Passed
Pull Request — master (#223)
by Kiran
10:03
created
geodirectory-admin/admin_functions.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6537,7 +6537,7 @@  discard block
 block discarded – undo
6537 6537
  *
6538 6538
  * @since 1.5.0
6539 6539
  *
6540
- * @return True if WPML is active else False.
6540
+ * @return boolean if WPML is active else False.
6541 6541
  */
6542 6542
 function geodir_is_wpml() {
6543 6543
 	if (function_exists('icl_object_id')) {
@@ -6633,7 +6633,7 @@  discard block
 block discarded – undo
6633 6633
  * @param int $master_post_id Original Post ID.
6634 6634
  * @param int $tr_post_id Translation Post ID.
6635 6635
  * @param string $lang Language code for translating post.
6636
- * @return bool True for success, False for fail.
6636
+ * @return boolean|null True for success, False for fail.
6637 6637
  */
6638 6638
 function geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang) {
6639 6639
 	global $sitepress, $wpdb;
Please login to merge, or discard this patch.
Spacing   +668 added lines, -668 removed lines patch added patch discarded remove patch
@@ -480,15 +480,15 @@  discard block
 block discarded – undo
480 480
                 <?php
481 481
 
482 482
                     $default_location = geodir_get_default_location();
483
-                  $city =  isset($default_location->city) ? $default_location->city : '';
484
-                  $region =isset($default_location->region) ? $default_location->region : '';
485
-                  $country =isset($default_location->country) ? $default_location->country : '';
486
-                  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
487
-                  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
483
+                  $city = isset($default_location->city) ? $default_location->city : '';
484
+                  $region = isset($default_location->region) ? $default_location->region : '';
485
+                  $country = isset($default_location->country) ? $default_location->country : '';
486
+                  $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
487
+                  $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
488 488
 
489 489
                 ?>
490 490
                 var geocoder = new google.maps.Geocoder();
491
-                var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>';
491
+                var CITY_ADDRESS = '<?php echo $city . ',' . $region . ',' . $country; ?>';
492 492
                 var bound_lat_lng;
493 493
                 var lat = <?php echo $city_latitude; ?>;
494 494
                 var lng = <?php echo $city_longitude; ?>;
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
                             );
526 526
 
527 527
                         } else {
528
-                            alert("<?php _e('Geocode was not successful for the following reason:','geodirectory');?> " + status);
528
+                            alert("<?php _e('Geocode was not successful for the following reason:', 'geodirectory'); ?> " + status);
529 529
                         }
530 530
                     });
531 531
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
                     var total_dummy_post_count = jQuery('#sub_' + active_tab).find('.selected_sample_data').val();
539 539
 
540 540
                     if (id == 'geodir_dummy_delete') {
541
-                        if (confirm('<?php _e('Are you sure you want to delete dummy data?' , 'geodirectory'); ?>')) {
541
+                        if (confirm('<?php _e('Are you sure you want to delete dummy data?', 'geodirectory'); ?>')) {
542 542
                             jQuery('#sub_' + active_tab).find('.geodir_auto_install').hide();
543 543
                             jQuery('#sub_' + active_tab).find('.geodir_show_progress').show();
544 544
                             jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&_wpnonce=' + nonce,
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
                         jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&insert_dummy_post_index=' + dummy_post_index + '&city_bound_lat1=' + bound_lat_lng[0] + '&city_bound_lng1=' + bound_lat_lng[1] + '&city_bound_lat2=' + bound_lat_lng[2] + '&city_bound_lng2=' + bound_lat_lng[3] + '&_wpnonce=' + nonce,
558 558
                             function (data) {
559 559
 
560
-                                jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:','geodirectory');?> ' + dummy_post_index + ' <?php _e('of' ,'geodirectory'); ?> ' + total_dummy_post_count + '');
560
+                                jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:', 'geodirectory'); ?> ' + dummy_post_index + ' <?php _e('of', 'geodirectory'); ?> ' + total_dummy_post_count + '');
561 561
                                 dummy_post_index++;
562 562
                                 if (dummy_post_index <= total_dummy_post_count)
563 563
                                     geodir_autoinstall(obj, id, nonce, posttype);
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
                     else
667 667
                         $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
668 668
                     $catname = str_replace(' ', '_', $catname);
669
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
669
+                    $uploaded = (array) fetch_remote_file("$dummy_image_url/" . $catname . ".png");
670 670
 
671 671
                     if (empty($uploaded['error'])) {
672 672
                         $new_path = $uploaded['file'];
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
                 else
708 708
                     $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
709 709
                 $catname = str_replace(' ', '_', $catname);
710
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
710
+                $uploaded = (array) fetch_remote_file("$dummy_image_url/" . $catname . ".png");
711 711
 
712 712
                 if (empty($uploaded['error'])) {
713 713
                     $new_path = $uploaded['file'];
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
  */
1017 1017
 function geodir_extend_geodirectory_setting_tab($tabs)
1018 1018
 {
1019
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1019
+    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory') . ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1020 1020
     return $tabs;
1021 1021
 }
1022 1022
 
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 function geodir_post_information_save($post_id, $post) {
1170 1170
     global $wpdb, $current_user;
1171 1171
 
1172
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1172
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
1173 1173
         return;
1174 1174
     }
1175 1175
 
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1310 1310
                                            id="<?php echo esc_attr($value['id']); ?>"
1311 1311
                                            type="<?php echo esc_attr($value['type']); ?>"
1312
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1312
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1313 1313
                                            style=" <?php echo esc_attr($value['css']); ?>"
1314 1314
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1315 1315
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1327 1327
                                            id="<?php echo esc_attr($value['id']); ?>"
1328 1328
                                            type="<?php echo esc_attr($value['type']); ?>"
1329
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1329
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1330 1330
                                            style="<?php echo esc_attr($value['css']); ?>"
1331 1331
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1332 1332
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
                                             id="<?php echo esc_attr($value['id']); ?>"
1433 1433
                                             style="<?php echo esc_attr($value['css']); ?>"
1434 1434
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1435
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1435
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>"
1436 1436
                                             option-ajaxchosen="false">
1437 1437
                         <?php
1438 1438
                         foreach ($value['options'] as $key => $val) {
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
                             } else {
1444 1444
                                 ?>
1445 1445
                                 <option
1446
-                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1446
+                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values))); ?>><?php echo ucfirst($val) ?></option>
1447 1447
                             <?php
1448 1448
                             }
1449 1449
                         }
@@ -1478,7 +1478,7 @@  discard block
 block discarded – undo
1478 1478
                 ?>
1479 1479
 
1480 1480
                 <tr valign="top">
1481
-                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1481
+                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
1482 1482
                     <td width="60%">
1483 1483
                         <select name="geodir_default_map_language" style="width:60%">
1484 1484
                             <?php
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
 
1561 1561
                 <tr valign="top">
1562 1562
                     <th class="titledesc"
1563
-                        width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
1563
+                        width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
1564 1564
                     <td width="60%">
1565 1565
                         <select name="geodir_default_map_search_pt" style="width:60%">
1566 1566
                             <?php
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
                         $cat_display = 'checkbox';
1602 1602
                         $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1603 1603
                         $gd_cats = get_option('geodir_exclude_cat_on_map');
1604
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1604
+                        $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
1605 1605
                         $count = 1;
1606 1606
                         ?>
1607 1607
                         <table width="70%" class="widefat">
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
                                                                                            name="home_map_post_types[]"
1631 1631
                                                                                            id="<?php echo esc_attr($value['id']); ?>"
1632 1632
                                                                                            value="<?php echo $key; ?>"
1633
-                                                                                           class="map_post_type" <?php echo $checked;?> />
1633
+                                                                                           class="map_post_type" <?php echo $checked; ?> />
1634 1634
                                         <?php echo $post_types_obj->labels->singular_name; ?></td>
1635 1635
                                     <td width="40%">
1636 1636
                                         <div class="home_map_category" style="overflow:auto;width:200px;height:100px;"
@@ -1688,12 +1688,12 @@  discard block
 block discarded – undo
1688 1688
                 ?>
1689 1689
                 <fieldset>
1690 1690
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1691
-                    <label for="<?php echo $value['id'];?>">
1691
+                    <label for="<?php echo $value['id']; ?>">
1692 1692
                         <input name="<?php echo esc_attr($value['id']); ?>"
1693 1693
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1694 1694
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1695 1695
                             echo 'checked="checked"';
1696
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1696
+                        }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
1697 1697
                         <?php echo $value['desc']; ?></label><br>
1698 1698
                 </fieldset>
1699 1699
                 <?php
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
                     <textarea
1716 1716
                         <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1717 1717
                         id="<?php echo esc_attr($value['id']); ?>"
1718
-                        <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1718
+                        <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1719 1719
                         style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) echo esc_textarea(stripslashes(get_option($value['id']))); else echo esc_textarea($value['std']); ?></textarea><span
1720 1720
                         class="description"><?php echo $value['desc'] ?></span>
1721 1721
 
@@ -1762,7 +1762,7 @@  discard block
 block discarded – undo
1762 1762
 					}
1763 1763
 				}
1764 1764
 				//
1765
-				$page_setting = (int)get_option($value['id']);
1765
+				$page_setting = (int) get_option($value['id']);
1766 1766
 
1767 1767
                 $args = array('name' => $value['id'],
1768 1768
                     'id' => $value['id'],
@@ -1789,7 +1789,7 @@  discard block
 block discarded – undo
1789 1789
                 break;
1790 1790
             case 'single_select_country' :
1791 1791
                 $countries = $geodirectory->countries->countries;
1792
-                $country_setting = (string)get_option($value['id']);
1792
+                $country_setting = (string) get_option($value['id']);
1793 1793
                 if (strstr($country_setting, ':')) :
1794 1794
                     $country = current(explode(':', $country_setting));
1795 1795
                     $state = end(explode(':', $country_setting));
@@ -1812,7 +1812,7 @@  discard block
 block discarded – undo
1812 1812
             case 'multi_select_countries' :
1813 1813
                 $countries = $geodirectory->countries->countries;
1814 1814
                 asort($countries);
1815
-                $selections = (array)get_option($value['id']);
1815
+                $selections = (array) get_option($value['id']);
1816 1816
                 ?>
1817 1817
                 <tr valign="top">
1818 1818
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1834,8 +1834,8 @@  discard block
 block discarded – undo
1834 1834
                 break;
1835 1835
 
1836 1836
             case 'google_analytics' :
1837
-                $selections = (array)get_option($value['id']);
1838
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1837
+                $selections = (array) get_option($value['id']);
1838
+                if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
1839 1839
                     ?>
1840 1840
                     <tr valign="top">
1841 1841
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1846,10 +1846,10 @@  discard block
 block discarded – undo
1846 1846
 
1847 1847
                             $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1848 1848
                             $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1849
-                            $state = "&state=123";//any string
1849
+                            $state = "&state=123"; //any string
1850 1850
                             $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1851 1851
                             $response_type = "&response_type=code";
1852
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1852
+                            $client_id = "&client_id=" . get_option('geodir_ga_client_id');
1853 1853
                             $access_type = "&access_type=offline";
1854 1854
                             $approval_prompt = "&approval_prompt=force";
1855 1855
 
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
                             ?>
1860 1860
                             <script>
1861 1861
                                 function gd_ga_popup() {
1862
-                                    var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
1862
+                                    var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
1863 1863
                                     var pollTimer = window.setInterval(function () {
1864 1864
                                         if (win.closed !== false) { // !== is required for compatibility with Opera
1865 1865
                                             window.clearInterval(pollTimer);
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
                             } else {
1882 1882
                                 ?>
1883 1883
                                 <span class="button-primary"
1884
-                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1884
+                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
1885 1885
                             <?php
1886 1886
                             }
1887 1887
                             ?>
@@ -1952,9 +1952,9 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
             <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
1954 1954
             jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
1955
-            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
1955
+            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
1956 1956
             jQuery('.gd-content-heading').hide();
1957
-            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
1957
+            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
1958 1958
             <?php } ?>
1959 1959
         });
1960 1960
     </script>
@@ -2096,7 +2096,7 @@  discard block
 block discarded – undo
2096 2096
         <div
2097 2097
             class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
2098 2098
             id="<?php echo $id; ?>plupload-upload-ui">
2099
-            <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
2099
+            <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
2100 2100
             <input id="<?php echo $id; ?>plupload-browse-button" type="button"
2101 2101
                    value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
2102 2102
             <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span>
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
              id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
2112 2112
         </div>
2113 2113
         <span
2114
-            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory');?></span>
2114
+            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory'); ?></span>
2115 2115
         <span id="<?php echo $id; ?>upload-error" style="display:none"></span>
2116 2116
     </div>
2117 2117
 
@@ -2489,11 +2489,11 @@  discard block
 block discarded – undo
2489 2489
 function geodir_hide_admin_preview_button() {
2490 2490
     global $post_type;
2491 2491
     $post_types = geodir_get_posttypes();
2492
-    if(in_array($post_type, $post_types))
2492
+    if (in_array($post_type, $post_types))
2493 2493
         echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2494 2494
 }
2495
-add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2496
-add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2495
+add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
2496
+add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
2497 2497
 
2498 2498
 /**
2499 2499
  * Add the tab in left sidebar menu fro import & export page.
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
  *
2504 2504
  * @return array Array of tab data.
2505 2505
  */
2506
-function geodir_import_export_tab( $tabs ) {
2507
-	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2506
+function geodir_import_export_tab($tabs) {
2507
+	$tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
2508 2508
     return $tabs;
2509 2509
 }
2510 2510
 
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
  * @return string Html content.
2519 2519
  */
2520 2520
 function geodir_import_export_page() {
2521
-	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2521
+	$nonce = wp_create_nonce('geodir_import_export_nonce');
2522 2522
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2523 2523
     /**
2524 2524
      * Filter sample category data csv file url.
@@ -2528,7 +2528,7 @@  discard block
 block discarded – undo
2528 2528
      *
2529 2529
      * @param string $gd_cats_sample_csv Sample category data csv file url.
2530 2530
      */
2531
-	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2531
+	$gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
2532 2532
 	
2533 2533
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2534 2534
     /**
@@ -2539,15 +2539,15 @@  discard block
 block discarded – undo
2539 2539
      *
2540 2540
      * @param string $gd_posts_sample_csv Sample post data csv file url.
2541 2541
      */
2542
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2542
+    $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
2543 2543
 	
2544
-	$gd_posttypes = geodir_get_posttypes( 'array' );
2544
+	$gd_posttypes = geodir_get_posttypes('array');
2545 2545
 	
2546 2546
 	$gd_posttypes_option = '';
2547
-	foreach ( $gd_posttypes as $gd_posttype => $row ) {
2548
-		$gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>';
2547
+	foreach ($gd_posttypes as $gd_posttype => $row) {
2548
+		$gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int) geodir_get_terms_count($gd_posttype) . '" data-posts="' . (int) geodir_get_posts_count($gd_posttype) . '">' . __($row['labels']['name'], 'geodirectory') . '</option>';
2549 2549
 	}
2550
-	wp_enqueue_script( 'jquery-ui-progressbar' );
2550
+	wp_enqueue_script('jquery-ui-progressbar');
2551 2551
 	
2552 2552
 	$gd_chunksize_options = array();
2553 2553
 	$gd_chunksize_options[100] = 100;
@@ -2569,7 +2569,7 @@  discard block
 block discarded – undo
2569 2569
      *
2570 2570
      * @param string $gd_chunksize_options Entries options.
2571 2571
      */
2572
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2572
+    $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
2573 2573
 	
2574 2574
 	$gd_chunksize_option = '';
2575 2575
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2580,38 +2580,38 @@  discard block
 block discarded – undo
2580 2580
 ?>
2581 2581
 </form>
2582 2582
 <div class="inner_content_tab_main gd-import-export">
2583
-  <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3>
2584
-  <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span>
2583
+  <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
2584
+  <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
2585 2585
   <div class="gd-content-heading">
2586 2586
 
2587 2587
   <?php
2588 2588
     ini_set('max_execution_time', 999999);
2589
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2589
+    $ini_max_execution_time_check = @ini_get('max_execution_time');
2590 2590
     ini_restore('max_execution_time');
2591 2591
 
2592
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2592
+    if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
2593 2593
         ?>
2594 2594
 	<div id="gd_ie_reqs" class="metabox-holder">
2595 2595
       <div class="meta-box-sortables ui-sortable">
2596 2596
         <div class="postbox">
2597
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3>
2597
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
2598 2598
           <div class="inside">
2599
-            <span class="description"><?php echo __( 'Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory' );?></span>
2599
+            <span class="description"><?php echo __('Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory'); ?></span>
2600 2600
 			<table class="form-table">
2601 2601
 				<thead>
2602 2602
 				  <tr>
2603
-				  	<th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th>
2603
+				  	<th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
2604 2604
 				  </tr>
2605 2605
 				</thead>
2606 2606
 				<tbody>
2607 2607
 				  <tr>
2608
-				  	<td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td>
2608
+				  	<td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
2609 2609
 				  </tr>
2610 2610
 				  <tr>
2611
-				  	<td>max_execution_time</td><td><?php  echo @ini_get( 'max_execution_time' );?></td><td>3000</td>
2611
+				  	<td>max_execution_time</td><td><?php  echo @ini_get('max_execution_time'); ?></td><td>3000</td>
2612 2612
 				  </tr>
2613 2613
 				  <tr>
2614
-				  	<td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td>
2614
+				  	<td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
2615 2615
 				  </tr>
2616 2616
 				</tbody>
2617 2617
 		    </table>
@@ -2623,21 +2623,21 @@  discard block
 block discarded – undo
2623 2623
 	<div id="gd_ie_imposts" class="metabox-holder">
2624 2624
       <div class="meta-box-sortables ui-sortable">
2625 2625
         <div id="gd_ie_im_posts" class="postbox gd-hndle-pbox">
2626
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Listings: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2627
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3>
2626
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Listings: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2627
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
2628 2628
           <div class="inside">
2629 2629
             <table class="form-table">
2630 2630
 				<tbody>
2631 2631
 				  <tr>
2632 2632
 					<td class="gd-imex-box">
2633 2633
 						<div class="gd-im-choices">
2634
-						<p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e( 'Update listing if post with post_id already exists.', 'geodirectory' );?></label></p>
2635
-						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e( 'Ignore listing if post with post_id already exists.', 'geodirectory' );?></label></p>
2634
+						<p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e('Update listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
2635
+						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e('Ignore listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
2636 2636
 						</div>
2637 2637
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui">
2638 2638
 							<input type="text" readonly="readonly" name="gd_im_post_file" class="gd-imex-file gd_im_post_file" id="gd_im_post" onclick="jQuery('#gd_im_postplupload-browse-button').trigger('click');" />
2639
-							<input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample">
2640
-						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" />
2639
+							<input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample">
2640
+						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" />
2641 2641
 							<?php
2642 2642
 							/**
2643 2643
 							 * Called just after the sample CSV download link.
@@ -2646,7 +2646,7 @@  discard block
 block discarded – undo
2646 2646
 							 */
2647 2647
 							do_action('geodir_sample_csv_download_link');
2648 2648
 							?>
2649
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span>
2649
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
2650 2650
 							<div class="filelist"></div>
2651 2651
 						</div>
2652 2652
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2664,7 +2664,7 @@  discard block
 block discarded – undo
2664 2664
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2665 2665
 						</div>
2666 2666
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2667
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2667
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2668 2668
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2669 2669
 									id="gd-import-perc">0%</font> )
2670 2670
 								<div class="gd-fileprogress"></div>
@@ -2676,10 +2676,10 @@  discard block
 block discarded – undo
2676 2676
                     	<div class="gd-imex-btns" style="display:none;">
2677 2677
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2678 2678
                         	<input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2679
-                        	<input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2680
-                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
2679
+                        	<input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2680
+                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
2681 2681
 							<div id="gd_process_data" style="display:none">
2682
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2682
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2683 2683
 							</div>
2684 2684
 						</div>
2685 2685
 					</td>
@@ -2693,26 +2693,26 @@  discard block
 block discarded – undo
2693 2693
 	<div id="gd_ie_excategs" class="metabox-holder">
2694 2694
 	  <div class="meta-box-sortables ui-sortable">
2695 2695
 		<div id="gd_ie_ex_posts" class="postbox gd-hndle-pbox">
2696
-		  <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - Listings: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2697
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3>
2696
+		  <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - Listings: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2697
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
2698 2698
 		  <div class="inside">
2699 2699
 			<table class="form-table">
2700 2700
 			  <tbody>
2701 2701
 				<tr>
2702 2702
 				  <td class="fld"><label for="gd_post_type">
2703
-					<?php _e( 'Post Type:', 'geodirectory' );?>
2703
+					<?php _e('Post Type:', 'geodirectory'); ?>
2704 2704
 					</label></td>
2705 2705
 				  <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px">
2706
-					  <?php echo $gd_posttypes_option;?>
2706
+					  <?php echo $gd_posttypes_option; ?>
2707 2707
 					</select></td>
2708 2708
 				</tr>
2709 2709
 				<tr>
2710
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2711
-					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td>
2710
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2711
+					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
2712 2712
 				  </tr>
2713 2713
 				<tr>
2714 2714
 				  <td class="fld" style="vertical-align:top"><label>
2715
-					<?php _e( 'Progress:', 'geodirectory' );?>
2715
+					<?php _e('Progress:', 'geodirectory'); ?>
2716 2716
 					</label></td>
2717 2717
 				  <td><div id='gd_progressbar_box'>
2718 2718
 					  <div id="gd_progressbar" class="gd_progressbar">
@@ -2720,13 +2720,13 @@  discard block
 block discarded – undo
2720 2720
 					  </div>
2721 2721
 					</div>
2722 2722
 					<p style="display:inline-block">
2723
-					  <?php _e( 'Elapsed Time:', 'geodirectory' );?>
2723
+					  <?php _e('Elapsed Time:', 'geodirectory'); ?>
2724 2724
 					</p>
2725 2725
 					  
2726 2726
 					<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2727 2727
 				</tr>
2728 2728
 				<tr class="gd-ie-actions">
2729
-				  <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit">
2729
+				  <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit">
2730 2730
 				  </td>
2731 2731
 				  <td id="gd_ie_ex_files" class="gd-ie-files"></td>
2732 2732
 				</tr>
@@ -2739,21 +2739,21 @@  discard block
 block discarded – undo
2739 2739
 	<div id="gd_ie_imcategs" class="metabox-holder">
2740 2740
       <div class="meta-box-sortables ui-sortable">
2741 2741
         <div id="gd_ie_imcats" class="postbox gd-hndle-pbox">
2742
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2743
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3>
2742
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2743
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
2744 2744
           <div class="inside">
2745 2745
             <table class="form-table">
2746 2746
 				<tbody>
2747 2747
 				  <tr>
2748 2748
 					<td class="gd-imex-box">
2749 2749
 						<div class="gd-im-choices">
2750
-						<p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e( 'Update item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p>
2751
-						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e( 'Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p>
2750
+						<p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e('Update item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
2751
+						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e('Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
2752 2752
 						</div>
2753 2753
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui">
2754 2754
 							<input type="text" readonly="readonly" name="gd_im_cat_file" class="gd-imex-file gd_im_cat_file" id="gd_im_cat" onclick="jQuery('#gd_im_catplupload-browse-button').trigger('click');" />
2755
-							<input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample">
2756
-						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" />
2755
+							<input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample">
2756
+						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" />
2757 2757
 						<?php
2758 2758
 						/**
2759 2759
 						 * Called just after the sample CSV download link.
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
 						 */
2764 2764
 						do_action('geodir_sample_cats_csv_download_link');
2765 2765
 						?>
2766
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span>
2766
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
2767 2767
 							<div class="filelist"></div>
2768 2768
 						</div>
2769 2769
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2780,7 +2780,7 @@  discard block
 block discarded – undo
2780 2780
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2781 2781
 						</div>
2782 2782
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2783
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2783
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2784 2784
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2785 2785
 									id="gd-import-perc">0%</font> )
2786 2786
 								<div class="gd-fileprogress"></div>
@@ -2792,10 +2792,10 @@  discard block
 block discarded – undo
2792 2792
                     	<div class="gd-imex-btns" style="display:none;">
2793 2793
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2794 2794
                         	<input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2795
-                        	<input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2796
-                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
2795
+                        	<input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2796
+                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
2797 2797
 							<div id="gd_process_data" style="display:none">
2798
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2798
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2799 2799
 							</div>
2800 2800
 						</div>
2801 2801
 					</td>
@@ -2809,26 +2809,26 @@  discard block
 block discarded – undo
2809 2809
 	<div id="gd_ie_excategs" class="metabox-holder">
2810 2810
       <div class="meta-box-sortables ui-sortable">
2811 2811
         <div id="gd_ie_ex_cats" class="postbox gd-hndle-pbox">
2812
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2813
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3>
2812
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2813
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
2814 2814
           <div class="inside">
2815 2815
             <table class="form-table">
2816 2816
 				<tbody>
2817 2817
 				  <tr>
2818
-					<td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td>
2819
-					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td>
2818
+					<td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
2819
+					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td>
2820 2820
 				  </tr>
2821 2821
 				   <tr>
2822
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2823
-					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td>
2822
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2823
+					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
2824 2824
 				  </tr>
2825 2825
 				  <tr>
2826
-					<td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td>
2827
-					<td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e( 'Elapsed Time:', 'geodirectory' );?></p>&nbsp;&nbsp;<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2826
+					<td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
2827
+					<td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e('Elapsed Time:', 'geodirectory'); ?></p>&nbsp;&nbsp;<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2828 2828
 				  </tr>
2829 2829
 				  <tr class="gd-ie-actions">
2830 2830
 					<td style="vertical-align:top">
2831
-						<input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2831
+						<input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2832 2832
 					</td>
2833 2833
 					<td id="gd_ie_ex_files" class="gd-ie-files"></td>
2834 2834
 				  </tr>
@@ -2850,7 +2850,7 @@  discard block
 block discarded – undo
2850 2850
      * @param array $gd_chunksize_options File chunk size options.
2851 2851
      * @param string $nonce Wordpress security token for GD import & export.
2852 2852
 	 */
2853
-	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2853
+	do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
2854 2854
 	?>
2855 2855
   </div>
2856 2856
 </div>
@@ -2869,7 +2869,7 @@  discard block
 block discarded – undo
2869 2869
         jQuery.ajax({
2870 2870
             url: ajaxurl,
2871 2871
             type: "POST",
2872
-            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>',
2872
+            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>',
2873 2873
             dataType: 'json',
2874 2874
             cache: false,
2875 2875
             success: function(data) {
@@ -2921,7 +2921,7 @@  discard block
 block discarded – undo
2921 2921
 
2922 2922
         jQuery(cont).find('.filelist .file').remove();
2923 2923
         
2924
-        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
2924
+        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
2925 2925
         jQuery('#gd-import-msg', cont).show();
2926 2926
         
2927 2927
         return false;
@@ -2980,7 +2980,7 @@  discard block
 block discarded – undo
2980 2980
     jQuery.ajax({
2981 2981
         url: ajaxurl,
2982 2982
         type: "POST",
2983
-        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>',
2983
+        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>',
2984 2984
         dataType : 'json',
2985 2985
         cache: false,
2986 2986
         success: function (data) {
@@ -3169,27 +3169,27 @@  discard block
 block discarded – undo
3169 3169
 
3170 3170
     var gdMsg = '<p></p>';
3171 3171
     if ( processed > 0 ) {
3172
-        var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>';
3172
+        var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
3173 3173
         msgParse = msgParse.replace("%s", processed);
3174 3174
         gdMsg += msgParse;
3175 3175
     }
3176 3176
 
3177 3177
     if ( updated > 0 ) {
3178
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3178
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
3179 3179
         msgParse = msgParse.replace("%s", updated);
3180 3180
         msgParse = msgParse.replace("%d", processed);
3181 3181
         gdMsg += msgParse;
3182 3182
     }
3183 3183
 
3184 3184
     if ( created > 0 ) {
3185
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3185
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
3186 3186
         msgParse = msgParse.replace("%s", created);
3187 3187
         msgParse = msgParse.replace("%d", processed);
3188 3188
         gdMsg += msgParse;
3189 3189
     }
3190 3190
 
3191 3191
     if ( skipped > 0 ) {
3192
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3192
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
3193 3193
         msgParse = msgParse.replace("%s", skipped);
3194 3194
         msgParse = msgParse.replace("%d", processed);
3195 3195
         gdMsg += msgParse;
@@ -3199,17 +3199,17 @@  discard block
 block discarded – undo
3199 3199
         if (type=='loc') {
3200 3200
             invalid_addr = invalid;
3201 3201
         }
3202
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ), '%s', '%d' ) );?></p>';
3202
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'), '%s', '%d')); ?></p>';
3203 3203
         msgParse = msgParse.replace("%s", invalid_addr);
3204 3204
         msgParse = msgParse.replace("%d", total);
3205 3205
         gdMsg += msgParse;
3206 3206
     }
3207 3207
 
3208 3208
     if (invalid > 0 && type!='loc') {
3209
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank title/invalid post type.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3209
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank title/invalid post type.', 'geodirectory'), '%s', '%d')); ?></p>';
3210 3210
         
3211 3211
         if (type=='hood') {
3212
-            msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ), '%s', '%d' ) );?></p>';
3212
+            msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory'), '%s', '%d')); ?></p>';
3213 3213
         }
3214 3214
         msgParse = msgParse.replace("%s", invalid);
3215 3215
         msgParse = msgParse.replace("%d", total);
@@ -3217,7 +3217,7 @@  discard block
 block discarded – undo
3217 3217
     }
3218 3218
 
3219 3219
     if (images > 0) {
3220
-        gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>';
3220
+        gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>';
3221 3221
     }
3222 3222
     gdMsg += '<p></p>';
3223 3223
     jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
@@ -3374,7 +3374,7 @@  discard block
 block discarded – undo
3374 3374
         
3375 3375
     function gd_process_export_posts(el, post_type, total_posts, chunk_size, pages, page) {
3376 3376
         if (page < 2) {
3377
-            gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3377
+            gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3378 3378
             jQuery(el).find('#gd_timer').text('00:00:01');
3379 3379
             jQuery('#gd_ie_ex_files', el).html('');
3380 3380
         }
@@ -3382,7 +3382,7 @@  discard block
 block discarded – undo
3382 3382
         jQuery.ajax({
3383 3383
             url: ajaxurl,
3384 3384
             type: "POST",
3385
-            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3385
+            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3386 3386
             dataType : 'json',
3387 3387
             cache: false,
3388 3388
             beforeSend: function (jqXHR, settings) {},
@@ -3396,11 +3396,11 @@  discard block
 block discarded – undo
3396 3396
                     } else {
3397 3397
                         if (pages < page || pages == page) {
3398 3398
                             window.clearInterval(timer_posts);
3399
-                            gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3399
+                            gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3400 3400
                         } else {
3401 3401
                             var percentage = Math.round(((page * chunk_size) / total_posts) * 100);
3402 3402
                             percentage = percentage > 100 ? 100 : percentage;
3403
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3403
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3404 3404
                         }
3405 3405
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3406 3406
                             var obj_files = data.files;
@@ -3430,7 +3430,7 @@  discard block
 block discarded – undo
3430 3430
 
3431 3431
     function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
3432 3432
         if (page < 2) {
3433
-            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3433
+            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3434 3434
             jQuery(el).find('#gd_timer').text('00:00:01');
3435 3435
             jQuery('#gd_ie_ex_files', el).html('');
3436 3436
         }
@@ -3438,7 +3438,7 @@  discard block
 block discarded – undo
3438 3438
         jQuery.ajax({
3439 3439
             url: ajaxurl,
3440 3440
             type: "POST",
3441
-            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3441
+            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3442 3442
             dataType : 'json',
3443 3443
             cache: false,
3444 3444
             beforeSend: function (jqXHR, settings) {},
@@ -3452,11 +3452,11 @@  discard block
 block discarded – undo
3452 3452
                     } else {
3453 3453
                         if (pages < page || pages == page) {
3454 3454
                             window.clearInterval(timer_cats);
3455
-                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3455
+                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3456 3456
                         } else {
3457 3457
                             var percentage = Math.round(((page * chunk_size) / total_cats) * 100);
3458 3458
                             percentage = percentage > 100 ? 100 : percentage;
3459
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
3459
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
3460 3460
                         }
3461 3461
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3462 3462
                             var obj_files = data.files;
@@ -3513,8 +3513,8 @@  discard block
 block discarded – undo
3513 3513
 function geodir_init_filesystem()
3514 3514
 {
3515 3515
 
3516
-    if(!function_exists('get_filesystem_method')){
3517
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3516
+    if (!function_exists('get_filesystem_method')) {
3517
+        require_once(ABSPATH . "/wp-admin/includes/file.php");
3518 3518
     }
3519 3519
     $access_type = get_filesystem_method();
3520 3520
     if ($access_type === 'direct') {
@@ -3567,7 +3567,7 @@  discard block
 block discarded – undo
3567 3567
  * @package GeoDirectory
3568 3568
  */
3569 3569
 function geodir_filesystem_notice()
3570
-{   if ( defined( 'DOING_AJAX' ) ){return;}
3570
+{   if (defined('DOING_AJAX')) {return; }
3571 3571
     $access_type = get_filesystem_method();
3572 3572
     if ($access_type === 'direct') {
3573 3573
     } elseif (!defined('FTP_USER')) {
@@ -3604,64 +3604,64 @@  discard block
 block discarded – undo
3604 3604
     // try to set higher limits for import
3605 3605
     $max_input_time = ini_get('max_input_time');
3606 3606
     $max_execution_time = ini_get('max_execution_time');
3607
-    $memory_limit= ini_get('memory_limit');
3607
+    $memory_limit = ini_get('memory_limit');
3608 3608
 
3609
-    if(!$max_input_time || $max_input_time<3000){
3609
+    if (!$max_input_time || $max_input_time < 3000) {
3610 3610
         ini_set('max_input_time', 3000);
3611 3611
     }
3612 3612
 
3613
-    if(!$max_execution_time || $max_execution_time<3000){
3613
+    if (!$max_execution_time || $max_execution_time < 3000) {
3614 3614
         ini_set('max_execution_time', 3000);
3615 3615
     }
3616 3616
 
3617
-    if($memory_limit && str_replace('M','',$memory_limit)){
3618
-        if(str_replace('M','',$memory_limit)<256){
3617
+    if ($memory_limit && str_replace('M', '', $memory_limit)) {
3618
+        if (str_replace('M', '', $memory_limit) < 256) {
3619 3619
             ini_set('memory_limit', '256M');
3620 3620
         }
3621 3621
     }
3622 3622
 
3623 3623
     $json = array();
3624 3624
 
3625
-    if ( !current_user_can( 'manage_options' ) ) {
3626
-        wp_send_json( $json );
3625
+    if (!current_user_can('manage_options')) {
3626
+        wp_send_json($json);
3627 3627
     }
3628 3628
 
3629
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3630
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3631
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3629
+    $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL;
3630
+    $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL;
3631
+    $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false;
3632 3632
 
3633
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3634
-        wp_send_json( $json );
3633
+    if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
3634
+        wp_send_json($json);
3635 3635
     }
3636 3636
 
3637
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3638
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3637
+    $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL;
3638
+    $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL;
3639 3639
     $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3640
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3640
+    $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1;
3641 3641
 
3642 3642
     $wp_filesystem = geodir_init_filesystem();
3643 3643
     if (!$wp_filesystem) {
3644
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3645
-        wp_send_json( $json );
3644
+        $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
3645
+        wp_send_json($json);
3646 3646
     }
3647 3647
 
3648 3648
     if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3649
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3650
-        wp_send_json( $json );
3649
+        $json['error'] = __('Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory');
3650
+        wp_send_json($json);
3651 3651
     }
3652 3652
 
3653
-    $csv_file_dir = geodir_path_import_export( false );
3654
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3655
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3656
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3657
-            wp_send_json( $json );
3653
+    $csv_file_dir = geodir_path_import_export(false);
3654
+    if (!$wp_filesystem->is_dir($csv_file_dir)) {
3655
+        if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
3656
+            $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
3657
+            wp_send_json($json);
3658 3658
         }
3659 3659
     }
3660 3660
     
3661 3661
     $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3662 3662
     $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3663 3663
 
3664
-    switch ( $task ) {
3664
+    switch ($task) {
3665 3665
         case 'export_posts': {
3666 3666
             // WPML
3667 3667
             $is_wpml = geodir_is_wpml();
@@ -3672,12 +3672,12 @@  discard block
 block discarded – undo
3672 3672
                 $sitepress->switch_lang('all', true);
3673 3673
             }
3674 3674
             // WPML
3675
-            if ( $post_type == 'gd_event' ) {
3675
+            if ($post_type == 'gd_event') {
3676 3676
                 //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 );
3677
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3677
+                add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
3678 3678
             }
3679
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3680
-            $posts_count = geodir_get_posts_count( $post_type );
3679
+            $file_name = $post_type . '_' . date('dmyHi');
3680
+            $posts_count = geodir_get_posts_count($post_type);
3681 3681
             $file_url_base = geodir_path_import_export() . '/';
3682 3682
             $file_url = $file_url_base . $file_name . '.csv';
3683 3683
             $file_path = $csv_file_dir . '/' . $file_name . '.csv';
@@ -3685,10 +3685,10 @@  discard block
 block discarded – undo
3685 3685
             
3686 3686
             $chunk_file_paths = array();
3687 3687
 
3688
-            if ( isset( $_REQUEST['_st'] ) ) {
3689
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3690
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3691
-                $percentage = min( $percentage, 100 );
3688
+            if (isset($_REQUEST['_st'])) {
3689
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3690
+                $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0;
3691
+                $percentage = min($percentage, 100);
3692 3692
                 
3693 3693
                 $json['percentage'] = $percentage;
3694 3694
                 // WPML
@@ -3696,45 +3696,45 @@  discard block
 block discarded – undo
3696 3696
                     $sitepress->switch_lang($active_lang, true);
3697 3697
                 }
3698 3698
                 // WPML
3699
-                wp_send_json( $json );
3699
+                wp_send_json($json);
3700 3700
                 exit;
3701 3701
             } else {
3702
-                if ( !$posts_count > 0 ) {
3703
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3702
+                if (!$posts_count > 0) {
3703
+                    $json['error'] = __('No records to export.', 'geodirectory');
3704 3704
                 } else {
3705 3705
                     $total_posts = $posts_count;
3706 3706
                     if ($chunk_per_page > $total_posts) {
3707 3707
                         $chunk_per_page = $total_posts;
3708 3708
                     }
3709
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3709
+                    $chunk_total_pages = ceil($total_posts / $chunk_per_page);
3710 3710
                     
3711 3711
                     $j = $chunk_page_no;
3712
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3712
+                    $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j);
3713 3713
                     
3714 3714
                     $per_page = 500;
3715 3715
                     if ($per_page > $chunk_per_page) {
3716 3716
                         $per_page = $chunk_per_page;
3717 3717
                     }
3718
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3718
+                    $total_pages = ceil($chunk_per_page / $per_page);
3719 3719
                     
3720
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3721
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3720
+                    for ($i = 0; $i <= $total_pages; $i++) {
3721
+                        $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page);
3722 3722
                         
3723 3723
                         $clear = $i == 0 ? true : false;
3724
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3724
+                        geodir_save_csv_data($file_path_temp, $save_posts, $clear);
3725 3725
                     }
3726 3726
                         
3727
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3727
+                    if ($wp_filesystem->exists($file_path_temp)) {
3728 3728
                         $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3729 3729
                         $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3730 3730
                         $file_path = $csv_file_dir . '/' . $chunk_file_name;
3731
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3731
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3732 3732
                         
3733 3733
                         $file_url = $file_url_base . $chunk_file_name;
3734 3734
                         $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3735 3735
                     }
3736 3736
                     
3737
-                    if ( !empty($chunk_file_paths) ) {
3737
+                    if (!empty($chunk_file_paths)) {
3738 3738
                         $json['total'] = $posts_count;
3739 3739
                         $json['files'] = $chunk_file_paths;
3740 3740
                     } else {
@@ -3742,7 +3742,7 @@  discard block
 block discarded – undo
3742 3742
                             $json['total'] = $items_count;
3743 3743
                             $json['files'] = array();
3744 3744
                         } else {
3745
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3745
+                            $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3746 3746
                         }
3747 3747
                     }
3748 3748
                 }
@@ -3751,7 +3751,7 @@  discard block
 block discarded – undo
3751 3751
                     $sitepress->switch_lang($active_lang, true);
3752 3752
                 }
3753 3753
                 // WPML
3754
-                wp_send_json( $json );
3754
+                wp_send_json($json);
3755 3755
             }
3756 3756
         }
3757 3757
         break;
@@ -3765,9 +3765,9 @@  discard block
 block discarded – undo
3765 3765
                 $sitepress->switch_lang('all', true);
3766 3766
             }
3767 3767
             // WPML
3768
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3768
+            $file_name = $post_type . 'category_' . date('dmyHi');
3769 3769
             
3770
-            $terms_count = geodir_get_terms_count( $post_type );
3770
+            $terms_count = geodir_get_terms_count($post_type);
3771 3771
             $file_url_base = geodir_path_import_export() . '/';
3772 3772
             $file_url = $file_url_base . $file_name . '.csv';
3773 3773
             $file_path = $csv_file_dir . '/' . $file_name . '.csv';
@@ -3775,10 +3775,10 @@  discard block
 block discarded – undo
3775 3775
             
3776 3776
             $chunk_file_paths = array();
3777 3777
             
3778
-            if ( isset( $_REQUEST['_st'] ) ) {
3779
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3780
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3781
-                $percentage = min( $percentage, 100 );
3778
+            if (isset($_REQUEST['_st'])) {
3779
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3780
+                $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0;
3781
+                $percentage = min($percentage, 100);
3782 3782
                 
3783 3783
                 $json['percentage'] = $percentage;
3784 3784
                 // WPML
@@ -3786,48 +3786,48 @@  discard block
 block discarded – undo
3786 3786
                     $sitepress->switch_lang($active_lang, true);
3787 3787
                 }
3788 3788
                 // WPML
3789
-                wp_send_json( $json );
3789
+                wp_send_json($json);
3790 3790
             } else {
3791
-                if ( !$terms_count > 0 ) {
3792
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3791
+                if (!$terms_count > 0) {
3792
+                    $json['error'] = __('No records to export.', 'geodirectory');
3793 3793
                 } else {
3794 3794
                     $total_terms = $terms_count;
3795 3795
                     if ($chunk_per_page > $terms_count) {
3796 3796
                         $chunk_per_page = $terms_count;
3797 3797
                     }
3798
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3798
+                    $chunk_total_pages = ceil($total_terms / $chunk_per_page);
3799 3799
                     
3800 3800
                     $j = $chunk_page_no;
3801
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3801
+                    $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j);
3802 3802
                     
3803 3803
                     $per_page = 500;
3804 3804
                     if ($per_page > $chunk_per_page) {
3805 3805
                         $per_page = $chunk_per_page;
3806 3806
                     }
3807
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3807
+                    $total_pages = ceil($chunk_per_page / $per_page);
3808 3808
                     
3809
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3810
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3809
+                    for ($i = 0; $i <= $total_pages; $i++) {
3810
+                        $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page);
3811 3811
                         
3812 3812
                         $clear = $i == 0 ? true : false;
3813
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3813
+                        geodir_save_csv_data($file_path_temp, $save_terms, $clear);
3814 3814
                     }
3815 3815
                     
3816
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3816
+                    if ($wp_filesystem->exists($file_path_temp)) {
3817 3817
                         $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3818 3818
                         $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3819 3819
                         $file_path = $csv_file_dir . '/' . $chunk_file_name;
3820
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3820
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3821 3821
                         
3822 3822
                         $file_url = $file_url_base . $chunk_file_name;
3823 3823
                         $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3824 3824
                     }
3825 3825
                     
3826
-                    if ( !empty($chunk_file_paths) ) {
3826
+                    if (!empty($chunk_file_paths)) {
3827 3827
                         $json['total'] = $terms_count;
3828 3828
                         $json['files'] = $chunk_file_paths;
3829 3829
                     } else {
3830
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3830
+                        $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3831 3831
                     }
3832 3832
                 }
3833 3833
                 // WPML
@@ -3835,127 +3835,127 @@  discard block
 block discarded – undo
3835 3835
                     $sitepress->switch_lang($active_lang, true);
3836 3836
                 }
3837 3837
                 // WPML
3838
-                wp_send_json( $json );
3838
+                wp_send_json($json);
3839 3839
             }
3840 3840
         }
3841 3841
         break;
3842 3842
         case 'export_locations': {
3843 3843
             $file_url_base = geodir_path_import_export() . '/';
3844
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3844
+            $file_name = 'gd_locations_' . date('dmyHi');
3845 3845
             $file_url = $file_url_base . $file_name . '.csv';
3846 3846
             $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3847 3847
             $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3848 3848
             
3849
-            $items_count = (int)geodir_location_imex_count_locations();
3849
+            $items_count = (int) geodir_location_imex_count_locations();
3850 3850
             
3851
-            if ( isset( $_REQUEST['_st'] ) ) {
3852
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3853
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3854
-                $percentage = min( $percentage, 100 );
3851
+            if (isset($_REQUEST['_st'])) {
3852
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3853
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3854
+                $percentage = min($percentage, 100);
3855 3855
                 
3856 3856
                 $json['percentage'] = $percentage;
3857
-                wp_send_json( $json );
3857
+                wp_send_json($json);
3858 3858
             } else {
3859 3859
                 $chunk_file_paths = array();
3860 3860
                 
3861
-                if ( !$items_count > 0 ) {
3862
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3861
+                if (!$items_count > 0) {
3862
+                    $json['error'] = __('No records to export.', 'geodirectory');
3863 3863
                 } else {
3864
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3865
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3864
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3865
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3866 3866
                     
3867 3867
                     $j = $chunk_page_no;
3868
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3868
+                    $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j);
3869 3869
                     
3870 3870
                     $per_page = 500;
3871
-                    $per_page = min( $per_page, $chunk_per_page );
3872
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3871
+                    $per_page = min($per_page, $chunk_per_page);
3872
+                    $total_pages = ceil($chunk_per_page / $per_page);
3873 3873
                     
3874
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3875
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3874
+                    for ($i = 0; $i <= $total_pages; $i++) {
3875
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3876 3876
                         
3877 3877
                         $clear = $i == 0 ? true : false;
3878
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3878
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3879 3879
                     }
3880 3880
                     
3881
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3881
+                    if ($wp_filesystem->exists($file_path_temp)) {
3882 3882
                         $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3883 3883
                         $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3884 3884
                         $file_path = $csv_file_dir . '/' . $chunk_file_name;
3885
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3885
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3886 3886
                         
3887 3887
                         $file_url = $file_url_base . $chunk_file_name;
3888 3888
                         $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3889 3889
                     }
3890 3890
                     
3891
-                    if ( !empty($chunk_file_paths) ) {
3891
+                    if (!empty($chunk_file_paths)) {
3892 3892
                         $json['total'] = $items_count;
3893 3893
                         $json['files'] = $chunk_file_paths;
3894 3894
                     } else {
3895
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3895
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3896 3896
                     }
3897 3897
                 }
3898
-                wp_send_json( $json );
3898
+                wp_send_json($json);
3899 3899
             }
3900 3900
         }
3901 3901
         break;
3902 3902
         case 'export_hoods': {
3903 3903
             $file_url_base = geodir_path_import_export() . '/';
3904
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3904
+            $file_name = 'gd_neighbourhoods_' . date('dmyHi');
3905 3905
             $file_url = $file_url_base . $file_name . '.csv';
3906 3906
             $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3907 3907
             $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3908 3908
             
3909
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3909
+            $items_count = (int) geodir_location_imex_count_neighbourhoods();
3910 3910
             
3911
-            if ( isset( $_REQUEST['_st'] ) ) {
3912
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3913
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3914
-                $percentage = min( $percentage, 100 );
3911
+            if (isset($_REQUEST['_st'])) {
3912
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3913
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3914
+                $percentage = min($percentage, 100);
3915 3915
                 
3916 3916
                 $json['percentage'] = $percentage;
3917
-                wp_send_json( $json );
3917
+                wp_send_json($json);
3918 3918
             } else {
3919 3919
                 $chunk_file_paths = array();
3920 3920
                 
3921
-                if ( !$items_count > 0 ) {
3922
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3921
+                if (!$items_count > 0) {
3922
+                    $json['error'] = __('No records to export.', 'geodirectory');
3923 3923
                 } else {
3924
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3925
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3924
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3925
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3926 3926
                     
3927 3927
                     $j = $chunk_page_no;
3928
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3928
+                    $chunk_save_items = geodir_location_imex_neighbourhoods_data($chunk_per_page, $j);
3929 3929
                     
3930 3930
                     $per_page = 500;
3931
-                    $per_page = min( $per_page, $chunk_per_page );
3932
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3931
+                    $per_page = min($per_page, $chunk_per_page);
3932
+                    $total_pages = ceil($chunk_per_page / $per_page);
3933 3933
                     
3934
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3935
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3934
+                    for ($i = 0; $i <= $total_pages; $i++) {
3935
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3936 3936
                         
3937 3937
                         $clear = $i == 0 ? true : false;
3938
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3938
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3939 3939
                     }
3940 3940
                     
3941
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3941
+                    if ($wp_filesystem->exists($file_path_temp)) {
3942 3942
                         $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3943 3943
                         $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3944 3944
                         $file_path = $csv_file_dir . '/' . $chunk_file_name;
3945
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3945
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3946 3946
                         
3947 3947
                         $file_url = $file_url_base . $chunk_file_name;
3948 3948
                         $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3949 3949
                     }
3950 3950
                     
3951
-                    if ( !empty($chunk_file_paths) ) {
3951
+                    if (!empty($chunk_file_paths)) {
3952 3952
                         $json['total'] = $items_count;
3953 3953
                         $json['files'] = $chunk_file_paths;
3954 3954
                     } else {
3955
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3955
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3956 3956
                     }
3957 3957
                 }
3958
-                wp_send_json( $json );
3958
+                wp_send_json($json);
3959 3959
             }
3960 3960
         }
3961 3961
         break;
@@ -3972,32 +3972,32 @@  discard block
 block discarded – undo
3972 3972
             }
3973 3973
             // WPML
3974 3974
             
3975
-            ini_set( 'auto_detect_line_endings', true );
3975
+            ini_set('auto_detect_line_endings', true);
3976 3976
             
3977 3977
             $uploads = wp_upload_dir();
3978 3978
             $uploads_dir = $uploads['path'];
3979 3979
             $uploads_subdir = $uploads['subdir'];
3980 3980
             
3981
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3982
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3981
+            $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL;
3982
+            $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip';
3983 3983
             
3984
-            $csv_file_arr = explode( '/', $csv_file );
3985
-            $csv_filename = end( $csv_file_arr );
3984
+            $csv_file_arr = explode('/', $csv_file);
3985
+            $csv_filename = end($csv_file_arr);
3986 3986
             $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3987 3987
             
3988 3988
             $json['file'] = $csv_file;
3989
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3989
+            $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
3990 3990
 
3991
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3992
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3991
+            if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
3992
+                $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename);
3993 3993
                 
3994 3994
                 if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
3995 3995
                     $json['error'] = NULL;
3996 3996
                     $json['rows'] = 0;
3997 3997
                     
3998
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
3999
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4000
-                            if ( !empty( $data ) ) {
3998
+                    if (($handle = fopen($target_path, "r")) !== FALSE) {
3999
+                        while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
4000
+                            if (!empty($data)) {
4001 4001
                                 $file[] = $data;
4002 4002
                             }
4003 4003
                         }
@@ -4010,19 +4010,19 @@  discard block
 block discarded – undo
4010 4010
                         $json['error'] = __('No data found in csv file.', 'geodirectory');
4011 4011
                     }
4012 4012
                 } else {
4013
-                    wp_send_json( $json );
4013
+                    wp_send_json($json);
4014 4014
                 }
4015 4015
             } else {
4016
-                wp_send_json( $json );
4016
+                wp_send_json($json);
4017 4017
             }
4018 4018
             
4019
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4020
-                wp_send_json( $json );
4019
+            if ($task == 'prepare_import' || !empty($json['error'])) {
4020
+                wp_send_json($json);
4021 4021
             }
4022 4022
             
4023 4023
             $total = $json['rows'];
4024
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4025
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4024
+            $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1;
4025
+            $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0;
4026 4026
             
4027 4027
             $count = $limit;
4028 4028
             $requested_limit = $limit;
@@ -4051,13 +4051,13 @@  discard block
 block discarded – undo
4051 4051
             
4052 4052
             $post_types = geodir_get_posttypes();
4053 4053
 
4054
-            if ( $task == 'import_cat' ) {				
4054
+            if ($task == 'import_cat') {				
4055 4055
                 if (!empty($file)) {
4056 4056
                     $columns = isset($file[0]) ? $file[0] : NULL;
4057 4057
                     
4058 4058
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4059 4059
                         $json['error'] = CSV_INVAILD_FILE;
4060
-                        wp_send_json( $json );
4060
+                        wp_send_json($json);
4061 4061
                         exit;
4062 4062
                     }
4063 4063
                     
@@ -4066,7 +4066,7 @@  discard block
 block discarded – undo
4066 4066
                         
4067 4067
                         if (isset($file[$index])) {
4068 4068
                             $row = $file[$index];
4069
-                            $row = array_map( 'trim', $row );
4069
+                            $row = array_map('trim', $row);
4070 4070
                             //$row = array_map( 'utf8_encode', $row );
4071 4071
                             
4072 4072
                             $cat_id = '';
@@ -4082,26 +4082,26 @@  discard block
 block discarded – undo
4082 4082
                             $cat_language = '';
4083 4083
                             
4084 4084
                             $c = 0;
4085
-                            foreach ($columns as $column ) {
4086
-                                if ( $column == 'cat_id' ) {
4087
-                                    $cat_id = (int)$row[$c];
4088
-                                } else if ( $column == 'cat_name' ) {
4085
+                            foreach ($columns as $column) {
4086
+                                if ($column == 'cat_id') {
4087
+                                    $cat_id = (int) $row[$c];
4088
+                                } else if ($column == 'cat_name') {
4089 4089
                                     $cat_name = $row[$c];
4090
-                                } else if ( $column == 'cat_slug' ) {
4090
+                                } else if ($column == 'cat_slug') {
4091 4091
                                     $cat_slug = $row[$c];
4092
-                                } else if ( $column == 'cat_posttype' ) {
4092
+                                } else if ($column == 'cat_posttype') {
4093 4093
                                     $cat_posttype = $row[$c];
4094
-                                } else if ( $column == 'cat_parent' ) {
4094
+                                } else if ($column == 'cat_parent') {
4095 4095
                                     $cat_parent = trim($row[$c]);
4096
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4096
+                                } else if ($column == 'cat_schema' && $row[$c] != '') {
4097 4097
                                     $cat_schema = $row[$c];
4098
-                                } else if ( $column == 'cat_description' ) {
4098
+                                } else if ($column == 'cat_description') {
4099 4099
                                     $cat_description = $row[$c];
4100
-                                } else if ( $column == 'cat_top_description' ) {
4100
+                                } else if ($column == 'cat_top_description') {
4101 4101
                                     $cat_top_description = $row[$c];
4102
-                                } else if ( $column == 'cat_image' ) {
4102
+                                } else if ($column == 'cat_image') {
4103 4103
                                     $cat_image = $row[$c];
4104
-                                } else if ( $column == 'cat_icon' ) {
4104
+                                } else if ($column == 'cat_icon') {
4105 4105
                                     $cat_icon = $row[$c];
4106 4106
                                 }
4107 4107
                                 // WPML
@@ -4112,7 +4112,7 @@  discard block
 block discarded – undo
4112 4112
                                 $c++;
4113 4113
                             }
4114 4114
                             
4115
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4115
+                            if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
4116 4116
                                 $invalid++;
4117 4117
                                 continue;
4118 4118
                             }
@@ -4129,8 +4129,8 @@  discard block
 block discarded – undo
4129 4129
                             $term_data['description'] = $cat_description;
4130 4130
                             $term_data['cat_schema'] = $cat_schema;
4131 4131
                             $term_data['top_description'] = $cat_top_description;
4132
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4133
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4132
+                            $term_data['image'] = $cat_image != '' ? basename($cat_image) : '';
4133
+                            $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : '';
4134 4134
                             
4135 4135
                             //$term_data = array_map( 'utf8_encode', $term_data );
4136 4136
                             
@@ -4139,14 +4139,14 @@  discard block
 block discarded – undo
4139 4139
                             $term_data['taxonomy'] = $taxonomy;
4140 4140
 
4141 4141
                             $term_parent_id = 0;
4142
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4142
+                            if ($cat_parent != "" || (int) $cat_parent > 0) {
4143 4143
                                 $term_parent = '';
4144 4144
                                 
4145
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4145
+                                if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
4146 4146
                                     $term_parent = $term_parent;
4147
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4147
+                                } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
4148 4148
                                     $term_parent = $term_parent;
4149
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4149
+                                } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
4150 4150
                                     $term_parent = $term_parent;
4151 4151
                                 } else {
4152 4152
                                     $term_parent_data = array();
@@ -4154,47 +4154,47 @@  discard block
 block discarded – undo
4154 4154
                                     //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );										
4155 4155
                                     $term_parent_data['taxonomy'] = $taxonomy;
4156 4156
                                     
4157
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4157
+                                    $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data);
4158 4158
                                 }
4159 4159
                                 
4160
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4161
-                                    $term_parent_id = (int)$term_parent->term_id;
4160
+                                if (!empty($term_parent) && !is_wp_error($term_parent)) {
4161
+                                    $term_parent_id = (int) $term_parent->term_id;
4162 4162
                                 }
4163 4163
                             }
4164
-                            $term_data['parent'] = (int)$term_parent_id;
4164
+                            $term_data['parent'] = (int) $term_parent_id;
4165 4165
 
4166 4166
                             $term_id = NULL;
4167
-                            if ( $import_choice == 'update' ) {
4168
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4167
+                            if ($import_choice == 'update') {
4168
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4169 4169
                                     $term_data['term_id'] = $term['term_id'];
4170 4170
                                     
4171
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4171
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4172 4172
                                         $updated++;
4173 4173
                                     } else {
4174 4174
                                         $invalid++;
4175 4175
                                     }
4176
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4176
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4177 4177
                                     $term_data['term_id'] = $term['term_id'];
4178 4178
                                     
4179
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4179
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4180 4180
                                         $updated++;
4181 4181
                                     } else {
4182 4182
                                         $invalid++;
4183 4183
                                     }
4184 4184
                                 } else {
4185
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4185
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
4186 4186
                                         $created++;
4187 4187
                                     } else {
4188 4188
                                         $invalid++;
4189 4189
                                     }
4190 4190
                                 }
4191
-                            } else if ( $import_choice == 'skip' ) {
4192
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4191
+                            } else if ($import_choice == 'skip') {
4192
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4193 4193
                                     $skipped++;
4194
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4194
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4195 4195
                                     $skipped++;
4196 4196
                                 } else {
4197
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {										
4197
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {										
4198 4198
                                         $created++;
4199 4199
                                     } else {
4200 4200
                                         $invalid++;
@@ -4204,37 +4204,37 @@  discard block
 block discarded – undo
4204 4204
                                 $invalid++;
4205 4205
                             }
4206 4206
                             
4207
-                            if ( $term_id ) {
4208
-                                if ( isset( $term_data['top_description'] ) ) {
4209
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4207
+                            if ($term_id) {
4208
+                                if (isset($term_data['top_description'])) {
4209
+                                    update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype);
4210 4210
                                 }
4211 4211
                                 
4212
-                                if ( isset( $term_data['cat_schema'] ) ) {
4213
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4212
+                                if (isset($term_data['cat_schema'])) {
4213
+                                    update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype);
4214 4214
                                 }
4215 4215
             
4216 4216
                                 $attachment = false;
4217
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4218
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4219
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4217
+                                if (isset($term_data['image']) && $term_data['image'] != '') {
4218
+                                    $cat_image = geodir_get_default_catimage($term_id, $cat_posttype);
4219
+                                    $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : '';
4220 4220
                                     
4221
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4221
+                                    if (basename($cat_image) != $term_data['image']) {
4222 4222
                                         $attachment = true;
4223
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4223
+                                        update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image']), $cat_posttype);
4224 4224
                                     }
4225 4225
                                 }
4226 4226
                                 
4227
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4228
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4229
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4227
+                                if (isset($term_data['icon']) && $term_data['icon'] != '') {
4228
+                                    $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype);
4229
+                                    $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
4230 4230
                                         
4231
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4231
+                                    if (basename($cat_icon) != $term_data['icon']) {
4232 4232
                                         $attachment = true;
4233
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4233
+                                        update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon']), $cat_posttype);
4234 4234
                                     }
4235 4235
                                 }
4236 4236
                                 
4237
-                                if ( $attachment ) {
4237
+                                if ($attachment) {
4238 4238
                                     $images++;
4239 4239
                                 }
4240 4240
                             }
@@ -4256,14 +4256,14 @@  discard block
 block discarded – undo
4256 4256
                 $json['invalid'] = $invalid;
4257 4257
                 $json['images'] = $images;
4258 4258
                 
4259
-                wp_send_json( $json );
4259
+                wp_send_json($json);
4260 4260
                 exit;
4261
-            } else if ( $task == 'import_post' ) {
4261
+            } else if ($task == 'import_post') {
4262 4262
 
4263 4263
                 //run some stuff to make the import quicker
4264
-                wp_defer_term_counting( true );
4265
-                wp_defer_comment_counting( true );
4266
-                $wpdb->query( 'SET autocommit = 0;' );
4264
+                wp_defer_term_counting(true);
4265
+                wp_defer_comment_counting(true);
4266
+                $wpdb->query('SET autocommit = 0;');
4267 4267
 
4268 4268
                 //remove_all_actions('publish_post');
4269 4269
                 //remove_all_actions('transition_post_status');
@@ -4272,26 +4272,26 @@  discard block
 block discarded – undo
4272 4272
                 if (!empty($file)) {
4273 4273
                     $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4274 4274
                     $default_status = 'publish';
4275
-                    $current_date = date_i18n( 'Y-m-d', time() );
4275
+                    $current_date = date_i18n('Y-m-d', time());
4276 4276
                     
4277 4277
                     $columns = isset($file[0]) ? $file[0] : NULL;
4278 4278
                     
4279 4279
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4280 4280
                         $json['error'] = CSV_INVAILD_FILE;
4281
-                        wp_send_json( $json );
4281
+                        wp_send_json($json);
4282 4282
                         exit;
4283 4283
                     }
4284 4284
 
4285
-                    $processed_actual=0;
4285
+                    $processed_actual = 0;
4286 4286
                     for ($i = 1; $i <= $limit; $i++) {
4287 4287
                         $index = $processed + $i;
4288 4288
                         $gd_post = array();
4289 4289
                         
4290 4290
                         if (isset($file[$index])) {$processed_actual++;
4291 4291
                             $row = $file[$index];
4292
-                            $row = array_map( 'trim', $row );
4292
+                            $row = array_map('trim', $row);
4293 4293
                             //$row = array_map( 'utf8_encode', $row );
4294
-                            $row = array_map( 'addslashes_gpc', $row );
4294
+                            $row = array_map('addslashes_gpc', $row);
4295 4295
                             
4296 4296
                             $post_id = '';
4297 4297
                             $post_title = '';
@@ -4328,80 +4328,80 @@  discard block
 block discarded – undo
4328 4328
                             $original_post_id = '';
4329 4329
                                                         
4330 4330
                             $c = 0;
4331
-                            foreach ($columns as $column ) {
4331
+                            foreach ($columns as $column) {
4332 4332
                                 $gd_post[$column] = $row[$c];
4333 4333
                                 
4334
-                                if ( $column == 'post_id' ) {
4334
+                                if ($column == 'post_id') {
4335 4335
                                     $post_id = $row[$c];
4336
-                                } else if ( $column == 'post_title' ) {
4336
+                                } else if ($column == 'post_title') {
4337 4337
                                     $post_title = sanitize_text_field($row[$c]);
4338
-                                } else if ( $column == 'post_author' ) {
4338
+                                } else if ($column == 'post_author') {
4339 4339
                                     $post_author = $row[$c];
4340
-                                } else if ( $column == 'post_content' ) {
4340
+                                } else if ($column == 'post_content') {
4341 4341
                                     $post_content = $row[$c];
4342
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4343
-                                    $post_category_arr = explode( ',', $row[$c] );
4344
-                                } else if ( $column == 'default_category' ) {
4342
+                                } else if ($column == 'post_category' && $row[$c] != '') {
4343
+                                    $post_category_arr = explode(',', $row[$c]);
4344
+                                } else if ($column == 'default_category') {
4345 4345
                                     $default_category = wp_kses_normalize_entities($row[$c]);
4346
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4347
-                                    $post_tags = explode( ',', $row[$c] );
4348
-                                } else if ( $column == 'post_type' ) {
4346
+                                } else if ($column == 'post_tags' && $row[$c] != '') {
4347
+                                    $post_tags = explode(',', $row[$c]);
4348
+                                } else if ($column == 'post_type') {
4349 4349
                                     $post_type = $row[$c];
4350
-                                } else if ( $column == 'post_status' ) {
4351
-                                    $post_status = sanitize_key( $row[$c] );
4352
-                                } else if ( $column == 'is_featured' ) {
4353
-                                    $is_featured = (int)$row[$c];
4354
-                                } else if ( $column == 'geodir_video' ) {
4350
+                                } else if ($column == 'post_status') {
4351
+                                    $post_status = sanitize_key($row[$c]);
4352
+                                } else if ($column == 'is_featured') {
4353
+                                    $is_featured = (int) $row[$c];
4354
+                                } else if ($column == 'geodir_video') {
4355 4355
                                     $geodir_video = $row[$c];
4356
-                                } else if ( $column == 'post_address' ) {
4356
+                                } else if ($column == 'post_address') {
4357 4357
                                     $post_address = $row[$c];
4358
-                                } else if ( $column == 'post_city' ) {
4358
+                                } else if ($column == 'post_city') {
4359 4359
                                     $post_city = $row[$c];
4360
-                                } else if ( $column == 'post_region' ) {
4360
+                                } else if ($column == 'post_region') {
4361 4361
                                     $post_region = $row[$c];
4362
-                                } else if ( $column == 'post_country' ) {
4362
+                                } else if ($column == 'post_country') {
4363 4363
                                     $post_country = $row[$c];
4364
-                                } else if ( $column == 'post_zip' ) {
4364
+                                } else if ($column == 'post_zip') {
4365 4365
                                     $post_zip = $row[$c];
4366
-                                } else if ( $column == 'post_latitude' ) {
4366
+                                } else if ($column == 'post_latitude') {
4367 4367
                                     $post_latitude = $row[$c];
4368
-                                } else if ( $column == 'post_longitude' ) {
4368
+                                } else if ($column == 'post_longitude') {
4369 4369
                                     $post_longitude = $row[$c];
4370
-                                } else if ( $column == 'post_neighbourhood' ) {
4370
+                                } else if ($column == 'post_neighbourhood') {
4371 4371
                                     $post_neighbourhood = $row[$c];
4372 4372
                                     unset($gd_post[$column]);
4373
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4373
+                                } else if ($column == 'neighbourhood_latitude') {
4374 4374
                                     $neighbourhood_latitude = $row[$c];
4375
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4375
+                                } else if ($column == 'neighbourhood_longitude') {
4376 4376
                                     $neighbourhood_longitude = $row[$c];
4377
-                                } else if ( $column == 'geodir_timing' ) {
4377
+                                } else if ($column == 'geodir_timing') {
4378 4378
                                     $geodir_timing = $row[$c];
4379
-                                } else if ( $column == 'geodir_contact' ) {
4379
+                                } else if ($column == 'geodir_contact') {
4380 4380
                                     $geodir_contact = $row[$c];
4381
-                                } else if ( $column == 'geodir_email' ) {
4381
+                                } else if ($column == 'geodir_email') {
4382 4382
                                     $geodir_email = $row[$c];
4383
-                                } else if ( $column == 'geodir_website' ) {
4383
+                                } else if ($column == 'geodir_website') {
4384 4384
                                     $geodir_website = $row[$c];
4385
-                                } else if ( $column == 'geodir_twitter' ) {
4385
+                                } else if ($column == 'geodir_twitter') {
4386 4386
                                     $geodir_twitter = $row[$c];
4387
-                                } else if ( $column == 'geodir_facebook' ) {
4387
+                                } else if ($column == 'geodir_facebook') {
4388 4388
                                     $geodir_facebook = $row[$c];
4389
-                                } else if ( $column == 'geodir_twitter' ) {
4389
+                                } else if ($column == 'geodir_twitter') {
4390 4390
                                     $geodir_twitter = $row[$c];
4391
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4391
+                                } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
4392 4392
                                     $post_images[] = $row[$c];
4393
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4394
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4395
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4393
+                                } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
4394
+                                    $expire_date = date_i18n('Y-m-d', strtotime($current_date . '+' . (int) $row[$c] . ' days'));
4395
+                                } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
4396 4396
                                     $row[$c] = str_replace('/', '-', $row[$c]);
4397
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4397
+                                    $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
4398 4398
                                 }
4399 4399
                                 // WPML
4400 4400
                                 if ($is_wpml) {
4401 4401
                                     if ($column == 'language') {
4402 4402
                                         $language = geodir_strtolower(trim($row[$c]));
4403 4403
                                     } else if ($column == 'original_post_id') {
4404
-                                        $original_post_id = (int)$row[$c];
4404
+                                        $original_post_id = (int) $row[$c];
4405 4405
                                     }
4406 4406
                                 }
4407 4407
                                 // WPML
@@ -4416,24 +4416,24 @@  discard block
 block discarded – undo
4416 4416
 
4417 4417
                             $gd_post['IMAGE'] = $post_images;
4418 4418
                             
4419
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4420
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4419
+                            $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
4420
+                            $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
4421 4421
                                                                                                                 
4422 4422
                             $valid = true;
4423 4423
                             
4424
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4424
+                            if ($post_title == '' || !in_array($post_type, $post_types)) {
4425 4425
                                 $invalid++;
4426 4426
                                 $valid = false;
4427 4427
                             }
4428 4428
                             
4429
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4430
-                            if ( $location_allowed ) {
4429
+                            $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
4430
+                            if ($location_allowed) {
4431 4431
                                 $location_result = geodir_get_default_location();
4432
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4432
+                                if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
4433 4433
                                     $invalid_addr++;
4434 4434
                                     $valid = false;
4435
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4436
-                                    if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4435
+                                } else if (!empty($location_result) && $location_result->location_id == 0) {
4436
+                                    if ((geodir_strtolower($post_city) != geodir_strtolower($location_result->city)) || (geodir_strtolower($post_region) != geodir_strtolower($location_result->region)) || (geodir_strtolower($post_country) != geodir_strtolower($location_result->country))) {
4437 4437
                                         $invalid_addr++;
4438 4438
                                         $valid = false;
4439 4439
                                     } else {
@@ -4444,7 +4444,7 @@  discard block
 block discarded – undo
4444 4444
                                 }
4445 4445
                             }
4446 4446
                             
4447
-                            if ( !$valid ) {
4447
+                            if (!$valid) {
4448 4448
                                 continue;
4449 4449
                             }
4450 4450
 
@@ -4457,29 +4457,29 @@  discard block
 block discarded – undo
4457 4457
 
4458 4458
                             $post_category = array();
4459 4459
                             $default_category_id = NULL;
4460
-                            if ( !empty( $post_category_arr ) ) {
4461
-                                foreach ( $post_category_arr as $value ) {
4462
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4460
+                            if (!empty($post_category_arr)) {
4461
+                                foreach ($post_category_arr as $value) {
4462
+                                    $category_name = wp_kses_normalize_entities(trim($value));
4463 4463
                                     
4464
-                                    if ( $category_name != '' ) {
4464
+                                    if ($category_name != '') {
4465 4465
                                         $term_category = array();
4466 4466
                                         
4467
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4467
+                                        if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
4468 4468
                                             $term_category = $term;
4469
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4469
+                                        } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
4470 4470
                                             $term_category = $term;
4471 4471
                                         } else {
4472 4472
                                             $term_data = array();
4473 4473
                                             $term_data['name'] = $category_name;
4474 4474
                                             $term_data['taxonomy'] = $cat_taxonomy;
4475 4475
                                             
4476
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4477
-                                            if ( $term_id ) {
4478
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4476
+                                            $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data);
4477
+                                            if ($term_id) {
4478
+                                                $term_category = get_term($term_id, $cat_taxonomy);
4479 4479
                                             }
4480 4480
                                         }
4481 4481
                                         
4482
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4482
+                                        if (!empty($term_category) && !is_wp_error($term_category)) {
4483 4483
                                             $post_category[] = intval($term_category->term_id);
4484 4484
                                             
4485 4485
                                             if ($category_name == $default_category) {
@@ -4500,28 +4500,28 @@  discard block
 block discarded – undo
4500 4500
                             $save_post['post_tags'] = $post_tags;
4501 4501
 
4502 4502
                             $saved_post_id = NULL;
4503
-                            if ( $import_choice == 'update' ) {
4504
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4503
+                            if ($import_choice == 'update') {
4504
+                                if ($post_id > 0 && get_post($post_id)) {
4505 4505
                                     $save_post['ID'] = $post_id;
4506 4506
                                     
4507
-                                    if ( wp_update_post( $save_post ) ) {
4507
+                                    if (wp_update_post($save_post)) {
4508 4508
                                         $saved_post_id = $post_id;
4509 4509
                                         $updated++;
4510 4510
                                     }
4511 4511
                                 } else {
4512
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
4512
+                                    if ($saved_post_id = wp_insert_post($save_post)) {
4513 4513
                                         $created++;
4514 4514
                                     }
4515 4515
                                 }
4516 4516
                                 
4517
-                                if ( !$saved_post_id > 0 ) {
4517
+                                if (!$saved_post_id > 0) {
4518 4518
                                     $invalid++;
4519 4519
                                 }
4520
-                            } else if ( $import_choice == 'skip' ) {
4521
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4520
+                            } else if ($import_choice == 'skip') {
4521
+                                if ($post_id > 0 && get_post($post_id)) {
4522 4522
                                     $skipped++;	
4523 4523
                                 } else {
4524
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
4524
+                                    if ($saved_post_id = wp_insert_post($save_post)) {
4525 4525
                                         $created++;	
4526 4526
                                     } else {
4527 4527
                                         $invalid++;
@@ -4531,19 +4531,19 @@  discard block
 block discarded – undo
4531 4531
                                 $invalid++;
4532 4532
                             }
4533 4533
 
4534
-                            if ( (int)$saved_post_id > 0 ) {
4534
+                            if ((int) $saved_post_id > 0) {
4535 4535
                                 // WPML
4536 4536
                                 if ($is_wpml && $original_post_id > 0 && $language != '') {
4537 4537
                                     $wpml_post_type = 'post_' . $post_type;
4538
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4538
+                                    $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type);
4539 4539
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4540 4540
 
4541
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4541
+                                    $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type);
4542 4542
                                     
4543
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4543
+                                    $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language);
4544 4544
                                 }
4545 4545
                                 // WPML
4546
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4546
+                                $gd_post_info = geodir_get_post_info($saved_post_id);
4547 4547
                                 
4548 4548
                                 $gd_post['post_id'] = $saved_post_id;
4549 4549
                                 $gd_post['ID'] = $saved_post_id;
@@ -4555,7 +4555,7 @@  discard block
 block discarded – undo
4555 4555
                                                     
4556 4556
                                 // post location
4557 4557
                                 $post_location_id = 0;
4558
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4558
+                                if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
4559 4559
                                     $gd_post['post_neighbourhood'] = '';
4560 4560
                                     
4561 4561
                                     $post_location_info = array(
@@ -4565,7 +4565,7 @@  discard block
 block discarded – undo
4565 4565
                                                                 'geo_lat' => $post_latitude,
4566 4566
                                                                 'geo_lng' => $post_longitude
4567 4567
                                                             );
4568
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4568
+                                    if ($location_id = (int) geodir_add_new_location($post_location_info)) {
4569 4569
                                         $post_location_id = $location_id;
4570 4570
                                     }
4571 4571
                                     
@@ -4603,14 +4603,14 @@  discard block
 block discarded – undo
4603 4603
                                 $gd_post['post_location_id'] = $post_location_id;
4604 4604
                                 
4605 4605
                                 // post package info
4606
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4606
+                                $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0;
4607 4607
                                 if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4608 4608
                                     $package_id = $gd_post_info->package_id;
4609 4609
                                 }
4610 4610
                                 
4611 4611
                                 $package_info = array();
4612 4612
                                 if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4613
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4613
+                                    $package_info = (array) geodir_get_package_info_by_id($package_id);
4614 4614
                                     
4615 4615
                                     if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4616 4616
                                         $package_info = array();
@@ -4618,18 +4618,18 @@  discard block
 block discarded – undo
4618 4618
                                 }
4619 4619
                                 
4620 4620
                                 if (empty($package_info)) {
4621
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4621
+                                    $package_info = (array) geodir_post_package_info(array(), '', $post_type);
4622 4622
                                 }
4623 4623
                                  
4624
-                                if (!empty($package_info))	 {
4624
+                                if (!empty($package_info)) {
4625 4625
                                     $package_id = $package_info['pid'];
4626 4626
                                     
4627 4627
                                     if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4628 4628
                                         $gd_post['expire_date'] = $expire_date;
4629 4629
                                     } else {
4630
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4631
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4632
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4630
+                                        if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
4631
+                                            $gd_post['alive_days'] = (int) $package_info['days'];
4632
+                                            $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date . '+' . (int) $package_info['days'] . ' days'));
4633 4633
                                         } else {
4634 4634
                                             $gd_post['expire_date'] = 'Never';
4635 4635
                                         }
@@ -4649,28 +4649,28 @@  discard block
 block discarded – undo
4649 4649
                                 }
4650 4650
 
4651 4651
                                 // Export franchise fields
4652
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4652
+                                $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
4653 4653
                                 if ($is_franchise_active) {
4654
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4654
+                                    if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
4655 4655
                                         $gd_franchise_lock = array();
4656 4656
                                         
4657
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4658
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4659
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4660
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4657
+                                        if (isset($gd_post['gd_franchise_lock'])) {
4658
+                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
4659
+                                            $gd_franchise_lock = trim($gd_franchise_lock);
4660
+                                            $gd_franchise_lock = explode(",", $gd_franchise_lock);
4661 4661
                                         }
4662 4662
                                         
4663
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4664
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4663
+                                        update_post_meta($saved_post_id, 'gd_is_franchise', 1);
4664
+                                        update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock);
4665 4665
                                     } else {
4666
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4667
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4666
+                                        if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
4667
+                                            geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']);
4668 4668
                                         }
4669 4669
                                     }
4670 4670
                                 }
4671 4671
                                 
4672 4672
                                 if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4673
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4673
+                                    $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
4674 4674
                                     if ($default_category_id) {
4675 4675
                                         $save_post['post_default_category'] = $default_category_id;
4676 4676
                                         $gd_post['default_category'] = $default_category_id;
@@ -4679,12 +4679,12 @@  discard block
 block discarded – undo
4679 4679
                                 }
4680 4680
                                 
4681 4681
                                 // Save post info
4682
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4682
+                                geodir_save_post_info($saved_post_id, $gd_post);
4683 4683
                                 // post taxonomies
4684
-                                if ( !empty( $save_post['post_category'] ) ) {
4685
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4684
+                                if (!empty($save_post['post_category'])) {
4685
+                                    wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy);
4686 4686
                                     
4687
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4687
+                                    $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : '';
4688 4688
                                     if ($default_category_id) {
4689 4689
                                         $post_default_category = $default_category_id;
4690 4690
                                     }
@@ -4698,15 +4698,15 @@  discard block
 block discarded – undo
4698 4698
                                     
4699 4699
                                     $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4700 4700
                                     
4701
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4701
+                                    geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str);
4702 4702
                                 }
4703 4703
 
4704
-                                if ( !empty( $save_post['post_tags'] ) ) {
4705
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4704
+                                if (!empty($save_post['post_tags'])) {
4705
+                                    wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy);
4706 4706
                                 }
4707 4707
 
4708 4708
                                 // Post images
4709
-                                if ( !empty( $post_images ) ) {
4709
+                                if (!empty($post_images)) {
4710 4710
                                     $post_images = array_unique($post_images);
4711 4711
                                     
4712 4712
                                     $old_post_images_arr = array();
@@ -4714,30 +4714,30 @@  discard block
 block discarded – undo
4714 4714
                                     
4715 4715
                                     $order = 1;
4716 4716
                                     
4717
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4717
+                                    $old_post_images = geodir_get_images($saved_post_id);
4718 4718
                                     if (!empty($old_post_images)) {
4719
-                                        foreach( $old_post_images as $old_post_image ) {
4719
+                                        foreach ($old_post_images as $old_post_image) {
4720 4720
                                             if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4721 4721
                                                 $old_post_images_arr[] = $old_post_image->file;
4722 4722
                                             }
4723 4723
                                         }
4724 4724
                                     }
4725 4725
                                     
4726
-                                    foreach ( $post_images as $post_image ) {
4727
-                                        $image_name = basename( $post_image );
4726
+                                    foreach ($post_images as $post_image) {
4727
+                                        $image_name = basename($post_image);
4728 4728
                                         $saved_post_images_arr[] = $image_name;
4729 4729
                                         
4730
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4730
+                                        if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
4731 4731
                                             continue; // Skip if image already exists.
4732 4732
                                         }
4733 4733
                                         
4734
-                                        $image_name_parts = explode( '.', $image_name );
4735
-                                        array_pop( $image_name_parts );
4736
-                                        $proper_image_name = implode( '.', $image_name_parts );
4734
+                                        $image_name_parts = explode('.', $image_name);
4735
+                                        array_pop($image_name_parts);
4736
+                                        $proper_image_name = implode('.', $image_name_parts);
4737 4737
                                         
4738
-                                        $arr_file_type = wp_check_filetype( $image_name );
4738
+                                        $arr_file_type = wp_check_filetype($image_name);
4739 4739
                                         
4740
-                                        if ( !empty( $arr_file_type ) ) {
4740
+                                        if (!empty($arr_file_type)) {
4741 4741
                                             $uploaded_file_type = $arr_file_type['type'];
4742 4742
                                             
4743 4743
                                             $attachment = array();
@@ -4750,46 +4750,46 @@  discard block
 block discarded – undo
4750 4750
                                             $attachment['is_featured'] = 0;
4751 4751
 
4752 4752
                                             $attachment_set = '';
4753
-                                            foreach ( $attachment as $key => $val ) {
4754
-                                                if ( $val != '' ) {
4753
+                                            foreach ($attachment as $key => $val) {
4754
+                                                if ($val != '') {
4755 4755
                                                     $attachment_set .= $key . " = '" . $val . "', ";
4756 4756
                                                 }
4757 4757
                                             }
4758
-                                            $attachment_set = trim( $attachment_set, ", " );
4758
+                                            $attachment_set = trim($attachment_set, ", ");
4759 4759
                                                                                         
4760 4760
                                             // Add new attachment
4761
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4761
+                                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
4762 4762
                                                                                         
4763 4763
                                             $order++;
4764 4764
                                         }
4765 4765
                                     }
4766 4766
 
4767
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4767
+                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
4768 4768
                                     // Remove previous attachment
4769
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4769
+                                    $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int) $saved_post_id . " " . $saved_post_images_sql);
4770 4770
                                     
4771
-                                    if ( !empty( $saved_post_images_arr ) ) {
4771
+                                    if (!empty($saved_post_images_arr)) {
4772 4772
                                         $menu_order = 1;
4773 4773
                                         
4774
-                                        foreach ( $saved_post_images_arr as $img_name ) {
4775
-                                            $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4774
+                                        foreach ($saved_post_images_arr as $img_name) {
4775
+                                            $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array($menu_order, $saved_post_id, '%/' . $img_name)));
4776 4776
                                             
4777
-                                            if( $menu_order == 1 ) {
4778
-                                                if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4779
-                                                    $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4777
+                                            if ($menu_order == 1) {
4778
+                                                if ($featured_image = $wpdb->get_var($wpdb->prepare("SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array($saved_post_id, '%/' . $img_name)))) {
4779
+                                                    $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array($featured_image, $saved_post_id)));
4780 4780
                                                 }
4781 4781
                                             }
4782 4782
                                             $menu_order++;
4783 4783
                                         }
4784 4784
                                     }
4785 4785
                                     
4786
-                                    if ( $order > 1 ) {
4786
+                                    if ($order > 1) {
4787 4787
                                         $images++;
4788 4788
                                     }
4789 4789
                                 }
4790 4790
 
4791 4791
                                 /** This action is documented in geodirectory-functions/post-functions.php */
4792
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4792
+                                do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
4793 4793
                                 
4794 4794
                                 if (isset($is_featured)) {
4795 4795
                                     geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
@@ -4809,10 +4809,10 @@  discard block
 block discarded – undo
4809 4809
                 }
4810 4810
 
4811 4811
                 //undo some stuff to make the import quicker
4812
-                wp_defer_term_counting( false );
4813
-                wp_defer_comment_counting( false );
4814
-                $wpdb->query( 'COMMIT;' );
4815
-                $wpdb->query( 'SET autocommit = 1;' );
4812
+                wp_defer_term_counting(false);
4813
+                wp_defer_comment_counting(false);
4814
+                $wpdb->query('COMMIT;');
4815
+                $wpdb->query('SET autocommit = 1;');
4816 4816
 
4817 4817
                 $json = array();
4818 4818
                 $json['processed'] = $processed_actual;
@@ -4823,9 +4823,9 @@  discard block
 block discarded – undo
4823 4823
                 $json['invalid_addr'] = $invalid_addr;
4824 4824
                 $json['images'] = $images;
4825 4825
                 
4826
-                wp_send_json( $json );
4826
+                wp_send_json($json);
4827 4827
                 exit;
4828
-            } else if ( $task == 'import_loc' ) {
4828
+            } else if ($task == 'import_loc') {
4829 4829
                 global $gd_post_types;
4830 4830
                 $gd_post_types = $post_types;
4831 4831
                 
@@ -4834,7 +4834,7 @@  discard block
 block discarded – undo
4834 4834
                     
4835 4835
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4836 4836
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4837
-                        wp_send_json( $json );
4837
+                        wp_send_json($json);
4838 4838
                     }
4839 4839
                     
4840 4840
                     for ($i = 1; $i <= $limit; $i++) {
@@ -4842,59 +4842,59 @@  discard block
 block discarded – undo
4842 4842
                         
4843 4843
                         if (isset($file[$index])) {
4844 4844
                             $row = $file[$index];
4845
-                            $row = array_map( 'trim', $row );
4845
+                            $row = array_map('trim', $row);
4846 4846
                             $data = array();
4847 4847
                             
4848
-                            foreach ($columns as $c => $column ) {
4848
+                            foreach ($columns as $c => $column) {
4849 4849
                                 if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
4850 4850
                                     $data[$column] = $row[$c];
4851 4851
                                 }
4852 4852
                             }
4853 4853
 
4854
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4854
+                            if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
4855 4855
                                 $invalid++;
4856 4856
                                 continue;
4857 4857
                             }
4858 4858
                             
4859 4859
                             $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4860 4860
                             
4861
-                            if ( $import_choice == 'update' ) {
4862
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4863
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4861
+                            if ($import_choice == 'update') {
4862
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4863
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4864 4864
                                         $updated++;
4865 4865
                                     } else {
4866 4866
                                         $invalid++;
4867 4867
                                     }
4868
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4869
-                                    $data['location_id'] = (int)$location->location_id;
4868
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4869
+                                    $data['location_id'] = (int) $location->location_id;
4870 4870
                                     
4871
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4872
-                                        $data['location_id'] = (int)$location->location_id;
4873
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4874
-                                        $data['location_id'] = (int)$location->location_id;
4875
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4876
-                                        $data['location_id'] = (int)$location->location_id;
4871
+                                    if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
4872
+                                        $data['location_id'] = (int) $location->location_id;
4873
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
4874
+                                        $data['location_id'] = (int) $location->location_id;
4875
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
4876
+                                        $data['location_id'] = (int) $location->location_id;
4877 4877
                                     }
4878 4878
                                     
4879
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4879
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4880 4880
                                         $updated++;
4881 4881
                                     } else {
4882 4882
                                         $invalid++;
4883 4883
                                     }
4884 4884
                                 } else {
4885
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4885
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4886 4886
                                         $created++;
4887 4887
                                     } else {
4888 4888
                                         $invalid++;
4889 4889
                                     }
4890 4890
                                 }
4891
-                            } elseif ( $import_choice == 'skip' ) {
4892
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4891
+                            } elseif ($import_choice == 'skip') {
4892
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4893 4893
                                     $skipped++;
4894
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4894
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4895 4895
                                     $skipped++;
4896 4896
                                 } else {
4897
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4897
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4898 4898
                                         $created++;
4899 4899
                                     } else {
4900 4900
                                         $invalid++;
@@ -4915,14 +4915,14 @@  discard block
 block discarded – undo
4915 4915
                 $json['invalid'] = $invalid;
4916 4916
                 $json['images'] = $images;
4917 4917
                 
4918
-                wp_send_json( $json );
4919
-            } else if ( $task == 'import_hood' ) {               
4918
+                wp_send_json($json);
4919
+            } else if ($task == 'import_hood') {               
4920 4920
                 if (!empty($file)) {
4921 4921
                     $columns = isset($file[0]) ? $file[0] : NULL;
4922 4922
                     
4923 4923
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4924 4924
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4925
-                        wp_send_json( $json );
4925
+                        wp_send_json($json);
4926 4926
                     }
4927 4927
                     
4928 4928
                     for ($i = 1; $i <= $limit; $i++) {
@@ -4930,7 +4930,7 @@  discard block
 block discarded – undo
4930 4930
                         
4931 4931
                         if (isset($file[$index])) {
4932 4932
                             $row = $file[$index];
4933
-                            $row = array_map( 'trim', $row );
4933
+                            $row = array_map('trim', $row);
4934 4934
                             $data = array();
4935 4935
                             
4936 4936
                             foreach ($columns as $c => $column) {
@@ -4945,8 +4945,8 @@  discard block
 block discarded – undo
4945 4945
                             }
4946 4946
                             
4947 4947
                             $location_info = array();
4948
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4949
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4948
+                            if (!empty($data['location_id']) && (int) $data['location_id'] > 0) {
4949
+                                $location_info = geodir_get_location_by_id('', (int) $data['location_id']);
4950 4950
                             } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4951 4951
                                 $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4952 4952
                             }
@@ -4967,9 +4967,9 @@  discard block
 block discarded – undo
4967 4967
                             $hood_data['hood_longitude'] = $data['longitude'];
4968 4968
                             $hood_data['hood_location_id'] = $location_id;
4969 4969
                                     
4970
-                            if ( $import_choice == 'update' ) {
4971
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4972
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4970
+                            if ($import_choice == 'update') {
4971
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
4972
+                                    $hood_data['hood_id'] = (int) $data['neighbourhood_id'];
4973 4973
                                     
4974 4974
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4975 4975
                                         $updated++;
@@ -4977,7 +4977,7 @@  discard block
 block discarded – undo
4977 4977
                                         $invalid++;
4978 4978
                                     }
4979 4979
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4980
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4980
+                                    $hood_data['hood_id'] = (int) $neighbourhood->hood_id;
4981 4981
                                     
4982 4982
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4983 4983
                                         $updated++;
@@ -4991,8 +4991,8 @@  discard block
 block discarded – undo
4991 4991
                                         $invalid++;
4992 4992
                                     }
4993 4993
                                 }
4994
-                            } elseif ( $import_choice == 'skip' ) {
4995
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4994
+                            } elseif ($import_choice == 'skip') {
4995
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
4996 4996
                                     $skipped++;
4997 4997
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4998 4998
                                     $skipped++;
@@ -5019,7 +5019,7 @@  discard block
 block discarded – undo
5019 5019
                 $json['invalid'] = $invalid;
5020 5020
                 $json['images'] = $images;
5021 5021
                 
5022
-                wp_send_json( $json );
5022
+                wp_send_json($json);
5023 5023
             }
5024 5024
         }
5025 5025
         break;
@@ -5063,29 +5063,29 @@  discard block
 block discarded – undo
5063 5063
  * }
5064 5064
  * @return int|bool Term id when success, false when fail.
5065 5065
  */
5066
-function geodir_imex_insert_term( $taxonomy, $term_data ) {
5067
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5066
+function geodir_imex_insert_term($taxonomy, $term_data) {
5067
+	if (empty($taxonomy) || empty($term_data)) {
5068 5068
 		return false;
5069 5069
 	}
5070 5070
 	
5071
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
5071
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
5072 5072
 	$args = array();
5073
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5074
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5075
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5073
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5074
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5075
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5076 5076
 	
5077
-	if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
5078
-		$term_args = array_merge( $term_data, $args );
5079
-		$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5080
-		$term_args = wp_parse_args( $term_args, $defaults );
5081
-		$term_args = sanitize_term( $term_args, $taxonomy, 'db' );
5082
-		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5077
+	if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
5078
+		$term_args = array_merge($term_data, $args);
5079
+		$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5080
+		$term_args = wp_parse_args($term_args, $defaults);
5081
+		$term_args = sanitize_term($term_args, $taxonomy, 'db');
5082
+		$args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args);
5083 5083
 	}
5084 5084
 	
5085
-    if( !empty( $term ) ) {
5086
-		$result = wp_insert_term( $term, $taxonomy, $args );
5087
-        if( !is_wp_error( $result ) ) {
5088
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5085
+    if (!empty($term)) {
5086
+		$result = wp_insert_term($term, $taxonomy, $args);
5087
+        if (!is_wp_error($result)) {
5088
+            return $term_id = isset($result['term_id']) ? $result['term_id'] : 0;
5089 5089
         }
5090 5090
     }
5091 5091
 	
@@ -5115,37 +5115,37 @@  discard block
 block discarded – undo
5115 5115
  * }
5116 5116
  * @return int|bool Term id when success, false when fail.
5117 5117
  */
5118
-function geodir_imex_update_term( $taxonomy, $term_data ) {
5119
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5118
+function geodir_imex_update_term($taxonomy, $term_data) {
5119
+	if (empty($taxonomy) || empty($term_data)) {
5120 5120
 		return false;
5121 5121
 	}
5122 5122
 	
5123
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
5124
-	$term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0;
5123
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
5124
+	$term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0;
5125 5125
 	
5126 5126
 	$args = array();
5127
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5128
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5129
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5127
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5128
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5129
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5130 5130
 	
5131
-	if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
5131
+	if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
5132 5132
 		$term_data['term_id'] = $term_info['term_id'];
5133 5133
 		
5134
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5134
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5135 5135
 		
5136
-		if( !is_wp_error( $result ) ) {
5137
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5136
+		if (!is_wp_error($result)) {
5137
+            return $term_id = isset($result['term_id']) ? $result['term_id'] : 0;
5138 5138
         }
5139
-	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5139
+	} else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
5140 5140
 		$term_data['term_id'] = $term_info['term_id'];
5141 5141
 		
5142
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5142
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5143 5143
 		
5144
-		if( !is_wp_error( $result ) ) {
5145
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5144
+		if (!is_wp_error($result)) {
5145
+            return $term_id = isset($result['term_id']) ? $result['term_id'] : 0;
5146 5146
         }
5147 5147
 	} else {
5148
-		return geodir_imex_insert_term( $taxonomy, $term_data );
5148
+		return geodir_imex_insert_term($taxonomy, $term_data);
5149 5149
 	}
5150 5150
 	
5151 5151
 	return false;
@@ -5160,9 +5160,9 @@  discard block
 block discarded – undo
5160 5160
  * @param string $post_type Post type.
5161 5161
  * @return int Posts count.
5162 5162
  */
5163
-function geodir_get_posts_count( $post_type ) {
5164
-	$posts_count = wp_count_posts( $post_type );
5165
-	$posts_count = array_sum( (array)$posts_count );
5163
+function geodir_get_posts_count($post_type) {
5164
+	$posts_count = wp_count_posts($post_type);
5165
+	$posts_count = array_sum((array) $posts_count);
5166 5166
 	
5167 5167
 	/**
5168 5168
 	 * Modify returned post counts for the current post type.
@@ -5173,7 +5173,7 @@  discard block
 block discarded – undo
5173 5173
 	 * @param int $posts_count Post counts.
5174 5174
 	 * @param string $post_type Post type.
5175 5175
 	 */
5176
-	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );	 
5176
+	$posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);	 
5177 5177
 	
5178 5178
 	return $posts_count;
5179 5179
 }
@@ -5191,8 +5191,8 @@  discard block
 block discarded – undo
5191 5191
  * @param string $post_type Post type.
5192 5192
  * @return int Posts count.
5193 5193
  */
5194
-function geodir_imex_count_events( $posts_count, $post_type ) {
5195
-	if ( $post_type == 'gd_event' ) {
5194
+function geodir_imex_count_events($posts_count, $post_type) {
5195
+	if ($post_type == 'gd_event') {
5196 5196
 		global $wpdb, $plugin_prefix;
5197 5197
 		
5198 5198
 		$table = $plugin_prefix . $post_type . '_detail';
@@ -5200,7 +5200,7 @@  discard block
 block discarded – undo
5200 5200
 
5201 5201
 		$query = "SELECT COUNT({$wpdb->posts}.ID) AS total FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s";
5202 5202
 		
5203
-		$posts_count = (int)$wpdb->get_var( $wpdb->prepare( $query, $post_type ) );
5203
+		$posts_count = (int) $wpdb->get_var($wpdb->prepare($query, $post_type));
5204 5204
 	}
5205 5205
 	
5206 5206
 	return $posts_count;
@@ -5222,17 +5222,17 @@  discard block
 block discarded – undo
5222 5222
  * @param int $page_no Page number. Default 0.
5223 5223
  * @return array Array of posts data.
5224 5224
  */
5225
-function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {	
5225
+function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {	
5226 5226
 	global $wp_filesystem;
5227 5227
 
5228
-	$posts = geodir_get_export_posts( $post_type, $per_page, $page_no );
5228
+	$posts = geodir_get_export_posts($post_type, $per_page, $page_no);
5229 5229
 
5230 5230
 	$csv_rows = array();
5231 5231
 	
5232
-	if ( !empty( $posts ) ) {
5233
-		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5232
+	if (!empty($posts)) {
5233
+		$is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
5234 5234
         $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5235
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5235
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
5236 5236
         $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5237 5237
 		
5238 5238
 		$csv_row = array();
@@ -5244,7 +5244,7 @@  discard block
 block discarded – undo
5244 5244
 		$csv_row[] = 'default_category';
5245 5245
 		$csv_row[] = 'post_tags';
5246 5246
 		$csv_row[] = 'post_type';
5247
-		if ( $post_type == 'gd_event' ) {
5247
+		if ($post_type == 'gd_event') {
5248 5248
 			$csv_row[] = 'event_date';
5249 5249
 			$csv_row[] = 'event_enddate';
5250 5250
 			$csv_row[] = 'starttime';
@@ -5298,15 +5298,15 @@  discard block
 block discarded – undo
5298 5298
 		}
5299 5299
 		// WPML
5300 5300
 
5301
-		$custom_fields = geodir_imex_get_custom_fields( $post_type );
5302
-		if ( !empty( $custom_fields ) ) {
5303
-			foreach ( $custom_fields as $custom_field ) {
5301
+		$custom_fields = geodir_imex_get_custom_fields($post_type);
5302
+		if (!empty($custom_fields)) {
5303
+			foreach ($custom_fields as $custom_field) {
5304 5304
 				$csv_row[] = $custom_field->htmlvar_name;
5305 5305
 			}
5306 5306
 		}
5307 5307
 
5308 5308
 		// Export franchise fields
5309
-		$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5309
+		$is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
5310 5310
 		if ($is_franchise_active) {
5311 5311
 			$csv_row[] = 'gd_is_franchise';
5312 5312
 			$csv_row[] = 'gd_franchise_lock';
@@ -5316,12 +5316,12 @@  discard block
 block discarded – undo
5316 5316
 		$csv_rows[] = $csv_row;
5317 5317
 
5318 5318
 		$images_count = 5;
5319
-        $xx=0;
5320
-		foreach ( $posts as $post ) {$xx++;
5319
+        $xx = 0;
5320
+		foreach ($posts as $post) {$xx++;
5321 5321
 			$post_id = $post['ID'];
5322 5322
 			
5323
-			$gd_post_info = geodir_get_post_info( $post_id );
5324
-			$post_info = (array)$gd_post_info;
5323
+			$gd_post_info = geodir_get_post_info($post_id);
5324
+			$post_info = (array) $gd_post_info;
5325 5325
 						
5326 5326
 			$taxonomy_category = $post_type . 'category';
5327 5327
 			$taxonomy_tags = $post_type . '_tags';
@@ -5330,14 +5330,14 @@  discard block
 block discarded – undo
5330 5330
 			$default_category_id = $gd_post_info->default_category;
5331 5331
 			$default_category = '';
5332 5332
 			$post_tags = '';
5333
-			$terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) );
5333
+			$terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags));
5334 5334
 			
5335
-			if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
5335
+			if (!empty($terms) && !is_wp_error($terms)) {
5336 5336
 				$post_category = array();
5337 5337
 				$post_tags = array();
5338 5338
 			
5339
-				foreach ( $terms as $term ) {
5340
-					if ( $term->taxonomy == $taxonomy_category ) {
5339
+				foreach ($terms as $term) {
5340
+					if ($term->taxonomy == $taxonomy_category) {
5341 5341
 						$post_category[] = $term->name;
5342 5342
 						
5343 5343
 						if ($default_category_id == $term->term_id) {
@@ -5345,7 +5345,7 @@  discard block
 block discarded – undo
5345 5345
 						}
5346 5346
 					}
5347 5347
 					
5348
-					if ( $term->taxonomy == $taxonomy_tags ) {
5348
+					if ($term->taxonomy == $taxonomy_tags) {
5349 5349
 						$post_tags[] = $term->name;
5350 5350
 					}
5351 5351
 				}
@@ -5353,8 +5353,8 @@  discard block
 block discarded – undo
5353 5353
 				if (empty($default_category) && !empty($post_category)) {
5354 5354
 					$default_category = $post_category[0]; // Set first one as default category.
5355 5355
 				}
5356
-				$post_category = !empty( $post_category ) ? implode( ',', $post_category ) : '';
5357
-				$post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : '';
5356
+				$post_category = !empty($post_category) ? implode(',', $post_category) : '';
5357
+				$post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
5358 5358
 			}
5359 5359
 
5360 5360
 			// Franchise data
@@ -5362,42 +5362,42 @@  discard block
 block discarded – undo
5362 5362
 			$franchise_info = array();
5363 5363
 			$locked_fields = array();
5364 5364
 			
5365
-			if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
5365
+			if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
5366 5366
 				$franchise_id = $post_info['franchise'];
5367 5367
 				$gd_franchise_info = geodir_get_post_info($franchise_id);
5368 5368
 
5369 5369
 				if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
5370
-					$franchise_info = (array)$gd_franchise_info;
5370
+					$franchise_info = (array) $gd_franchise_info;
5371 5371
 					$locked_fields = geodir_franchise_get_locked_fields($franchise_id, true);
5372 5372
 					
5373 5373
 					if (!empty($locked_fields)) {
5374
-						foreach( $locked_fields as $locked_field) {
5374
+						foreach ($locked_fields as $locked_field) {
5375 5375
 							if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
5376 5376
 								$post_info[$locked_field] = $franchise_info[$locked_field];
5377 5377
 							}
5378 5378
 							
5379 5379
 							if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
5380
-								$franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) );
5380
+								$franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags));
5381 5381
 			
5382
-								if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
5382
+								if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
5383 5383
 									$franchise_post_category = array();
5384 5384
 									$franchise_post_tags = array();
5385 5385
 								
5386
-									foreach ( $franchise_terms as $franchise_term ) {
5387
-										if ( $franchise_term->taxonomy == $taxonomy_category ) {
5386
+									foreach ($franchise_terms as $franchise_term) {
5387
+										if ($franchise_term->taxonomy == $taxonomy_category) {
5388 5388
 											$franchise_post_category[] = $franchise_term->name;
5389 5389
 										}
5390 5390
 										
5391
-										if ( $franchise_term->taxonomy == $taxonomy_tags ) {
5391
+										if ($franchise_term->taxonomy == $taxonomy_tags) {
5392 5392
 											$franchise_post_tags[] = $franchise_term->name;
5393 5393
 										}
5394 5394
 									}
5395 5395
 									
5396 5396
 									if (in_array($taxonomy_category, $locked_fields)) {
5397
-										$post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : '';
5397
+										$post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
5398 5398
 									}
5399 5399
 									if (in_array('post_tags', $locked_fields)) {
5400
-										$post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : '';
5400
+										$post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
5401 5401
 									}
5402 5402
 								}
5403 5403
 							}
@@ -5406,18 +5406,18 @@  discard block
 block discarded – undo
5406 5406
 				}
5407 5407
 			}
5408 5408
 						
5409
-			$post_images = geodir_get_images( $post_id );
5409
+			$post_images = geodir_get_images($post_id);
5410 5410
 			$current_images = array();
5411
-			if ( !empty( $post_images ) ) {
5412
-				foreach ( $post_images as $post_image ) {
5413
-					$post_image = (array)$post_image;
5414
-					$image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : '';
5415
-					if ( $image ) {
5411
+			if (!empty($post_images)) {
5412
+				foreach ($post_images as $post_image) {
5413
+					$post_image = (array) $post_image;
5414
+					$image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : '';
5415
+					if ($image) {
5416 5416
 						$current_images[] = $image;
5417 5417
 					}
5418 5418
 				}
5419 5419
 				
5420
-				$images_count = max( $images_count, count( $current_images ) );
5420
+				$images_count = max($images_count, count($current_images));
5421 5421
 			}
5422 5422
 
5423 5423
 			$csv_row = array();
@@ -5429,7 +5429,7 @@  discard block
 block discarded – undo
5429 5429
 			$csv_row[] = $default_category; // default_category
5430 5430
 			$csv_row[] = $post_tags; // post_tags
5431 5431
 			$csv_row[] = $post_type; // post_type
5432
-			if ( $post_type == 'gd_event' ) {
5432
+			if ($post_type == 'gd_event') {
5433 5433
 				$event_data = geodir_imex_get_event_data($post, $gd_post_info);
5434 5434
 				$csv_row[] = $event_data['event_date']; // event_date
5435 5435
 				$csv_row[] = $event_data['event_enddate']; // enddate
@@ -5450,9 +5450,9 @@  discard block
 block discarded – undo
5450 5450
 				$csv_row[] = $event_data['recurring_end_date']; // repeat_end
5451 5451
 			}
5452 5452
 			$csv_row[] = $post_info['post_status']; // post_status
5453
-			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5453
+			$csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5454 5454
 			if ($is_payment_plugin) {
5455
-				$csv_row[] = (int)$post_info['package_id']; // package_id
5455
+				$csv_row[] = (int) $post_info['package_id']; // package_id
5456 5456
 				$csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
5457 5457
 			}
5458 5458
 			$csv_row[] = $post_info['geodir_video']; // geodir_video
@@ -5488,14 +5488,14 @@  discard block
 block discarded – undo
5488 5488
 			$csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers
5489 5489
 			// WPML
5490 5490
 			if ($is_wpml) {
5491
-				$csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type );
5492
-				$csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type );
5491
+				$csv_row[] = geodir_get_language_for_element($post_id, 'post_' . $post_type);
5492
+				$csv_row[] = geodir_imex_original_post_id($post_id, 'post_' . $post_type);
5493 5493
 			}
5494 5494
 			// WPML
5495 5495
 			
5496
-			if ( !empty( $custom_fields ) ) {
5497
-				foreach ( $custom_fields as $custom_field ) {
5498
-					$csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : '';
5496
+			if (!empty($custom_fields)) {
5497
+				foreach ($custom_fields as $custom_field) {
5498
+					$csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : '';
5499 5499
 				}
5500 5500
 			}
5501 5501
 			
@@ -5506,26 +5506,26 @@  discard block
 block discarded – undo
5506 5506
 				$franchise = '';
5507 5507
 					
5508 5508
 				if (geodir_franchise_pkg_is_active($gd_post_info)) {
5509
-					$gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true );
5510
-					$locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : '';
5509
+					$gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true);
5510
+					$locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : '';
5511 5511
 					$locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
5512
-					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id
5512
+					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id
5513 5513
 				}
5514 5514
 				
5515
-				$csv_row[] = (int)$gd_is_franchise; // gd_is_franchise
5515
+				$csv_row[] = (int) $gd_is_franchise; // gd_is_franchise
5516 5516
 				$csv_row[] = $locaked_fields; // gd_franchise_lock fields
5517
-				$csv_row[] = (int)$franchise; // franchise id
5517
+				$csv_row[] = (int) $franchise; // franchise id
5518 5518
 			}
5519 5519
 			
5520
-			for ( $c = 0; $c < $images_count; $c++ ) {
5521
-				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
5520
+			for ($c = 0; $c < $images_count; $c++) {
5521
+				$csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE
5522 5522
 			}
5523 5523
 			
5524 5524
 			$csv_rows[] = $csv_row;
5525 5525
 
5526 5526
 		}
5527 5527
 
5528
-		for ( $c = 0; $c < $images_count; $c++ ) {
5528
+		for ($c = 0; $c < $images_count; $c++) {
5529 5529
 			$csv_rows[0][] = 'IMAGE';
5530 5530
 		}
5531 5531
 	}
@@ -5547,19 +5547,19 @@  discard block
 block discarded – undo
5547 5547
  * @param int $page_no Page number. Default 0.
5548 5548
  * @return array Array of posts data.
5549 5549
  */
5550
-function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5550
+function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
5551 5551
 	global $wpdb, $plugin_prefix;
5552 5552
 
5553
-	if ( ! post_type_exists( $post_type ) )
5553
+	if (!post_type_exists($post_type))
5554 5554
 		return new stdClass;
5555 5555
 		
5556 5556
 	$table = $plugin_prefix . $post_type . '_detail';
5557 5557
 	
5558 5558
 	$limit = '';
5559
-	if ( $per_page > 0 && $page_no > 0 ) {
5560
-		$offset = ( $page_no - 1 ) * $per_page;
5559
+	if ($per_page > 0 && $page_no > 0) {
5560
+		$offset = ($page_no - 1) * $per_page;
5561 5561
 		
5562
-		if ( $offset > 0 ) {
5562
+		if ($offset > 0) {
5563 5563
 			$limit = " LIMIT " . $offset . "," . $per_page;
5564 5564
 		} else {
5565 5565
 			$limit = " LIMIT " . $per_page;
@@ -5576,9 +5576,9 @@  discard block
 block discarded – undo
5576 5576
 	 * @param int $query The SQL query.
5577 5577
 	 * @param string $post_type Post type.
5578 5578
 	 */
5579
-	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5579
+	$query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
5580 5580
 
5581
-	$results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5581
+	$results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A);
5582 5582
 
5583 5583
 	/**
5584 5584
 	 * Modify returned post results for the current post type.
@@ -5589,7 +5589,7 @@  discard block
 block discarded – undo
5589 5589
 	 * @param object $results An object containing all post ids.
5590 5590
 	 * @param string $post_type Post type.
5591 5591
 	 */
5592
-	return apply_filters( 'geodir_export_posts', $results, $post_type );
5592
+	return apply_filters('geodir_export_posts', $results, $post_type);
5593 5593
 }
5594 5594
 
5595 5595
 /**
@@ -5606,8 +5606,8 @@  discard block
 block discarded – undo
5606 5606
  * @param string $post_type Post type.
5607 5607
  * @return string The SQL query.
5608 5608
  */
5609
-function geodir_imex_get_events_query( $query, $post_type ) {
5610
-	if ( $post_type == 'gd_event' ) {
5609
+function geodir_imex_get_events_query($query, $post_type) {
5610
+	if ($post_type == 'gd_event') {
5611 5611
 		global $wpdb, $plugin_prefix;
5612 5612
 		
5613 5613
 		$table = $plugin_prefix . $post_type . '_detail';
@@ -5628,15 +5628,15 @@  discard block
 block discarded – undo
5628 5628
  * @param  string $post_type Post type.
5629 5629
  * @return int Total terms count.
5630 5630
  */
5631
-function geodir_get_terms_count( $post_type ) {
5632
-	$args = array( 'hide_empty' => 0 );
5631
+function geodir_get_terms_count($post_type) {
5632
+	$args = array('hide_empty' => 0);
5633 5633
 	
5634
-	remove_all_filters( 'get_terms' );
5634
+	remove_all_filters('get_terms');
5635 5635
 	
5636 5636
 	$taxonomy = $post_type . 'category';
5637 5637
 
5638
-	$count_terms = wp_count_terms( $taxonomy, $args );
5639
-	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5638
+	$count_terms = wp_count_terms($taxonomy, $args);
5639
+	$count_terms = !is_wp_error($count_terms) ? $count_terms : 0;
5640 5640
 	 
5641 5641
 	return $count_terms;
5642 5642
 }
@@ -5653,23 +5653,23 @@  discard block
 block discarded – undo
5653 5653
  * @param int $page_no Page number. Default 0.
5654 5654
  * @return array Array of terms data.
5655 5655
  */
5656
-function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
5657
-	$args = array( 'hide_empty' => 0, 'orderby' => 'id' );
5656
+function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
5657
+	$args = array('hide_empty' => 0, 'orderby' => 'id');
5658 5658
 	
5659
-	remove_all_filters( 'get_terms' );
5659
+	remove_all_filters('get_terms');
5660 5660
 	
5661 5661
 	$taxonomy = $post_type . 'category';
5662 5662
 	
5663
-	if ( $per_page > 0 && $page_no > 0 ) {
5664
-		$args['offset'] = ( $page_no - 1 ) * $per_page;
5663
+	if ($per_page > 0 && $page_no > 0) {
5664
+		$args['offset'] = ($page_no - 1) * $per_page;
5665 5665
 		$args['number'] = $per_page;
5666 5666
 	}
5667 5667
 	
5668
-	$terms = get_terms( $taxonomy, $args );
5668
+	$terms = get_terms($taxonomy, $args);
5669 5669
 
5670 5670
 	$csv_rows = array();
5671 5671
 	
5672
-	if ( !empty( $terms ) ) {
5672
+	if (!empty($terms)) {
5673 5673
 		$csv_row = array();
5674 5674
 		$csv_row[] = 'cat_id';
5675 5675
 		$csv_row[] = 'cat_name';
@@ -5690,16 +5690,16 @@  discard block
 block discarded – undo
5690 5690
 		
5691 5691
 		$csv_rows[] = $csv_row;
5692 5692
 		
5693
-		foreach ( $terms as $term ) {			
5694
-			$cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type );
5695
-			$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5693
+		foreach ($terms as $term) {			
5694
+			$cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type);
5695
+			$cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
5696 5696
 			
5697
-			$cat_image = geodir_get_default_catimage( $term->term_id, $post_type );
5698
-			$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; 
5697
+			$cat_image = geodir_get_default_catimage($term->term_id, $post_type);
5698
+			$cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; 
5699 5699
 			
5700 5700
 			$cat_parent = '';
5701
-			if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
5702
-				$parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy );
5701
+			if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
5702
+				$parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
5703 5703
 				$cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : '';
5704 5704
 			}
5705 5705
 			
@@ -5709,14 +5709,14 @@  discard block
 block discarded – undo
5709 5709
 			$csv_row[] = $term->slug;
5710 5710
 			$csv_row[] = $post_type;
5711 5711
 			$csv_row[] = $cat_parent;
5712
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5712
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type);
5713 5713
 			$csv_row[] = $term->description;
5714
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type );
5714
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type);
5715 5715
 			$csv_row[] = $cat_image;
5716 5716
 			$csv_row[] = $cat_icon;
5717 5717
 			// WPML
5718 5718
 			if ($is_wpml) {
5719
-				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5719
+				$csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_' . $taxonomy);
5720 5720
 			}
5721 5721
 			// WPML
5722 5722
 			
@@ -5735,7 +5735,7 @@  discard block
 block discarded – undo
5735 5735
  * @param  bool $relative True for relative path & False for absolute path.
5736 5736
  * @return string Path to the cache directory.
5737 5737
  */
5738
-function geodir_path_import_export( $relative = true ) {
5738
+function geodir_path_import_export($relative = true) {
5739 5739
 	$upload_dir = wp_upload_dir();
5740 5740
 	
5741 5741
 	return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache';
@@ -5754,8 +5754,8 @@  discard block
 block discarded – undo
5754 5754
  * @param  bool $clear If true then it overwrite data otherwise add rows at the end of file.
5755 5755
  * @return bool true if success otherwise false.
5756 5756
  */
5757
-function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
5758
-	if ( empty( $csv_data ) ) {
5757
+function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
5758
+	if (empty($csv_data)) {
5759 5759
 		return false;
5760 5760
 	}
5761 5761
 	
@@ -5763,17 +5763,17 @@  discard block
 block discarded – undo
5763 5763
 	
5764 5764
 	$mode = $clear ? 'w+' : 'a+';
5765 5765
 	
5766
-	if ( function_exists( 'fputcsv' ) ) {
5767
-		$file = fopen( $file_path, $mode );
5768
-		foreach( $csv_data as $csv_row ) {
5766
+	if (function_exists('fputcsv')) {
5767
+		$file = fopen($file_path, $mode);
5768
+		foreach ($csv_data as $csv_row) {
5769 5769
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5770
-			$write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' );
5770
+			$write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"');
5771 5771
 		}
5772
-		fclose( $file );
5772
+		fclose($file);
5773 5773
 	} else {
5774
-		foreach( $csv_data as $csv_row ) {
5774
+		foreach ($csv_data as $csv_row) {
5775 5775
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5776
-			$wp_filesystem->put_contents( $file_path, $csv_row );
5776
+			$wp_filesystem->put_contents($file_path, $csv_row);
5777 5777
 		}
5778 5778
 	}
5779 5779
 		
@@ -5791,14 +5791,14 @@  discard block
 block discarded – undo
5791 5791
  * @param  string $file Full path to file.
5792 5792
  * @return int No of file rows.
5793 5793
  */
5794
-function geodir_import_export_line_count( $file ) {
5794
+function geodir_import_export_line_count($file) {
5795 5795
 	global $wp_filesystem;
5796 5796
 	
5797
-	if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
5798
-		$contents = $wp_filesystem->get_contents_array( $file );
5797
+	if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
5798
+		$contents = $wp_filesystem->get_contents_array($file);
5799 5799
 		
5800
-		if ( !empty( $contents ) && is_array( $contents ) ) {
5801
-			return count( $contents ) - 1;
5800
+		if (!empty($contents) && is_array($contents)) {
5801
+			return count($contents) - 1;
5802 5802
 		}
5803 5803
 	}
5804 5804
 	
@@ -5815,11 +5815,11 @@  discard block
 block discarded – undo
5815 5815
  * @param string $post_type The post type.
5816 5816
  * @return object Queried object.
5817 5817
  */
5818
-function geodir_imex_get_custom_fields( $post_type ) {
5818
+function geodir_imex_get_custom_fields($post_type) {
5819 5819
 	global $wpdb;
5820 5820
 	 
5821
-	$sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
5822
-	$rows = $wpdb->get_results( $sql );
5821
+	$sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array($post_type));
5822
+	$rows = $wpdb->get_results($sql);
5823 5823
 	 
5824 5824
 	return $rows;
5825 5825
 }
@@ -5901,9 +5901,9 @@  discard block
 block discarded – undo
5901 5901
 	$post_table = $plugin_prefix . $post_type . '_detail';
5902 5902
 	
5903 5903
 	$query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
5904
-	$data = (array)$wpdb->get_row($query);
5904
+	$data = (array) $wpdb->get_row($query);
5905 5905
 	
5906
-	if ( !empty( $data ) ) {
5906
+	if (!empty($data)) {
5907 5907
 		$data['post_id'] = $tr_post_id;
5908 5908
 		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
5909 5909
 		
@@ -5931,7 +5931,7 @@  discard block
 block discarded – undo
5931 5931
 	global $sitepress, $wpdb;
5932 5932
 	$post_type = get_post_type($master_post_id);
5933 5933
 	
5934
-	remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
5934
+	remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
5935 5935
 
5936 5936
 	$taxonomies = get_object_taxonomies($post_type);
5937 5937
 	foreach ($taxonomies as $taxonomy) {
@@ -5940,9 +5940,9 @@  discard block
 block discarded – undo
5940 5940
 		
5941 5941
 		if ($terms) {
5942 5942
 			foreach ($terms as $term) {
5943
-				$tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
5943
+				$tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
5944 5944
 				
5945
-				if (!is_null($tr_id)){
5945
+				if (!is_null($tr_id)) {
5946 5946
 					// not using get_term - unfiltered get_term
5947 5947
 					$translated_term = $wpdb->get_row($wpdb->prepare("
5948 5948
 						SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
@@ -5951,8 +5951,8 @@  discard block
 block discarded – undo
5951 5951
 				}
5952 5952
 			}
5953 5953
 
5954
-			if (!is_taxonomy_hierarchical($taxonomy)){
5955
-				$terms_array = array_unique( array_map( 'intval', $terms_array ) );
5954
+			if (!is_taxonomy_hierarchical($taxonomy)) {
5955
+				$terms_array = array_unique(array_map('intval', $terms_array));
5956 5956
 			}
5957 5957
 
5958 5958
 			wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
@@ -5985,9 +5985,9 @@  discard block
 block discarded – undo
5985 5985
 	$query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
5986 5986
 	$post_images = $wpdb->get_results($query);
5987 5987
 	
5988
-	if ( !empty( $post_images ) ) {
5989
-		foreach ( $post_images as $post_image) {
5990
-			$image_data = (array)$post_image;
5988
+	if (!empty($post_images)) {
5989
+		foreach ($post_images as $post_image) {
5990
+			$image_data = (array) $post_image;
5991 5991
 			unset($image_data['ID']);
5992 5992
 			$image_data['post_id'] = $tr_post_id;
5993 5993
 			
@@ -6013,10 +6013,10 @@  discard block
 block discarded – undo
6013 6013
  * @return array Event data array.
6014 6014
  */
6015 6015
 function geodir_imex_get_event_data($post, $gd_post_info) {
6016
-	$event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : '';
6016
+	$event_date = isset($post['event_date']) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($post['event_date'])) : '';
6017 6017
 	$event_enddate = $event_date;
6018
-	$starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : '';
6019
-	$endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : '';
6018
+	$starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
6019
+	$endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
6020 6020
 	
6021 6021
 	$is_recurring_event = '';
6022 6022
 	$event_duration_days = '';
@@ -6034,15 +6034,15 @@  discard block
 block discarded – undo
6034 6034
 		
6035 6035
 	$recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array();
6036 6036
 	if (!empty($recurring_data)) {
6037
-		$event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date;
6038
-		$event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date;
6039
-		$starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime;
6040
-		$endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime;
6037
+		$event_date = isset($recurring_data['event_start']) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_start'])) : $event_date;
6038
+		$event_enddate = isset($recurring_data['event_end']) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_end'])) : $event_date;
6039
+		$starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
6040
+		$endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
6041 6041
 		$is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : '';
6042 6042
 		$different_times = !empty($recurring_data['different_times']) ? true : false;
6043 6043
 	
6044
-		$recurring_pkg = geodir_event_recurring_pkg( $gd_post_info );
6045
-		$is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true;
6044
+		$recurring_pkg = geodir_event_recurring_pkg($gd_post_info);
6045
+		$is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true;
6046 6046
 			
6047 6047
 		if ($recurring_pkg && $is_recurring) {
6048 6048
 			$recurring_dates = $event_date;
@@ -6052,13 +6052,13 @@  discard block
 block discarded – undo
6052 6052
 			$recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
6053 6053
 			
6054 6054
 			if (!empty($recurring_data['event_recurring_dates'])) {
6055
-				$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
6055
+				$event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
6056 6056
 				
6057 6057
 				if (!empty($event_recurring_dates)) {
6058 6058
 					$recurring_dates = array();
6059 6059
 					
6060 6060
 					foreach ($event_recurring_dates as $date) {
6061
-						$recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) );
6061
+						$recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
6062 6062
 					}
6063 6063
 					
6064 6064
 					$recurring_dates = implode(",", $recurring_dates);
@@ -6074,7 +6074,7 @@  discard block
 block discarded – undo
6074 6074
 						$times = array();
6075 6075
 						
6076 6076
 						foreach ($recurring_data['starttimes'] as $time) {
6077
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6077
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6078 6078
 						}
6079 6079
 						
6080 6080
 						$event_starttimes = implode(",", $times);
@@ -6084,7 +6084,7 @@  discard block
 block discarded – undo
6084 6084
 						$times = array();
6085 6085
 						
6086 6086
 						foreach ($recurring_data['endtimes'] as $time) {
6087
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6087
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6088 6088
 						}
6089 6089
 						
6090 6090
 						$event_endtimes = implode(",", $times);
@@ -6096,8 +6096,8 @@  discard block
 block discarded – undo
6096 6096
 					}
6097 6097
 				}
6098 6098
 			} else {
6099
-				$event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1;
6100
-				$recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6099
+				$event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1;
6100
+				$recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6101 6101
 				
6102 6102
 				if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
6103 6103
 					$week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
@@ -6113,11 +6113,11 @@  discard block
 block discarded – undo
6113 6113
 				}
6114 6114
 				
6115 6115
 				$recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
6116
-				if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
6117
-					$recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : '';
6116
+				if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
6117
+					$recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['repeat_end'])) : '';
6118 6118
 					$max_recurring_count = empty($recurring_end_date) ? 1 : '';
6119 6119
 				} else {
6120
-					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1);
6120
+					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1);
6121 6121
 				}
6122 6122
 			}
6123 6123
 		}
@@ -6181,9 +6181,9 @@  discard block
 block discarded – undo
6181 6181
  * @return array Event data array.
6182 6182
  */
6183 6183
 function geodir_imex_process_event_data($gd_post) {
6184
-	$recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post );
6184
+	$recurring_pkg = geodir_event_recurring_pkg((object) $gd_post);
6185 6185
 
6186
-	$is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true;
6186
+	$is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true;
6187 6187
 	$event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : '';
6188 6188
 	$event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date;
6189 6189
 	$all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false;
@@ -6230,17 +6230,17 @@  discard block
 block discarded – undo
6230 6230
 				$event_recurring_dates = implode(",", $event_recurring_dates);
6231 6231
 			}
6232 6232
 		} else {
6233
-			$duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1;
6234
-			$repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1;
6235
-			$max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1;
6236
-			$repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6233
+			$duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1;
6234
+			$repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1;
6235
+			$max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1;
6236
+			$repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6237 6237
 			
6238 6238
 			$repeat_end_type = $repeat_end != '' ? 1 : 0;
6239 6239
 			$max_repeat = $repeat_end != '' ? '' : $max_repeat;
6240 6240
 			
6241 6241
 			$week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
6242 6242
 			
6243
-			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6243
+			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6244 6244
 			$repeat_days = array();
6245 6245
 			if (!empty($a_repeat_days)) {
6246 6246
 				foreach ($a_repeat_days as $repeat_day) {
@@ -6258,7 +6258,7 @@  discard block
 block discarded – undo
6258 6258
 			$repeat_weeks = array();
6259 6259
 			if (!empty($a_repeat_weeks)) {
6260 6260
 				foreach ($a_repeat_weeks as $repeat_week) {
6261
-					$repeat_weeks[] = (int)$repeat_week;
6261
+					$repeat_weeks[] = (int) $repeat_week;
6262 6262
 				}
6263 6263
 				
6264 6264
 				$repeat_weeks = array_unique($repeat_weeks);
@@ -6377,7 +6377,7 @@  discard block
 block discarded – undo
6377 6377
  */
6378 6378
 function geodir_admin_upgrade_notice() {
6379 6379
     $class = "error";
6380
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6380
+    $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
6381 6381
     echo"<div class=\"$class\"> <p>$message</p></div>";
6382 6382
 }
6383 6383
 
@@ -6389,7 +6389,7 @@  discard block
 block discarded – undo
6389 6389
  * @param (object) $r
6390 6390
  * @return (string) $output
6391 6391
  */
6392
-function geodire_admin_upgrade_notice( $plugin_data, $r )
6392
+function geodire_admin_upgrade_notice($plugin_data, $r)
6393 6393
 {
6394 6394
     // readme contents
6395 6395
     $args = array(
@@ -6397,7 +6397,7 @@  discard block
 block discarded – undo
6397 6397
         'redirection' => 5
6398 6398
     );
6399 6399
     $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6400
-    $data       = wp_remote_get( $url, $args );
6400
+    $data = wp_remote_get($url, $args);
6401 6401
 
6402 6402
     if (!is_wp_error($data) && $data['response']['code'] == 200) {
6403 6403
 
@@ -6412,20 +6412,20 @@  discard block
 block discarded – undo
6412 6412
 function geodir_in_plugin_update_message($content) {
6413 6413
     // Output Upgrade Notice
6414 6414
     $matches        = null;
6415
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6415
+    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote(GEODIRECTORY_VERSION) . '\s*=|$)~Uis';
6416 6416
     $upgrade_notice = '';
6417
-    if ( preg_match( $regexp, $content, $matches ) ) {
6418
-        if(empty($matches)){return;}
6417
+    if (preg_match($regexp, $content, $matches)) {
6418
+        if (empty($matches)) {return; }
6419 6419
 
6420
-        $version = trim( $matches[1] );
6421
-        if($version && $version>GEODIRECTORY_VERSION){
6420
+        $version = trim($matches[1]);
6421
+        if ($version && $version > GEODIRECTORY_VERSION) {
6422 6422
 
6423 6423
 
6424
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6425
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6424
+        $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
6425
+        if (version_compare(GEODIRECTORY_VERSION, $version, '<')) {
6426 6426
             $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6427
-            foreach ( $notices as $index => $line ) {
6428
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6427
+            foreach ($notices as $index => $line) {
6428
+                $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
6429 6429
             }
6430 6430
             $upgrade_notice .= '</div> ';
6431 6431
         }
@@ -6449,7 +6449,7 @@  discard block
 block discarded – undo
6449 6449
 		$default_language = $sitepress->get_default_language();
6450 6450
 		if ($current_language != 'all' && $current_language != $default_language) {
6451 6451
 	?>
6452
-	<div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory');?></strong></p></div>
6452
+	<div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory'); ?></strong></p></div>
6453 6453
 	<?php
6454 6454
 		}
6455 6455
 	}
Please login to merge, or discard this patch.
Braces   +231 added lines, -127 removed lines patch added patch discarded remove patch
@@ -183,8 +183,9 @@  discard block
 block discarded – undo
183 183
 
184 184
         $thumb_img_arr = array();
185 185
 
186
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
187
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
186
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
187
+                    $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
188
+        }
188 189
 
189 190
         $totImg = '';
190 191
         $image_limit = '';
@@ -240,7 +241,9 @@  discard block
 block discarded – undo
240 241
     {
241 242
         global $menu, $geodirectory;
242 243
 
243
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
244
+        if (current_user_can('manage_options')) {
245
+        	$menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
246
+        }
244 247
 
245 248
         add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
246 249
 
@@ -309,7 +312,9 @@  discard block
 block discarded – undo
309 312
      */
310 313
     function geodir_admin_custom_menu_order()
311 314
     {
312
-        if (!current_user_can('manage_options')) return false;
315
+        if (!current_user_can('manage_options')) {
316
+        	return false;
317
+        }
313 318
         return true;
314 319
     }
315 320
 }
@@ -340,10 +345,11 @@  discard block
 block discarded – undo
340 345
 			case 'fail':
341 346
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
342 347
 				
343
-				if ($gderr == 21)
344
-			    	echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
345
-				else
346
-					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
348
+				if ($gderr == 21) {
349
+							    	echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
350
+				} else {
351
+									echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
352
+				}
347 353
                 break;
348 354
         }
349 355
     }
@@ -380,8 +386,12 @@  discard block
 block discarded – undo
380 386
         include_once('option-pages/' . $current_tab . '_array.php');
381 387
     }
382 388
     if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
383
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
384
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
389
+        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) {
390
+        	die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
391
+        }
392
+        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) {
393
+        	die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
394
+        }
385 395
 		
386 396
 		/**
387 397
 		 * Fires before updating geodirectory admin settings.
@@ -393,8 +403,9 @@  discard block
 block discarded – undo
393 403
 		 */
394 404
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
395 405
 		
396
-        if (!empty($geodir_settings[$current_tab]))
397
-            geodir_update_options($geodir_settings[$current_tab]);
406
+        if (!empty($geodir_settings[$current_tab])) {
407
+                    geodir_update_options($geodir_settings[$current_tab]);
408
+        }
398 409
 
399 410
         /**
400 411
          * Called after GeoDirectory options settings are updated.
@@ -462,8 +473,9 @@  discard block
 block discarded – undo
462 473
                 $options_list = '';
463 474
                 for ($option = 1; $option <= 30; $option++) {
464 475
                     $selected = '';
465
-                    if ($option == 10)
466
-                        $selected = 'selected="selected"';
476
+                    if ($option == 10) {
477
+                                            $selected = 'selected="selected"';
478
+                    }
467 479
 
468 480
                     $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
469 481
                 }
@@ -661,10 +673,11 @@  discard block
 block discarded – undo
661 673
                     }
662 674
 
663 675
 
664
-                    if (geodir_dummy_folder_exists())
665
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
666
-                    else
667
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
676
+                    if (geodir_dummy_folder_exists()) {
677
+                                            $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
678
+                    } else {
679
+                                            $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
680
+                    }
668 681
                     $catname = str_replace(' ', '_', $catname);
669 682
                     $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
670 683
 
@@ -702,10 +715,11 @@  discard block
 block discarded – undo
702 715
             if (!term_exists($catname, 'gd_placecategory')) {
703 716
                 $last_catid = wp_insert_term($catname, 'gd_placecategory');
704 717
 
705
-                if (geodir_dummy_folder_exists())
706
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
707
-                else
708
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
718
+                if (geodir_dummy_folder_exists()) {
719
+                                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
720
+                } else {
721
+                                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
722
+                }
709 723
                 $catname = str_replace(' ', '_', $catname);
710 724
                 $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
711 725
 
@@ -754,11 +768,14 @@  discard block
 block discarded – undo
754 768
  * @return bool Returns true if saved.
755 769
  */
756 770
 function geodir_update_options($options, $dummy = false) {
757
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
771
+    if ((!isset($_POST) || !$_POST) && !$dummy) {
772
+    	return false;
773
+    }
758 774
 
759 775
     foreach ($options as $value) {
760
-        if ($dummy && isset($value['std']))
761
-            $_POST[$value['id']] = $value['std'];
776
+        if ($dummy && isset($value['std'])) {
777
+                    $_POST[$value['id']] = $value['std'];
778
+        }
762 779
 
763 780
 
764 781
         if (isset($value['type']) && $value['type'] == 'checkbox') :
@@ -767,25 +784,23 @@  discard block
 block discarded – undo
767 784
                 update_option($value['id'], $_POST[$value['id']]);
768 785
             } else {
769 786
                 update_option($value['id'], 0);
770
-            }
771
-
772
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
787
+            } elseif (isset($value['type']) && $value['type'] == 'image_width') :
773 788
 
774 789
             if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
775 790
                 update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
776 791
                 update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
777 792
                 if (isset($_POST[$value['id'] . '_crop'])) :
778 793
                     update_option($value['id'] . '_crop', 1);
779
-                else :
780
-                    update_option($value['id'] . '_crop', 0);
794
+                else {
795
+                	:
796
+                    update_option($value['id'] . '_crop', 0);
797
+                }
781 798
                 endif;
782 799
             } else {
783 800
                 update_option($value['id'] . '_width', $value['std']);
784 801
                 update_option($value['id'] . '_height', $value['std']);
785 802
                 update_option($value['id'] . '_crop', 1);
786
-            }
787
-
788
-        elseif (isset($value['type']) && $value['type'] == 'map') :
803
+            } elseif (isset($value['type']) && $value['type'] == 'map') :
789 804
             $post_types = array();
790 805
             $categories = array();
791 806
             $i = 0;
@@ -831,8 +846,9 @@  discard block
 block discarded – undo
831 846
                     $image_name_arr = explode('/', get_option($value['id']));
832 847
                     $noimg_name = end($image_name_arr);
833 848
                     $img_path = $uploads['path'] . '/' . $noimg_name;
834
-                    if (file_exists($img_path))
835
-                        unlink($img_path);
849
+                    if (file_exists($img_path)) {
850
+                                            unlink($img_path);
851
+                    }
836 852
                 }
837 853
 
838 854
                 update_option($value['id'], '');
@@ -848,8 +864,10 @@  discard block
 block discarded – undo
848 864
                 foreach ($uploadedfile as $key => $uplaod):
849 865
                     if ($key == 'name'):
850 866
                         $uplaods[$key] = $filename;
851
-                    else :
852
-                        $uplaods[$key] = $uplaod;
867
+                    else {
868
+                    	:
869
+                        $uplaods[$key] = $uplaod;
870
+                    }
853 871
                     endif;
854 872
                 endforeach;
855 873
 
@@ -859,8 +877,9 @@  discard block
 block discarded – undo
859 877
                     $image_name_arr = explode('/', get_option($value['id']));
860 878
                     $noimg_name = end($image_name_arr);
861 879
                     $img_path = $uploads['path'] . '/' . $noimg_name;
862
-                    if (file_exists($img_path))
863
-                        unlink($img_path);
880
+                    if (file_exists($img_path)) {
881
+                                            unlink($img_path);
882
+                    }
864 883
                 }
865 884
 
866 885
                 $upload_overrides = array('test_form' => false);
@@ -875,10 +894,12 @@  discard block
 block discarded – undo
875 894
             endif;
876 895
 
877 896
 
878
-        else :
897
+        else {
898
+        	:
879 899
             // same menu setting per theme.
880 900
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
881
-                $theme = wp_get_theme();
901
+                $theme = wp_get_theme();
902
+        }
882 903
                 update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
883 904
             }
884 905
 
@@ -890,8 +911,9 @@  discard block
 block discarded – undo
890 911
 
891 912
         endif;
892 913
     }
893
-    if ($dummy)
894
-        $_POST = array();
914
+    if ($dummy) {
915
+            $_POST = array();
916
+    }
895 917
     return true;
896 918
 
897 919
 }
@@ -1036,9 +1058,12 @@  discard block
 block discarded – undo
1036 1058
         $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1037 1059
             'categorys' => __('Categories', 'geodirectory'));
1038 1060
 
1039
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1061
+        if (($offset = array_search('author', array_keys($columns))) === false) {
1062
+        	// if the key doesn't exist
1040 1063
         {
1041
-            $offset = 0; // should we prepend $array with $data?
1064
+            $offset = 0;
1065
+        }
1066
+        // should we prepend $array with $data?
1042 1067
             $offset = count($columns); // or should we append $array with $data? lets pick this one...
1043 1068
         }
1044 1069
 
@@ -1098,11 +1123,13 @@  discard block
 block discarded – undo
1098 1123
                     $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1099 1124
                 }
1100 1125
                 /* If no expire_date is found, output a default message. */
1101
-                if (empty($expire_date))
1102
-                    echo __('Unknown', 'geodirectory');
1126
+                if (empty($expire_date)) {
1127
+                                    echo __('Unknown', 'geodirectory');
1128
+                }
1103 1129
                 /* If there is a expire_date, append 'days left' to the text string. */
1104
-                else
1105
-                    echo $expire_date . $date_diff_text;
1130
+                else {
1131
+                                    echo $expire_date . $date_diff_text;
1132
+                }
1106 1133
                 break;
1107 1134
 
1108 1135
             /* If displaying the 'categorys' column. */
@@ -1175,21 +1202,26 @@  discard block
 block discarded – undo
1175 1202
 
1176 1203
     $geodir_posttypes = geodir_get_posttypes();
1177 1204
 
1178
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1179
-        return;
1205
+    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1206
+            return;
1207
+    }
1180 1208
 
1181 1209
     if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1182
-        if (isset($_REQUEST['_status']))
1183
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1210
+        if (isset($_REQUEST['_status'])) {
1211
+                    geodir_change_post_status($post_id, $_REQUEST['_status']);
1212
+        }
1184 1213
 
1185
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1186
-            return;
1214
+        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) {
1215
+                    return;
1216
+        }
1187 1217
 
1188
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1189
-            return;
1218
+        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) {
1219
+                    return;
1220
+        }
1190 1221
 
1191
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1192
-            return;
1222
+        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) {
1223
+                    return;
1224
+        }
1193 1225
 
1194 1226
         geodir_save_listing($_REQUEST);
1195 1227
     }
@@ -1214,10 +1246,18 @@  discard block
 block discarded – undo
1214 1246
     $tab_id = '';
1215 1247
     $i = 0;
1216 1248
     foreach ($options as $value) :
1217
-        if (!isset($value['name'])) $value['name'] = '';
1218
-        if (!isset($value['class'])) $value['class'] = '';
1219
-        if (!isset($value['css'])) $value['css'] = '';
1220
-        if (!isset($value['std'])) $value['std'] = '';
1249
+        if (!isset($value['name'])) {
1250
+        	$value['name'] = '';
1251
+        }
1252
+        if (!isset($value['class'])) {
1253
+        	$value['class'] = '';
1254
+        }
1255
+        if (!isset($value['css'])) {
1256
+        	$value['css'] = '';
1257
+        }
1258
+        if (!isset($value['std'])) {
1259
+        	$value['std'] = '';
1260
+        }
1221 1261
         $desc = '';
1222 1262
         switch ($value['type']) :
1223 1263
             case 'dummy_installer':
@@ -1233,11 +1273,13 @@  discard block
 block discarded – undo
1233 1273
 
1234 1274
                 $i++;
1235 1275
 
1236
-                if (isset($value['id']) && $value['id'])
1237
-                    $tab_id = $value['id'];
1276
+                if (isset($value['id']) && $value['id']) {
1277
+                                    $tab_id = $value['id'];
1278
+                }
1238 1279
 
1239
-                if (isset($value['desc']) && $value['desc'])
1240
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1280
+                if (isset($value['desc']) && $value['desc']) {
1281
+                                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1282
+                }
1241 1283
 
1242 1284
                 if (isset($value['name']) && $value['name']) {
1243 1285
                     if ($first_title === true) {
@@ -1268,10 +1310,12 @@  discard block
 block discarded – undo
1268 1310
                 break;
1269 1311
 
1270 1312
             case 'sectionstart':
1271
-                if (isset($value['desc']) && $value['desc'])
1272
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1273
-                if (isset($value['name']) && $value['name'])
1274
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1313
+                if (isset($value['desc']) && $value['desc']) {
1314
+                                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1315
+                }
1316
+                if (isset($value['name']) && $value['name']) {
1317
+                                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1318
+                }
1275 1319
                 /**
1276 1320
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1277 1321
                  *
@@ -1279,7 +1323,9 @@  discard block
 block discarded – undo
1279 1323
                  *
1280 1324
                  * @since 1.0.0
1281 1325
                  */
1282
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1326
+                if (isset($value['id']) && $value['id']) {
1327
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1328
+                }
1283 1329
                 echo '<table class="form-table">' . "\n\n";
1284 1330
 
1285 1331
                 break;
@@ -1291,7 +1337,9 @@  discard block
 block discarded – undo
1291 1337
                  *
1292 1338
                  * @since 1.0.0
1293 1339
                  */
1294
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1340
+                if (isset($value['id']) && $value['id']) {
1341
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1342
+                }
1295 1343
                 echo '</table>';
1296 1344
                 /**
1297 1345
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -1300,7 +1348,9 @@  discard block
 block discarded – undo
1300 1348
                  *
1301 1349
                  * @since 1.0.0
1302 1350
                  */
1303
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1351
+                if (isset($value['id']) && $value['id']) {
1352
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1353
+                }
1304 1354
                 break;
1305 1355
             case 'text':
1306 1356
                 ?>
@@ -1372,17 +1422,32 @@  discard block
 block discarded – undo
1372 1422
                     <?php _e('Width', 'geodirectory'); ?> <input
1373 1423
                         name="<?php echo esc_attr($value['id']); ?>_width"
1374 1424
                         id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3"
1375
-                        value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1425
+                        value="<?php if ($size = get_option($value['id'] . '_width')) {
1426
+	echo stripslashes($size);
1427
+} else {
1428
+	echo $value['std'];
1429
+}
1430
+?>"/>
1376 1431
 
1377 1432
                     <?php _e('Height', 'geodirectory'); ?> <input
1378 1433
                         name="<?php echo esc_attr($value['id']); ?>_height"
1379 1434
                         id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3"
1380
-                        value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1435
+                        value="<?php if ($size = get_option($value['id'] . '_height')) {
1436
+	echo stripslashes($size);
1437
+} else {
1438
+	echo $value['std'];
1439
+}
1440
+?>"/>
1381 1441
 
1382 1442
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
1383 1443
                             name="<?php echo esc_attr($value['id']); ?>_crop"
1384 1444
                             id="<?php echo esc_attr($value['id']); ?>_crop"
1385
-                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label>
1445
+                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') {
1446
+	checked(get_option($value['id'] . '_crop'), 1);
1447
+} else {
1448
+	checked(1);
1449
+}
1450
+?> /></label>
1386 1451
 
1387 1452
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1388 1453
                 </tr><?php
@@ -1396,17 +1461,22 @@  discard block
 block discarded – undo
1396 1461
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
1397 1462
                                             id="<?php echo esc_attr($value['id']); ?>"
1398 1463
                                             style="<?php echo esc_attr($value['css']); ?>"
1399
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1464
+                                            class="<?php if (isset($value['class'])) {
1465
+	echo $value['class'];
1466
+}
1467
+?>"
1400 1468
                                             option-ajaxchosen="false">
1401 1469
                         <?php
1402 1470
                         foreach ($value['options'] as $key => $val) {
1403 1471
                             $geodir_select_value = '';
1404 1472
                             if ($option_value != '') {
1405
-                                if ($option_value != '' && $option_value == $key)
1406
-                                    $geodir_select_value = ' selected="selected" ';
1473
+                                if ($option_value != '' && $option_value == $key) {
1474
+                                                                    $geodir_select_value = ' selected="selected" ';
1475
+                                }
1407 1476
                             } else {
1408
-                                if ($value['std'] == $key)
1409
-                                    $geodir_select_value = ' selected="selected" ';
1477
+                                if ($value['std'] == $key) {
1478
+                                                                    $geodir_select_value = ' selected="selected" ';
1479
+                                }
1410 1480
                             }
1411 1481
                             ?>
1412 1482
                             <option
@@ -1431,8 +1501,14 @@  discard block
 block discarded – undo
1431 1501
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
1432 1502
                                             id="<?php echo esc_attr($value['id']); ?>"
1433 1503
                                             style="<?php echo esc_attr($value['css']); ?>"
1434
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1435
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1504
+                                            class="<?php if (isset($value['class'])) {
1505
+	echo $value['class'];
1506
+}
1507
+?>"
1508
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) {
1509
+	echo $value['placeholder_text'];
1510
+}
1511
+?>"
1436 1512
                                             option-ajaxchosen="false">
1437 1513
                         <?php
1438 1514
                         foreach ($value['options'] as $key => $val) {
@@ -1459,7 +1535,10 @@  discard block
 block discarded – undo
1459 1535
                 <td class="forminp">
1460 1536
                     <input type="file" name="<?php echo esc_attr($value['id']); ?>"
1461 1537
                            id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>"
1462
-                           class="<?php if (isset($value['class'])) echo $value['class']; ?>"/>
1538
+                           class="<?php if (isset($value['class'])) {
1539
+	echo $value['class'];
1540
+}
1541
+?>"/>
1463 1542
                     <?php if (get_option($value['id'])) { ?>
1464 1543
                         <input type="hidden" name="<?php echo esc_attr($value['id']); ?>_remove"
1465 1544
                                id="<?php echo esc_attr($value['id']); ?>_remove" value="0">
@@ -1540,13 +1619,15 @@  discard block
 block discarded – undo
1540 1619
                                 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1541 1620
                             );
1542 1621
                             $geodir_default_map_language = get_option('geodir_default_map_language');
1543
-                            if (empty($geodir_default_map_language))
1544
-                                $geodir_default_map_language = 'en';
1622
+                            if (empty($geodir_default_map_language)) {
1623
+                                                            $geodir_default_map_language = 'en';
1624
+                            }
1545 1625
                             foreach ($arr_map_langages as $language_key => $language_txt) {
1546
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1547
-                                    $geodir_default_language_selected = "selected='selected'";
1548
-                                else
1549
-                                    $geodir_default_language_selected = '';
1626
+                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) {
1627
+                                                                    $geodir_default_language_selected = "selected='selected'";
1628
+                                } else {
1629
+                                                                    $geodir_default_language_selected = '';
1630
+                                }
1550 1631
 
1551 1632
                                 ?>
1552 1633
                                 <option
@@ -1566,14 +1647,16 @@  discard block
 block discarded – undo
1566 1647
                             <?php
1567 1648
                             $post_types = geodir_get_posttypes('array');
1568 1649
                             $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1569
-                            if (empty($geodir_default_map_search_pt))
1570
-                                $geodir_default_map_search_pt = 'gd_place';
1650
+                            if (empty($geodir_default_map_search_pt)) {
1651
+                                                            $geodir_default_map_search_pt = 'gd_place';
1652
+                            }
1571 1653
                             if (is_array($post_types)) {
1572 1654
                                 foreach ($post_types as $key => $post_types_obj) {
1573
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1574
-                                        $geodir_search_pt_selected = "selected='selected'";
1575
-                                    else
1576
-                                        $geodir_search_pt_selected = '';
1655
+                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) {
1656
+                                                                            $geodir_search_pt_selected = "selected='selected'";
1657
+                                    } else {
1658
+                                                                            $geodir_search_pt_selected = '';
1659
+                                    }
1577 1660
 
1578 1661
                                     ?>
1579 1662
                                     <option
@@ -1693,7 +1776,7 @@  discard block
 block discarded – undo
1693 1776
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1694 1777
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1695 1778
                             echo 'checked="checked"';
1696
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1779
+                        } elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1697 1780
                         <?php echo $value['desc']; ?></label><br>
1698 1781
                 </fieldset>
1699 1782
                 <?php
@@ -1713,10 +1796,18 @@  discard block
 block discarded – undo
1713 1796
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1714 1797
                 <td class="forminp">
1715 1798
                     <textarea
1716
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1799
+                        <?php if (isset($value['args'])) {
1800
+	echo $value['args'] . ' ';
1801
+}
1802
+?>name="<?php echo esc_attr($value['id']); ?>"
1717 1803
                         id="<?php echo esc_attr($value['id']); ?>"
1718 1804
                         <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1719
-                        style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) echo esc_textarea(stripslashes(get_option($value['id']))); else echo esc_textarea($value['std']); ?></textarea><span
1805
+                        style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) {
1806
+	echo esc_textarea(stripslashes(get_option($value['id'])));
1807
+} else {
1808
+	echo esc_textarea($value['std']);
1809
+}
1810
+?></textarea><span
1720 1811
                         class="description"><?php echo $value['desc'] ?></span>
1721 1812
 
1722 1813
                 </td>
@@ -1730,10 +1821,11 @@  discard block
 block discarded – undo
1730 1821
                 <td class="forminp"><?php
1731 1822
 
1732 1823
                     $content = '';
1733
-                    if (get_option($value['id']))
1734
-                        $content = stripslashes(get_option($value['id']));
1735
-                    else
1736
-                        $content = $value['std'];
1824
+                    if (get_option($value['id'])) {
1825
+                                            $content = stripslashes(get_option($value['id']));
1826
+                    } else {
1827
+                                            $content = $value['std'];
1828
+                    }
1737 1829
 
1738 1830
                     $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1739 1831
 
@@ -1773,7 +1865,9 @@  discard block
 block discarded – undo
1773 1865
                     'echo' => false,
1774 1866
                     'selected' => $page_setting);
1775 1867
 
1776
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1868
+                if (isset($value['args'])) {
1869
+                	$args = wp_parse_args($value['args'], $args);
1870
+                }
1777 1871
 
1778 1872
                 ?>
1779 1873
                 <tr valign="top" class="single_select_page">
@@ -1793,8 +1887,10 @@  discard block
 block discarded – undo
1793 1887
                 if (strstr($country_setting, ':')) :
1794 1888
                     $country = current(explode(':', $country_setting));
1795 1889
                     $state = end(explode(':', $country_setting));
1796
-                else :
1797
-                    $country = $country_setting;
1890
+                else {
1891
+                	:
1892
+                    $country = $country_setting;
1893
+                }
1798 1894
                     $state = '*';
1799 1895
                 endif;
1800 1896
                 ?>
@@ -1821,8 +1917,10 @@  discard block
 block discarded – undo
1821 1917
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1822 1918
                             title="Country" class="chosen_select">
1823 1919
                         <?php
1824
-                        if ($countries) foreach ($countries as $key => $val) :
1825
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1920
+                        if ($countries) {
1921
+                        	foreach ($countries as $key => $val) :
1922
+                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1923
+                        }
1826 1924
                         endforeach;
1827 1925
                         ?>
1828 1926
                     </select>
@@ -2073,8 +2171,9 @@  discard block
 block discarded – undo
2073 2171
         endforeach;
2074 2172
     endif;
2075 2173
 
2076
-    if (!empty($place_img_array))
2077
-        $curImages = implode(',', $place_img_array);
2174
+    if (!empty($place_img_array)) {
2175
+            $curImages = implode(',', $place_img_array);
2176
+    }
2078 2177
 
2079 2178
 
2080 2179
     // adjust values here
@@ -2421,16 +2520,17 @@  discard block
 block discarded – undo
2421 2520
 	
2422 2521
 	$post_type = NULL;
2423 2522
 	
2424
-	if ($post && isset($post->post_type))
2425
-		$post_type = $post->post_type;
2426
-	elseif ($typenow)
2427
-		$post_type = $typenow;
2428
-	elseif ($current_screen && isset($current_screen->post_type))
2429
-		$post_type = $current_screen->post_type;
2430
-	elseif (isset($_REQUEST['post_type']))
2431
-		$post_type = sanitize_key($_REQUEST['post_type']);
2432
-	elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2433
-		$post_type = get_post_type($_REQUEST['post']);
2523
+	if ($post && isset($post->post_type)) {
2524
+			$post_type = $post->post_type;
2525
+	} elseif ($typenow) {
2526
+			$post_type = $typenow;
2527
+	} elseif ($current_screen && isset($current_screen->post_type)) {
2528
+			$post_type = $current_screen->post_type;
2529
+	} elseif (isset($_REQUEST['post_type'])) {
2530
+			$post_type = sanitize_key($_REQUEST['post_type']);
2531
+	} elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) {
2532
+			$post_type = get_post_type($_REQUEST['post']);
2533
+	}
2434 2534
 
2435 2535
 	return $post_type;
2436 2536
 }
@@ -2489,9 +2589,10 @@  discard block
 block discarded – undo
2489 2589
 function geodir_hide_admin_preview_button() {
2490 2590
     global $post_type;
2491 2591
     $post_types = geodir_get_posttypes();
2492
-    if(in_array($post_type, $post_types))
2493
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2494
-}
2592
+    if(in_array($post_type, $post_types)) {
2593
+            echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2594
+    }
2595
+    }
2495 2596
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2496 2597
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2497 2598
 
@@ -5550,8 +5651,9 @@  discard block
 block discarded – undo
5550 5651
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5551 5652
 	global $wpdb, $plugin_prefix;
5552 5653
 
5553
-	if ( ! post_type_exists( $post_type ) )
5554
-		return new stdClass;
5654
+	if ( ! post_type_exists( $post_type ) ) {
5655
+			return new stdClass;
5656
+	}
5555 5657
 		
5556 5658
 	$table = $plugin_prefix . $post_type . '_detail';
5557 5659
 	
@@ -6329,7 +6431,9 @@  discard block
 block discarded – undo
6329 6431
 
6330 6432
     if ($page_found) :
6331 6433
         // Page exists
6332
-        if (!$option_value) update_option($option, $page_found);
6434
+        if (!$option_value) {
6435
+        	update_option($option, $page_found);
6436
+        }
6333 6437
         return;
6334 6438
     endif;
6335 6439
 
Please login to merge, or discard this patch.
Indentation   +2639 added lines, -2639 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Admin functions.
4
- *
5
- * @since 1.0.0
6
- * @package GeoDirectory
7
- */
3
+	 * Admin functions.
4
+	 *
5
+	 * @since 1.0.0
6
+	 * @package GeoDirectory
7
+	 */
8 8
 
9 9
 /**
10 10
  * Updates option value when GeoDirectory get deactivated.
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 function geodir_deactivation()
16 16
 {
17 17
 
18
-    // Update installed variable
19
-    update_option("geodir_installed", 0);
18
+	// Update installed variable
19
+	update_option("geodir_installed", 0);
20 20
 
21
-    // Remove rewrite rules and then recreate rewrite rules.
22
-    flush_rewrite_rules();
21
+	// Remove rewrite rules and then recreate rewrite rules.
22
+	flush_rewrite_rules();
23 23
 }
24 24
 
25 25
 
@@ -32,105 +32,105 @@  discard block
 block discarded – undo
32 32
 function geodir_uninstall()
33 33
 {
34 34
 
35
-    delete_option('geodir_default_data_installed');
35
+	delete_option('geodir_default_data_installed');
36 36
 
37 37
 }
38 38
 
39 39
 if (!function_exists('geodir_admin_styles')) {
40
-    /**
41
-     * Enqueue Admin Styles.
42
-     *
43
-     * @since 1.0.0
44
-     * @package GeoDirectory
45
-     */
46
-    function geodir_admin_styles()
47
-    {
40
+	/**
41
+	 * Enqueue Admin Styles.
42
+	 *
43
+	 * @since 1.0.0
44
+	 * @package GeoDirectory
45
+	 */
46
+	function geodir_admin_styles()
47
+	{
48 48
 
49
-        wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
50
-        wp_enqueue_style('geodirectory-admin-css');
49
+		wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
50
+		wp_enqueue_style('geodirectory-admin-css');
51 51
 
52
-        wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
53
-        wp_enqueue_style('geodirectory-frontend-style');
52
+		wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
53
+		wp_enqueue_style('geodirectory-frontend-style');
54 54
 
55
-        wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
56
-        wp_enqueue_style('geodir-chosen-style');
55
+		wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
56
+		wp_enqueue_style('geodir-chosen-style');
57 57
 
58
-        wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
59
-        wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
58
+		wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
59
+		wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
60 60
 
61
-        wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
62
-        wp_enqueue_style('geodirectory-jquery-ui-css');
61
+		wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
62
+		wp_enqueue_style('geodirectory-jquery-ui-css');
63 63
 
64
-        wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
65
-        wp_enqueue_style('geodirectory-custom-fields-css');
64
+		wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
65
+		wp_enqueue_style('geodirectory-custom-fields-css');
66 66
 
67
-        wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
68
-        wp_enqueue_style('geodirectory-pluplodar-css');
67
+		wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
68
+		wp_enqueue_style('geodirectory-pluplodar-css');
69 69
 
70
-        wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
71
-        wp_enqueue_style('geodir-rating-style');
70
+		wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
71
+		wp_enqueue_style('geodir-rating-style');
72 72
 
73
-        wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
74
-        wp_enqueue_style('geodir-rtl-style');
73
+		wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
74
+		wp_enqueue_style('geodir-rtl-style');
75 75
 
76
-    }
76
+	}
77 77
 }
78 78
 
79 79
 if (!function_exists('geodir_admin_styles_req')) {
80
-    /**
81
-     * Loads stylesheets from CDN.
82
-     *
83
-     * @since 1.0.0
84
-     * @package GeoDirectory
85
-     */
86
-    function geodir_admin_styles_req()
87
-    {
80
+	/**
81
+	 * Loads stylesheets from CDN.
82
+	 *
83
+	 * @since 1.0.0
84
+	 * @package GeoDirectory
85
+	 */
86
+	function geodir_admin_styles_req()
87
+	{
88 88
 
89
-        wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
-        wp_enqueue_style('geodirectory-font-awesome');
89
+		wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
+		wp_enqueue_style('geodirectory-font-awesome');
91 91
 
92
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
93
-        wp_enqueue_script('geodirectory-admin');
92
+		wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
93
+		wp_enqueue_script('geodirectory-admin');
94 94
 
95
-    }
95
+	}
96 96
 }
97 97
 
98 98
 if (!function_exists('geodir_admin_scripts')) {
99
-    /**
100
-     * Enqueue Admin Scripts.
101
-     *
102
-     * @since 1.0.0
103
-     * @package GeoDirectory
104
-     */
105
-    function geodir_admin_scripts()
106
-    {
99
+	/**
100
+	 * Enqueue Admin Scripts.
101
+	 *
102
+	 * @since 1.0.0
103
+	 * @package GeoDirectory
104
+	 */
105
+	function geodir_admin_scripts()
106
+	{
107 107
 
108
-        wp_enqueue_script('jquery');
108
+		wp_enqueue_script('jquery');
109 109
 
110
-        wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
110
+		wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
111 111
 
112
-        wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array(), GEODIRECTORY_VERSION);
113
-        wp_enqueue_script('chosen');
112
+		wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array(), GEODIRECTORY_VERSION);
113
+		wp_enqueue_script('chosen');
114 114
 
115
-        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
116
-        wp_enqueue_script('geodirectory-choose-ajax');
115
+		wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
116
+		wp_enqueue_script('geodirectory-choose-ajax');
117 117
 
118
-        if (isset($_REQUEST['listing_type'])) {
119
-            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
120
-        }
118
+		if (isset($_REQUEST['listing_type'])) {
119
+			wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
120
+		}
121 121
 
122
-        wp_enqueue_script('geodirectory-custom-fields-script');
123
-        $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
122
+		wp_enqueue_script('geodirectory-custom-fields-script');
123
+		$plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
124 124
 
125
-        wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
125
+		wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
126 126
 
127
-        $map_lang = "&language=" . geodir_get_map_default_language();
128
-        /** This filter is documented in geodirectory_template_tags.php */
129
-        $map_extra = apply_filters('geodir_googlemap_script_extra', '');
130
-        wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
127
+		$map_lang = "&language=" . geodir_get_map_default_language();
128
+		/** This filter is documented in geodirectory_template_tags.php */
129
+		$map_extra = apply_filters('geodir_googlemap_script_extra', '');
130
+		wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
131 131
 
132
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
133
-        wp_enqueue_script('geodirectory-goMap-script');
132
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
133
+		wp_enqueue_script('geodirectory-goMap-script');
134 134
 
135 135
 		// font awesome rating script
136 136
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
@@ -141,177 +141,177 @@  discard block
 block discarded – undo
141 141
 			wp_enqueue_script('geodir-jRating-js');
142 142
 		}
143 143
 
144
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
145
-        wp_enqueue_script('geodir-on-document-load');
146
-
147
-
148
-        // SCRIPT FOR UPLOAD
149
-        wp_enqueue_script('plupload-all');
150
-        wp_enqueue_script('jquery-ui-sortable');
151
-
152
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
153
-        wp_enqueue_script('geodirectory-plupload-script');
154
-
155
-        // SCRIPT FOR UPLOAD END
156
-
157
-
158
-        // place js config array for plupload
159
-        $plupload_init = array(
160
-            'runtimes' => 'html5,silverlight,flash,html4',
161
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
162
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
163
-            'drop_element' => 'dropbox', // will be adjusted per uploader
164
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
165
-            'multiple_queues' => true,
166
-            'max_file_size' => geodir_max_upload_size(),
167
-            'url' => admin_url('admin-ajax.php'),
168
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
169
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
170
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
171
-            'multipart' => true,
172
-            'urlstream_upload' => true,
173
-            'multi_selection' => false, // will be added per uploader
174
-            // additional post data to send to our ajax hook
175
-            'multipart_params' => array(
176
-                '_ajax_nonce' => "", // will be added per uploader
177
-                'action' => 'plupload_action', // the ajax action name
178
-                'imgid' => 0 // will be added per uploader
179
-            )
180
-        );
181
-        $base_plupload_config = json_encode($plupload_init);
182
-
183
-
184
-        $thumb_img_arr = array();
185
-
186
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
187
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
188
-
189
-        $totImg = '';
190
-        $image_limit = '';
191
-        if (!empty($thumb_img_arr)) {
192
-            foreach ($thumb_img_arr as $img) {
193
-                $curImages = $img->src . ",";
194
-            }
144
+		wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
145
+		wp_enqueue_script('geodir-on-document-load');
146
+
147
+
148
+		// SCRIPT FOR UPLOAD
149
+		wp_enqueue_script('plupload-all');
150
+		wp_enqueue_script('jquery-ui-sortable');
151
+
152
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
153
+		wp_enqueue_script('geodirectory-plupload-script');
154
+
155
+		// SCRIPT FOR UPLOAD END
156
+
157
+
158
+		// place js config array for plupload
159
+		$plupload_init = array(
160
+			'runtimes' => 'html5,silverlight,flash,html4',
161
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
162
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
163
+			'drop_element' => 'dropbox', // will be adjusted per uploader
164
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
165
+			'multiple_queues' => true,
166
+			'max_file_size' => geodir_max_upload_size(),
167
+			'url' => admin_url('admin-ajax.php'),
168
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
169
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
170
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
171
+			'multipart' => true,
172
+			'urlstream_upload' => true,
173
+			'multi_selection' => false, // will be added per uploader
174
+			// additional post data to send to our ajax hook
175
+			'multipart_params' => array(
176
+				'_ajax_nonce' => "", // will be added per uploader
177
+				'action' => 'plupload_action', // the ajax action name
178
+				'imgid' => 0 // will be added per uploader
179
+			)
180
+		);
181
+		$base_plupload_config = json_encode($plupload_init);
182
+
183
+
184
+		$thumb_img_arr = array();
185
+
186
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
187
+			$thumb_img_arr = geodir_get_images($_REQUEST['pid']);
188
+
189
+		$totImg = '';
190
+		$image_limit = '';
191
+		if (!empty($thumb_img_arr)) {
192
+			foreach ($thumb_img_arr as $img) {
193
+				$curImages = $img->src . ",";
194
+			}
195 195
 
196
-            $totImg = count($thumb_img_arr);
197
-        }
196
+			$totImg = count($thumb_img_arr);
197
+		}
198 198
 
199 199
 
200
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
201
-            'totalImg' => $totImg,
202
-            'image_limit' => $image_limit,
203
-            'upload_img_size' => geodir_max_upload_size());
200
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
201
+			'totalImg' => $totImg,
202
+			'image_limit' => $image_limit,
203
+			'upload_img_size' => geodir_max_upload_size());
204 204
 
205
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
205
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
206 206
 
207
-        $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
208
-        wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
207
+		$ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
208
+		wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
209 209
 
210 210
 
211
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
212
-        wp_enqueue_script('geodirectory-admin-script');
211
+		wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
212
+		wp_enqueue_script('geodirectory-admin-script');
213 213
 
214
-        wp_enqueue_style('farbtastic');
215
-        wp_enqueue_script('farbtastic');
214
+		wp_enqueue_style('farbtastic');
215
+		wp_enqueue_script('farbtastic');
216 216
 
217
-        $screen = get_current_screen();
218
-        if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
219
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
220
-        }
217
+		$screen = get_current_screen();
218
+		if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
219
+			wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
220
+		}
221 221
 
222
-        $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
223
-        wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
222
+		$ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
223
+		wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
224 224
 
225
-    }
225
+	}
226 226
 }
227 227
 
228 228
 if (!function_exists('geodir_admin_menu')) {
229
-    /**
230
-     * Admin Menus
231
-     *
232
-     * Sets up the admin menus in wordpress.
233
-     *
234
-     * @since 1.0.0
235
-     * @package GeoDirectory
236
-     * @global array $menu Menu array.
237
-     * @global object $geodirectory GeoDirectory plugin object.
238
-     */
239
-    function geodir_admin_menu()
240
-    {
241
-        global $menu, $geodirectory;
229
+	/**
230
+	 * Admin Menus
231
+	 *
232
+	 * Sets up the admin menus in wordpress.
233
+	 *
234
+	 * @since 1.0.0
235
+	 * @package GeoDirectory
236
+	 * @global array $menu Menu array.
237
+	 * @global object $geodirectory GeoDirectory plugin object.
238
+	 */
239
+	function geodir_admin_menu()
240
+	{
241
+		global $menu, $geodirectory;
242 242
 
243
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
243
+		if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
244 244
 
245
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
245
+		add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
246 246
 
247 247
 
248
-    }
248
+	}
249 249
 }
250 250
 
251 251
 if (!function_exists('geodir_admin_menu_order')) {
252
-    /**
253
-     * Order admin menus.
254
-     *
255
-     * @since 1.0.0
256
-     * @package GeoDirectory
257
-     * @param array $menu_order Menu order array.
258
-     * @return array Modified menu order array.
259
-     */
260
-    function geodir_admin_menu_order($menu_order)
261
-    {
262
-
263
-        // Initialize our custom order array
264
-        $geodir_menu_order = array();
265
-
266
-        // Get the index of our custom separator
267
-        $geodir_separator = array_search('separator-geodirectory', $menu_order);
268
-
269
-        // Get index of posttype menu
270
-        $post_types = geodir_get_posttypes();
271
-        if (!empty($post_types)) {
272
-            foreach ($post_types as $post_type) {
273
-                $geodir_posts = array_search("edit.php?post_type={$post_type}", $menu_order);
274
-            }
275
-        }
252
+	/**
253
+	 * Order admin menus.
254
+	 *
255
+	 * @since 1.0.0
256
+	 * @package GeoDirectory
257
+	 * @param array $menu_order Menu order array.
258
+	 * @return array Modified menu order array.
259
+	 */
260
+	function geodir_admin_menu_order($menu_order)
261
+	{
276 262
 
277
-        // Loop through menu order and do some rearranging
278
-        foreach ($menu_order as $index => $item) :
263
+		// Initialize our custom order array
264
+		$geodir_menu_order = array();
279 265
 
280
-            if ((('geodirectory') == $item)) :
281
-                $geodir_menu_order[] = 'separator-geodirectory';
282
-                if (!empty($post_types)) {
283
-                    foreach ($post_types as $post_type) {
284
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
285
-                    }
286
-                }
287
-                $geodir_menu_order[] = $item;
266
+		// Get the index of our custom separator
267
+		$geodir_separator = array_search('separator-geodirectory', $menu_order);
288 268
 
289
-                unset($menu_order[$geodir_separator]);
290
-            //unset( $menu_order[$geodir_places] );
291
-            elseif (!in_array($item, array('separator-geodirectory'))) :
292
-                $geodir_menu_order[] = $item;
293
-            endif;
269
+		// Get index of posttype menu
270
+		$post_types = geodir_get_posttypes();
271
+		if (!empty($post_types)) {
272
+			foreach ($post_types as $post_type) {
273
+				$geodir_posts = array_search("edit.php?post_type={$post_type}", $menu_order);
274
+			}
275
+		}
294 276
 
295
-        endforeach;
277
+		// Loop through menu order and do some rearranging
278
+		foreach ($menu_order as $index => $item) :
296 279
 
297
-        // Return order
298
-        return $geodir_menu_order;
299
-    }
280
+			if ((('geodirectory') == $item)) :
281
+				$geodir_menu_order[] = 'separator-geodirectory';
282
+				if (!empty($post_types)) {
283
+					foreach ($post_types as $post_type) {
284
+						$geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
285
+					}
286
+				}
287
+				$geodir_menu_order[] = $item;
288
+
289
+				unset($menu_order[$geodir_separator]);
290
+			//unset( $menu_order[$geodir_places] );
291
+			elseif (!in_array($item, array('separator-geodirectory'))) :
292
+				$geodir_menu_order[] = $item;
293
+			endif;
294
+
295
+		endforeach;
296
+
297
+		// Return order
298
+		return $geodir_menu_order;
299
+	}
300 300
 }
301 301
 
302 302
 if (!function_exists('geodir_admin_custom_menu_order')) {
303
-    /**
304
-     * Enables custom menu order.
305
-     *
306
-     * @since 1.0.0
307
-     * @package GeoDirectory
308
-     * @return bool
309
-     */
310
-    function geodir_admin_custom_menu_order()
311
-    {
312
-        if (!current_user_can('manage_options')) return false;
313
-        return true;
314
-    }
303
+	/**
304
+	 * Enables custom menu order.
305
+	 *
306
+	 * @since 1.0.0
307
+	 * @package GeoDirectory
308
+	 * @return bool
309
+	 */
310
+	function geodir_admin_custom_menu_order()
311
+	{
312
+		if (!current_user_can('manage_options')) return false;
313
+		return true;
314
+	}
315 315
 }
316 316
 
317 317
 /**
@@ -322,41 +322,41 @@  discard block
 block discarded – undo
322 322
  */
323 323
 function geodir_before_admin_panel()
324 324
 {
325
-    if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
326
-        echo '<div id="message" class="updated fade">
325
+	if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
326
+		echo '<div id="message" class="updated fade">
327 327
                         <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
328 328
                         <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
329 329
                 </div>';
330 330
 
331
-    }
331
+	}
332 332
 
333
-    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
334
-        switch ($_REQUEST['msg']) {
335
-            case 'success':
336
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
337
-                flush_rewrite_rules(false);
333
+	if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
334
+		switch ($_REQUEST['msg']) {
335
+			case 'success':
336
+				echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
337
+				flush_rewrite_rules(false);
338 338
 
339
-                break;
339
+				break;
340 340
 			case 'fail':
341 341
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
342 342
 				
343 343
 				if ($gderr == 21)
344
-			    	echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
344
+					echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
345 345
 				else
346 346
 					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
347
-                break;
348
-        }
349
-    }
347
+				break;
348
+		}
349
+	}
350 350
 
351
-    if (!geodir_is_default_location_set()) {
352
-        echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
351
+	if (!geodir_is_default_location_set()) {
352
+		echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
353 353
 
354
-    }
354
+	}
355 355
 
356
-    if (!function_exists('curl_init')) {
357
-        echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
356
+	if (!function_exists('curl_init')) {
357
+		echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
358 358
 
359
-    }
359
+	}
360 360
 }
361 361
 
362 362
 /**
@@ -369,19 +369,19 @@  discard block
 block discarded – undo
369 369
  */
370 370
 function geodir_handle_option_form_submit($current_tab)
371 371
 {
372
-    global $geodir_settings;
373
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
374
-        /**
375
-         * Contains settings array for current tab.
376
-         *
377
-         * @since 1.0.0
378
-         * @package GeoDirectory
379
-         */
380
-        include_once('option-pages/' . $current_tab . '_array.php');
381
-    }
382
-    if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
383
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
384
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
372
+	global $geodir_settings;
373
+	if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
374
+		/**
375
+		 * Contains settings array for current tab.
376
+		 *
377
+		 * @since 1.0.0
378
+		 * @package GeoDirectory
379
+		 */
380
+		include_once('option-pages/' . $current_tab . '_array.php');
381
+	}
382
+	if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
383
+		if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
384
+		if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
385 385
 		
386 386
 		/**
387 387
 		 * Fires before updating geodirectory admin settings.
@@ -393,100 +393,100 @@  discard block
 block discarded – undo
393 393
 		 */
394 394
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
395 395
 		
396
-        if (!empty($geodir_settings[$current_tab]))
397
-            geodir_update_options($geodir_settings[$current_tab]);
396
+		if (!empty($geodir_settings[$current_tab]))
397
+			geodir_update_options($geodir_settings[$current_tab]);
398 398
 
399
-        /**
400
-         * Called after GeoDirectory options settings are updated.
401
-         *
402
-         * @since 1.0.0
403
-         * @param array $geodir_settings The array of GeoDirectory settings.
404
-         * @see 'geodir_before_update_options'
405
-         */
406
-        do_action('geodir_update_options', $geodir_settings);
399
+		/**
400
+		 * Called after GeoDirectory options settings are updated.
401
+		 *
402
+		 * @since 1.0.0
403
+		 * @param array $geodir_settings The array of GeoDirectory settings.
404
+		 * @see 'geodir_before_update_options'
405
+		 */
406
+		do_action('geodir_update_options', $geodir_settings);
407 407
 
408
-        /**
409
-         * Called after GeoDirectory options settings are updated.
410
-         *
411
-         * Provides tab specific settings.
412
-         *
413
-         * @since 1.0.0
414
-         * @param string $current_tab The current settings tab name.
415
-         * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
416
-         */
417
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
408
+		/**
409
+		 * Called after GeoDirectory options settings are updated.
410
+		 *
411
+		 * Provides tab specific settings.
412
+		 *
413
+		 * @since 1.0.0
414
+		 * @param string $current_tab The current settings tab name.
415
+		 * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
416
+		 */
417
+		do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
418 418
 
419
-        flush_rewrite_rules(false);
419
+		flush_rewrite_rules(false);
420 420
 
421
-        $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
421
+		$current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
422 422
 
423
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
423
+		$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
424 424
 
425
-        wp_redirect($redirect_url);
426
-        exit();
427
-    endif;
425
+		wp_redirect($redirect_url);
426
+		exit();
427
+	endif;
428 428
 
429 429
 
430 430
 }
431 431
 
432 432
 
433 433
 if (!function_exists('geodir_autoinstall_admin_header') && get_option('geodir_installed')) {
434
-    /**
435
-     * GeoDirectory dummy data installation.
436
-     *
437
-     * @since 1.0.0
438
-     * @package GeoDirectory
439
-     * @global object $wpdb WordPress Database object.
440
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
441
-     * @param string $post_type The post type.
442
-     */
443
-    function geodir_autoinstall_admin_header($post_type = 'gd_place')
444
-    {
434
+	/**
435
+	 * GeoDirectory dummy data installation.
436
+	 *
437
+	 * @since 1.0.0
438
+	 * @package GeoDirectory
439
+	 * @global object $wpdb WordPress Database object.
440
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
441
+	 * @param string $post_type The post type.
442
+	 */
443
+	function geodir_autoinstall_admin_header($post_type = 'gd_place')
444
+	{
445 445
 
446
-        global $wpdb, $plugin_prefix;
446
+		global $wpdb, $plugin_prefix;
447 447
 
448
-        if (!geodir_is_default_location_set()) {
449
-            echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
450
-        } else {
448
+		if (!geodir_is_default_location_set()) {
449
+			echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
450
+		} else {
451 451
 
452
-            $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
452
+			$geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
453 453
 
454
-            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
454
+			$post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
455 455
 
456
-            if ($post_counts > 0) {
457
-                $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
456
+			if ($post_counts > 0) {
457
+				$nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
458 458
 
459
-                $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '"  >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>';
460
-                $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>';
461
-            } else {
462
-                $options_list = '';
463
-                for ($option = 1; $option <= 30; $option++) {
464
-                    $selected = '';
465
-                    if ($option == 10)
466
-                        $selected = 'selected="selected"';
459
+				$dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '"  >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>';
460
+				$dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>';
461
+			} else {
462
+				$options_list = '';
463
+				for ($option = 1; $option <= 30; $option++) {
464
+					$selected = '';
465
+					if ($option == 10)
466
+						$selected = 'selected="selected"';
467 467
 
468
-                    $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
469
-                }
468
+					$options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
469
+				}
470 470
 
471
-                $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
471
+				$nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
472 472
 
473
-                $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')"   redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>';
474
-                $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>';
473
+				$dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')"   redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>';
474
+				$dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>';
475 475
 
476
-            }
477
-            echo $dummy_msg;
478
-            ?>
476
+			}
477
+			echo $dummy_msg;
478
+			?>
479 479
             <script>
480 480
                 <?php
481 481
 
482
-                    $default_location = geodir_get_default_location();
483
-                  $city =  isset($default_location->city) ? $default_location->city : '';
484
-                  $region =isset($default_location->region) ? $default_location->region : '';
485
-                  $country =isset($default_location->country) ? $default_location->country : '';
486
-                  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
487
-                  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
482
+					$default_location = geodir_get_default_location();
483
+				  $city =  isset($default_location->city) ? $default_location->city : '';
484
+				  $region =isset($default_location->region) ? $default_location->region : '';
485
+				  $country =isset($default_location->country) ? $default_location->country : '';
486
+				  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
487
+				  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
488 488
 
489
-                ?>
489
+				?>
490 490
                 var geocoder = new google.maps.Geocoder();
491 491
                 var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>';
492 492
                 var bound_lat_lng;
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
                 }
572 572
             </script>
573 573
         <?php
574
-        }
575
-    }
574
+		}
575
+	}
576 576
 }
577 577
 
578 578
 /**
@@ -585,19 +585,19 @@  discard block
 block discarded – undo
585 585
  */
586 586
 function geodir_insert_dummy_posts()
587 587
 {
588
-    geodir_default_taxonomies();
588
+	geodir_default_taxonomies();
589 589
 
590
-    ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
590
+	ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
591 591
 
592
-    global $wpdb, $current_user;
592
+	global $wpdb, $current_user;
593 593
 
594
-    /**
595
-     * Contains dumy post content.
596
-     *
597
-     * @since 1.0.0
598
-     * @package GeoDirectory
599
-     */
600
-    include_once('place_dummy_post.php');
594
+	/**
595
+	 * Contains dumy post content.
596
+	 *
597
+	 * @since 1.0.0
598
+	 * @package GeoDirectory
599
+	 */
600
+	include_once('place_dummy_post.php');
601 601
 
602 602
 }
603 603
 
@@ -611,18 +611,18 @@  discard block
 block discarded – undo
611 611
  */
612 612
 function geodir_delete_dummy_posts()
613 613
 {
614
-    global $wpdb, $plugin_prefix;
614
+	global $wpdb, $plugin_prefix;
615 615
 
616 616
 
617
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
617
+	$post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
618 618
 
619 619
 
620
-    foreach ($post_ids as $post_ids_obj) {
621
-        wp_delete_post($post_ids_obj->post_id);
622
-    }
620
+	foreach ($post_ids as $post_ids_obj) {
621
+		wp_delete_post($post_ids_obj->post_id);
622
+	}
623 623
 
624
-    //double check posts are deleted
625
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
624
+	//double check posts are deleted
625
+	$wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
626 626
 }
627 627
 
628 628
 /**
@@ -636,116 +636,116 @@  discard block
 block discarded – undo
636 636
  * @global string $dummy_image_path The dummy image path.
637 637
  */
638 638
 function geodir_default_taxonomies() {
639
-    global $wpdb, $dummy_image_path;
639
+	global $wpdb, $dummy_image_path;
640 640
 
641
-    $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
641
+	$category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
642 642
 
643
-    $last_catid = isset($last_catid) ? $last_catid : '';
643
+	$last_catid = isset($last_catid) ? $last_catid : '';
644 644
 
645
-    $last_term = get_term($last_catid, 'gd_placecategory');
645
+	$last_term = get_term($last_catid, 'gd_placecategory');
646 646
 
647
-    $uploads = wp_upload_dir(); // Array of key => value pairs
647
+	$uploads = wp_upload_dir(); // Array of key => value pairs
648 648
 
649
-    for ($i = 0; $i < count($category_array); $i++) {
650
-        $parent_catid = 0;
651
-        if (is_array($category_array[$i])) {
652
-            $cat_name_arr = $category_array[$i];
653
-            for ($j = 0; $j < count($cat_name_arr); $j++) {
654
-                $catname = $cat_name_arr[$j];
649
+	for ($i = 0; $i < count($category_array); $i++) {
650
+		$parent_catid = 0;
651
+		if (is_array($category_array[$i])) {
652
+			$cat_name_arr = $category_array[$i];
653
+			for ($j = 0; $j < count($cat_name_arr); $j++) {
654
+				$catname = $cat_name_arr[$j];
655 655
 
656
-                if (!term_exists($catname, 'gd_placecategory')) {
657
-                    $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
656
+				if (!term_exists($catname, 'gd_placecategory')) {
657
+					$last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
658 658
 
659
-                    if ($j == 0) {
660
-                        $parent_catid = $last_catid;
661
-                    }
659
+					if ($j == 0) {
660
+						$parent_catid = $last_catid;
661
+					}
662 662
 
663 663
 
664
-                    if (geodir_dummy_folder_exists())
665
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
666
-                    else
667
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
664
+					if (geodir_dummy_folder_exists())
665
+						$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
666
+					else
667
+						$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
668 668
 
669
-                    $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
669
+					$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
670 670
 
671
-                    $catname = str_replace(' ', '_', $catname);
672
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
671
+					$catname = str_replace(' ', '_', $catname);
672
+					$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
673 673
 
674
-                    if (empty($uploaded['error'])) {
675
-                        $new_path = $uploaded['file'];
676
-                        $new_url = $uploaded['url'];
677
-                    }
674
+					if (empty($uploaded['error'])) {
675
+						$new_path = $uploaded['file'];
676
+						$new_url = $uploaded['url'];
677
+					}
678 678
 
679
-                    $wp_filetype = wp_check_filetype(basename($new_path), null);
680
-
681
-                    $attachment = array(
682
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
683
-                        'post_mime_type' => $wp_filetype['type'],
684
-                        'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
685
-                        'post_content' => '',
686
-                        'post_status' => 'inherit'
687
-                    );
688
-                    $attach_id = wp_insert_attachment($attachment, $new_path);
689
-
690
-                    // you must first include the image.php file
691
-                    // for the function wp_generate_attachment_metadata() to work
692
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
693
-                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
694
-                    wp_update_attachment_metadata($attach_id, $attach_data);
695
-
696
-                    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
697
-                        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
698
-                    }
699
-                }
700
-            }
679
+					$wp_filetype = wp_check_filetype(basename($new_path), null);
680
+
681
+					$attachment = array(
682
+						'guid' => $uploads['baseurl'] . '/' . basename($new_path),
683
+						'post_mime_type' => $wp_filetype['type'],
684
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
685
+						'post_content' => '',
686
+						'post_status' => 'inherit'
687
+					);
688
+					$attach_id = wp_insert_attachment($attachment, $new_path);
689
+
690
+					// you must first include the image.php file
691
+					// for the function wp_generate_attachment_metadata() to work
692
+					require_once(ABSPATH . 'wp-admin/includes/image.php');
693
+					$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
694
+					wp_update_attachment_metadata($attach_id, $attach_data);
695
+
696
+					if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
697
+						update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
698
+					}
699
+				}
700
+			}
701 701
 
702
-        } else {
703
-            $catname = $category_array[$i];
702
+		} else {
703
+			$catname = $category_array[$i];
704 704
 
705
-            if (!term_exists($catname, 'gd_placecategory')) {
706
-                $last_catid = wp_insert_term($catname, 'gd_placecategory');
705
+			if (!term_exists($catname, 'gd_placecategory')) {
706
+				$last_catid = wp_insert_term($catname, 'gd_placecategory');
707 707
 
708
-                if (geodir_dummy_folder_exists())
709
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
710
-                else
711
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
708
+				if (geodir_dummy_folder_exists())
709
+					$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
710
+				else
711
+					$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
712 712
 
713
-                $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
713
+				$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
714 714
 
715
-                $catname = str_replace(' ', '_', $catname);
716
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
715
+				$catname = str_replace(' ', '_', $catname);
716
+				$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
717 717
 
718
-                if (empty($uploaded['error'])) {
719
-                    $new_path = $uploaded['file'];
720
-                    $new_url = $uploaded['url'];
721
-                }
718
+				if (empty($uploaded['error'])) {
719
+					$new_path = $uploaded['file'];
720
+					$new_url = $uploaded['url'];
721
+				}
722 722
 
723
-                $wp_filetype = wp_check_filetype(basename($new_path), null);
723
+				$wp_filetype = wp_check_filetype(basename($new_path), null);
724 724
 
725
-                $attachment = array(
726
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
727
-                    'post_mime_type' => $wp_filetype['type'],
728
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
729
-                    'post_content' => '',
730
-                    'post_status' => 'inherit'
731
-                );
725
+				$attachment = array(
726
+					'guid' => $uploads['baseurl'] . '/' . basename($new_path),
727
+					'post_mime_type' => $wp_filetype['type'],
728
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
729
+					'post_content' => '',
730
+					'post_status' => 'inherit'
731
+				);
732 732
 
733
-                $attach_id = wp_insert_attachment($attachment, $new_path);
733
+				$attach_id = wp_insert_attachment($attachment, $new_path);
734 734
 
735 735
 
736
-                // you must first include the image.php file
737
-                // for the function wp_generate_attachment_metadata() to work
738
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
739
-                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
740
-                wp_update_attachment_metadata($attach_id, $attach_data);
736
+				// you must first include the image.php file
737
+				// for the function wp_generate_attachment_metadata() to work
738
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
739
+				$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
740
+				wp_update_attachment_metadata($attach_id, $attach_data);
741 741
 
742
-                if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
743
-                    update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
744
-                }
745
-            }
746
-        }
742
+				if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
743
+					update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
744
+				}
745
+			}
746
+		}
747 747
 
748
-    }
748
+	}
749 749
 }
750 750
 
751 751
 /**
@@ -760,145 +760,145 @@  discard block
 block discarded – undo
760 760
  * @return bool Returns true if saved.
761 761
  */
762 762
 function geodir_update_options($options, $dummy = false) {
763
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
763
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
764 764
 
765
-    foreach ($options as $value) {
766
-        if ($dummy && isset($value['std']))
767
-            $_POST[$value['id']] = $value['std'];
765
+	foreach ($options as $value) {
766
+		if ($dummy && isset($value['std']))
767
+			$_POST[$value['id']] = $value['std'];
768 768
 
769 769
 
770
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
770
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
771 771
 
772
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
773
-                update_option($value['id'], $_POST[$value['id']]);
774
-            } else {
775
-                update_option($value['id'], 0);
776
-            }
772
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
773
+				update_option($value['id'], $_POST[$value['id']]);
774
+			} else {
775
+				update_option($value['id'], 0);
776
+			}
777 777
 
778
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
778
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
779 779
 
780
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
781
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
782
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
783
-                if (isset($_POST[$value['id'] . '_crop'])) :
784
-                    update_option($value['id'] . '_crop', 1);
785
-                else :
786
-                    update_option($value['id'] . '_crop', 0);
787
-                endif;
788
-            } else {
789
-                update_option($value['id'] . '_width', $value['std']);
790
-                update_option($value['id'] . '_height', $value['std']);
791
-                update_option($value['id'] . '_crop', 1);
792
-            }
780
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
781
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
782
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
783
+				if (isset($_POST[$value['id'] . '_crop'])) :
784
+					update_option($value['id'] . '_crop', 1);
785
+				else :
786
+					update_option($value['id'] . '_crop', 0);
787
+				endif;
788
+			} else {
789
+				update_option($value['id'] . '_width', $value['std']);
790
+				update_option($value['id'] . '_height', $value['std']);
791
+				update_option($value['id'] . '_crop', 1);
792
+			}
793 793
 
794
-        elseif (isset($value['type']) && $value['type'] == 'map') :
795
-            $post_types = array();
796
-            $categories = array();
797
-            $i = 0;
794
+		elseif (isset($value['type']) && $value['type'] == 'map') :
795
+			$post_types = array();
796
+			$categories = array();
797
+			$i = 0;
798 798
 
799
-            if (!empty($_POST['home_map_post_types'])) :
800
-                foreach ($_POST['home_map_post_types'] as $post_type) :
801
-                    $post_types[] = $post_type;
802
-                endforeach;
803
-            endif;
799
+			if (!empty($_POST['home_map_post_types'])) :
800
+				foreach ($_POST['home_map_post_types'] as $post_type) :
801
+					$post_types[] = $post_type;
802
+				endforeach;
803
+			endif;
804 804
 
805
-            update_option('geodir_exclude_post_type_on_map', $post_types);
805
+			update_option('geodir_exclude_post_type_on_map', $post_types);
806 806
 
807
-            if (!empty($_POST['post_category'])) :
808
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
809
-                    $categories[$texonomy] = array();
810
-                    foreach ($cat_arr as $category) :
811
-                        $categories[$texonomy][] = $category;
812
-                    endforeach;
813
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
814
-                endforeach;
815
-            endif;
816
-            update_option('geodir_exclude_cat_on_map', $categories);
817
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
818
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
807
+			if (!empty($_POST['post_category'])) :
808
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
809
+					$categories[$texonomy] = array();
810
+					foreach ($cat_arr as $category) :
811
+						$categories[$texonomy][] = $category;
812
+					endforeach;
813
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
814
+				endforeach;
815
+			endif;
816
+			update_option('geodir_exclude_cat_on_map', $categories);
817
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
818
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
819 819
 
820 820
 
821
-            if (!empty($_POST['geodir_default_map_language'])):
822
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
823
-            endif;
821
+			if (!empty($_POST['geodir_default_map_language'])):
822
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
823
+			endif;
824 824
 
825 825
 
826
-            if (!empty($_POST['geodir_default_map_search_pt'])):
827
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
828
-            endif;
826
+			if (!empty($_POST['geodir_default_map_search_pt'])):
827
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
828
+			endif;
829 829
 
830 830
 
831
-        elseif (isset($value['type']) && $value['type'] == 'file') :
831
+		elseif (isset($value['type']) && $value['type'] == 'file') :
832 832
 
833 833
 
834
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
834
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
835 835
 
836
-                if (get_option($value['id'])) {
837
-                    $image_name_arr = explode('/', get_option($value['id']));
838
-                    $noimg_name = end($image_name_arr);
839
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
840
-                    if (file_exists($img_path))
841
-                        unlink($img_path);
842
-                }
836
+				if (get_option($value['id'])) {
837
+					$image_name_arr = explode('/', get_option($value['id']));
838
+					$noimg_name = end($image_name_arr);
839
+					$img_path = $uploads['path'] . '/' . $noimg_name;
840
+					if (file_exists($img_path))
841
+						unlink($img_path);
842
+				}
843 843
 
844
-                update_option($value['id'], '');
845
-            }
844
+				update_option($value['id'], '');
845
+			}
846 846
 
847
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
848
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
849
-
850
-            if (!empty($filename)):
851
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
852
-                $uplaods = array();
853
-
854
-                foreach ($uploadedfile as $key => $uplaod):
855
-                    if ($key == 'name'):
856
-                        $uplaods[$key] = $filename;
857
-                    else :
858
-                        $uplaods[$key] = $uplaod;
859
-                    endif;
860
-                endforeach;
861
-
862
-                $uploads = wp_upload_dir();
863
-
864
-                if (get_option($value['id'])) {
865
-                    $image_name_arr = explode('/', get_option($value['id']));
866
-                    $noimg_name = end($image_name_arr);
867
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
868
-                    if (file_exists($img_path))
869
-                        unlink($img_path);
870
-                }
847
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
848
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
849
+
850
+			if (!empty($filename)):
851
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
852
+				$uplaods = array();
853
+
854
+				foreach ($uploadedfile as $key => $uplaod):
855
+					if ($key == 'name'):
856
+						$uplaods[$key] = $filename;
857
+					else :
858
+						$uplaods[$key] = $uplaod;
859
+					endif;
860
+				endforeach;
861
+
862
+				$uploads = wp_upload_dir();
863
+
864
+				if (get_option($value['id'])) {
865
+					$image_name_arr = explode('/', get_option($value['id']));
866
+					$noimg_name = end($image_name_arr);
867
+					$img_path = $uploads['path'] . '/' . $noimg_name;
868
+					if (file_exists($img_path))
869
+						unlink($img_path);
870
+				}
871 871
 
872
-                $upload_overrides = array('test_form' => false);
873
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
872
+				$upload_overrides = array('test_form' => false);
873
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
874 874
 
875
-                update_option($value['id'], $movefile['url']);
875
+				update_option($value['id'], $movefile['url']);
876 876
 
877
-            endif;
877
+			endif;
878 878
 
879
-            if (!get_option($value['id']) && isset($value['value'])):
880
-                update_option($value['id'], $value['value']);
881
-            endif;
879
+			if (!get_option($value['id']) && isset($value['value'])):
880
+				update_option($value['id'], $value['value']);
881
+			endif;
882 882
 
883 883
 
884
-        else :
885
-            // same menu setting per theme.
886
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
887
-                $theme = wp_get_theme();
888
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
889
-            }
884
+		else :
885
+			// same menu setting per theme.
886
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
887
+				$theme = wp_get_theme();
888
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
889
+			}
890 890
 
891
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
892
-                update_option($value['id'], $_POST[$value['id']]);
893
-            } else {
894
-                delete_option($value['id']);
895
-            }
891
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
892
+				update_option($value['id'], $_POST[$value['id']]);
893
+			} else {
894
+				delete_option($value['id']);
895
+			}
896 896
 
897
-        endif;
898
-    }
899
-    if ($dummy)
900
-        $_POST = array();
901
-    return true;
897
+		endif;
898
+	}
899
+	if ($dummy)
900
+		$_POST = array();
901
+	return true;
902 902
 
903 903
 }
904 904
 
@@ -947,33 +947,33 @@  discard block
 block discarded – undo
947 947
 function places_custom_fields_tab($tabs)
948 948
 {
949 949
 
950
-    $geodir_post_types = get_option('geodir_post_types');
950
+	$geodir_post_types = get_option('geodir_post_types');
951 951
 
952
-    if (!empty($geodir_post_types)) {
952
+	if (!empty($geodir_post_types)) {
953 953
 
954
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
954
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
955 955
 
956
-            $listing_slug = $geodir_posttype_info['labels']['singular_name'];
956
+			$listing_slug = $geodir_posttype_info['labels']['singular_name'];
957 957
 
958
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
959
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
960
-                'subtabs' => array(
961
-                    array('subtab' => 'custom_fields',
962
-                        'label' => __('Custom Fields', 'geodirectory'),
963
-                        'request' => array('listing_type' => $geodir_post_type)),
964
-                    array('subtab' => 'sorting_options',
965
-                        'label' => __('Sorting Options', 'geodirectory'),
966
-                        'request' => array('listing_type' => $geodir_post_type)),
967
-                ),
968
-                'tab_index' => 9,
969
-                'request' => array('listing_type' => $geodir_post_type)
970
-            );
958
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
959
+				'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
960
+				'subtabs' => array(
961
+					array('subtab' => 'custom_fields',
962
+						'label' => __('Custom Fields', 'geodirectory'),
963
+						'request' => array('listing_type' => $geodir_post_type)),
964
+					array('subtab' => 'sorting_options',
965
+						'label' => __('Sorting Options', 'geodirectory'),
966
+						'request' => array('listing_type' => $geodir_post_type)),
967
+				),
968
+				'tab_index' => 9,
969
+				'request' => array('listing_type' => $geodir_post_type)
970
+			);
971 971
 
972
-        endforeach;
972
+		endforeach;
973 973
 
974
-    }
974
+	}
975 975
 
976
-    return $tabs;
976
+	return $tabs;
977 977
 }
978 978
 
979 979
 
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
  */
990 990
 function geodir_tools_setting_tab($tabs)
991 991
 {
992
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
993
-    return $tabs;
992
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
993
+	return $tabs;
994 994
 }
995 995
 
996 996
 /**
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
  */
1006 1006
 function geodir_compatibility_setting_tab($tabs)
1007 1007
 {
1008
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1009
-    return $tabs;
1008
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1009
+	return $tabs;
1010 1010
 }
1011 1011
 
1012 1012
 
@@ -1022,144 +1022,144 @@  discard block
 block discarded – undo
1022 1022
  */
1023 1023
 function geodir_extend_geodirectory_setting_tab($tabs)
1024 1024
 {
1025
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1026
-    return $tabs;
1025
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1026
+	return $tabs;
1027 1027
 }
1028 1028
 
1029 1029
 
1030 1030
 if (!function_exists('geodir_edit_post_columns')) {
1031
-    /**
1032
-     * Modify admin post listing page columns.
1033
-     *
1034
-     * @since 1.0.0
1035
-     * @package GeoDirectory
1036
-     * @param array $columns The column array.
1037
-     * @return array Altered column array.
1038
-     */
1039
-    function geodir_edit_post_columns($columns)
1040
-    {
1041
-
1042
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1043
-            'categorys' => __('Categories', 'geodirectory'));
1044
-
1045
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1046
-        {
1047
-            $offset = 0; // should we prepend $array with $data?
1048
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
1049
-        }
1031
+	/**
1032
+	 * Modify admin post listing page columns.
1033
+	 *
1034
+	 * @since 1.0.0
1035
+	 * @package GeoDirectory
1036
+	 * @param array $columns The column array.
1037
+	 * @return array Altered column array.
1038
+	 */
1039
+	function geodir_edit_post_columns($columns)
1040
+	{
1050 1041
 
1051
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1042
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1043
+			'categorys' => __('Categories', 'geodirectory'));
1052 1044
 
1053
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1045
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1046
+		{
1047
+			$offset = 0; // should we prepend $array with $data?
1048
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
1049
+		}
1054 1050
 
1055
-        return $columns;
1056
-    }
1051
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1052
+
1053
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1054
+
1055
+		return $columns;
1056
+	}
1057 1057
 }
1058 1058
 
1059 1059
 
1060 1060
 if (!function_exists('geodir_manage_post_columns')) {
1061
-    /**
1062
-     * Adds content to our custom post listing page columns.
1063
-     *
1064
-     * @since 1.0.0
1065
-     * @package GeoDirectory
1066
-     * @global object $wpdb WordPress Database object.
1067
-     * @global object $post WordPress Post object.
1068
-     * @param string $column The column name.
1069
-     * @param int $post_id The post ID.
1070
-     */
1071
-    function geodir_manage_post_columns($column, $post_id)
1072
-    {
1073
-        global $post, $wpdb;
1074
-
1075
-        switch ($column):
1076
-            /* If displaying the 'city' column. */
1077
-            case 'location' :
1078
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1079
-                $location = geodir_get_location($location_id);
1080
-                /* If no city is found, output a default message. */
1081
-                if (empty($location)) {
1082
-                    _e('Unknown', 'geodirectory');
1083
-                } else {
1084
-                    /* If there is a city id, append 'city name' to the text string. */
1085
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1086
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1087
-                }
1088
-                break;
1089
-
1090
-            /* If displaying the 'expire' column. */
1091
-            case 'expire' :
1092
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1093
-                $d1 = $expire_date; // get expire_date
1094
-                $d2 = date('Y-m-d'); // get current date
1095
-                $state = __('days left', 'geodirectory');
1096
-                $date_diff_text = '';
1097
-                $expire_class = 'expire_left';
1098
-                if ($expire_date != 'Never') {
1099
-                    if (strtotime($d1) < strtotime($d2)) {
1100
-                        $state = __('days overdue', 'geodirectory');
1101
-                        $expire_class = 'expire_over';
1102
-                    }
1103
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the differance in days
1104
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1105
-                }
1106
-                /* If no expire_date is found, output a default message. */
1107
-                if (empty($expire_date))
1108
-                    echo __('Unknown', 'geodirectory');
1109
-                /* If there is a expire_date, append 'days left' to the text string. */
1110
-                else
1111
-                    echo $expire_date . $date_diff_text;
1112
-                break;
1113
-
1114
-            /* If displaying the 'categorys' column. */
1115
-            case 'categorys' :
1116
-
1117
-                /* Get the categorys for the post. */
1118
-
1119
-
1120
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1121
-
1122
-                /* If terms were found. */
1123
-                if (!empty($terms)) {
1124
-                    $out = array();
1125
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
1126
-                    foreach ($terms as $term) {
1127
-                        if (!strstr($term->taxonomy, 'tag')) {
1128
-                            $out[] = sprintf('<a href="%s">%s</a>',
1129
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1130
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1131
-                            );
1132
-                        }
1133
-                    }
1134
-                    /* Join the terms, separating them with a comma. */
1135
-                    echo(join(', ', $out));
1136
-                } /* If no terms were found, output a default message. */
1137
-                else {
1138
-                    _e('No Categories', 'geodirectory');
1139
-                }
1140
-                break;
1061
+	/**
1062
+	 * Adds content to our custom post listing page columns.
1063
+	 *
1064
+	 * @since 1.0.0
1065
+	 * @package GeoDirectory
1066
+	 * @global object $wpdb WordPress Database object.
1067
+	 * @global object $post WordPress Post object.
1068
+	 * @param string $column The column name.
1069
+	 * @param int $post_id The post ID.
1070
+	 */
1071
+	function geodir_manage_post_columns($column, $post_id)
1072
+	{
1073
+		global $post, $wpdb;
1074
+
1075
+		switch ($column):
1076
+			/* If displaying the 'city' column. */
1077
+			case 'location' :
1078
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1079
+				$location = geodir_get_location($location_id);
1080
+				/* If no city is found, output a default message. */
1081
+				if (empty($location)) {
1082
+					_e('Unknown', 'geodirectory');
1083
+				} else {
1084
+					/* If there is a city id, append 'city name' to the text string. */
1085
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1086
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1087
+				}
1088
+				break;
1089
+
1090
+			/* If displaying the 'expire' column. */
1091
+			case 'expire' :
1092
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1093
+				$d1 = $expire_date; // get expire_date
1094
+				$d2 = date('Y-m-d'); // get current date
1095
+				$state = __('days left', 'geodirectory');
1096
+				$date_diff_text = '';
1097
+				$expire_class = 'expire_left';
1098
+				if ($expire_date != 'Never') {
1099
+					if (strtotime($d1) < strtotime($d2)) {
1100
+						$state = __('days overdue', 'geodirectory');
1101
+						$expire_class = 'expire_over';
1102
+					}
1103
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the differance in days
1104
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1105
+				}
1106
+				/* If no expire_date is found, output a default message. */
1107
+				if (empty($expire_date))
1108
+					echo __('Unknown', 'geodirectory');
1109
+				/* If there is a expire_date, append 'days left' to the text string. */
1110
+				else
1111
+					echo $expire_date . $date_diff_text;
1112
+				break;
1141 1113
 
1142
-        endswitch;
1143
-    }
1114
+			/* If displaying the 'categorys' column. */
1115
+			case 'categorys' :
1116
+
1117
+				/* Get the categorys for the post. */
1118
+
1119
+
1120
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1121
+
1122
+				/* If terms were found. */
1123
+				if (!empty($terms)) {
1124
+					$out = array();
1125
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
1126
+					foreach ($terms as $term) {
1127
+						if (!strstr($term->taxonomy, 'tag')) {
1128
+							$out[] = sprintf('<a href="%s">%s</a>',
1129
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1130
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1131
+							);
1132
+						}
1133
+					}
1134
+					/* Join the terms, separating them with a comma. */
1135
+					echo(join(', ', $out));
1136
+				} /* If no terms were found, output a default message. */
1137
+				else {
1138
+					_e('No Categories', 'geodirectory');
1139
+				}
1140
+				break;
1141
+
1142
+		endswitch;
1143
+	}
1144 1144
 }
1145 1145
 
1146 1146
 
1147 1147
 if (!function_exists('geodir_post_sortable_columns')) {
1148
-    /**
1149
-     * Makes admin post listing page columns sortable.
1150
-     *
1151
-     * @since 1.0.0
1152
-     * @package GeoDirectory
1153
-     * @param array $columns The column array.
1154
-     * @return array Altered column array.
1155
-     */
1156
-    function geodir_post_sortable_columns($columns)
1157
-    {
1158
-
1159
-        $columns['expire'] = 'expire';
1160
-
1161
-        return $columns;
1162
-    }
1148
+	/**
1149
+	 * Makes admin post listing page columns sortable.
1150
+	 *
1151
+	 * @since 1.0.0
1152
+	 * @package GeoDirectory
1153
+	 * @param array $columns The column array.
1154
+	 * @return array Altered column array.
1155
+	 */
1156
+	function geodir_post_sortable_columns($columns)
1157
+	{
1158
+
1159
+		$columns['expire'] = 'expire';
1160
+
1161
+		return $columns;
1162
+	}
1163 1163
 }
1164 1164
 
1165 1165
 /**
@@ -1173,32 +1173,32 @@  discard block
 block discarded – undo
1173 1173
  * @param int $post_id The post ID.
1174 1174
  */
1175 1175
 function geodir_post_information_save($post_id, $post) {
1176
-    global $wpdb, $current_user;
1176
+	global $wpdb, $current_user;
1177 1177
 
1178
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1179
-        return;
1180
-    }
1178
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1179
+		return;
1180
+	}
1181 1181
 
1182
-    $geodir_posttypes = geodir_get_posttypes();
1182
+	$geodir_posttypes = geodir_get_posttypes();
1183 1183
 
1184
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1185
-        return;
1184
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1185
+		return;
1186 1186
 
1187
-    if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1188
-        if (isset($_REQUEST['_status']))
1189
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1187
+	if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1188
+		if (isset($_REQUEST['_status']))
1189
+			geodir_change_post_status($post_id, $_REQUEST['_status']);
1190 1190
 
1191
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1192
-            return;
1191
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1192
+			return;
1193 1193
 
1194
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1195
-            return;
1194
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1195
+			return;
1196 1196
 
1197
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1198
-            return;
1197
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1198
+			return;
1199 1199
 
1200
-        geodir_save_listing($_REQUEST);
1201
-    }
1200
+		geodir_save_listing($_REQUEST);
1201
+	}
1202 1202
 }
1203 1203
 
1204 1204
 /**
@@ -1214,102 +1214,102 @@  discard block
 block discarded – undo
1214 1214
  */
1215 1215
 function geodir_admin_fields($options)
1216 1216
 {
1217
-    global $geodirectory;
1218
-
1219
-    $first_title = true;
1220
-    $tab_id = '';
1221
-    $i = 0;
1222
-    foreach ($options as $value) :
1223
-        if (!isset($value['name'])) $value['name'] = '';
1224
-        if (!isset($value['class'])) $value['class'] = '';
1225
-        if (!isset($value['css'])) $value['css'] = '';
1226
-        if (!isset($value['std'])) $value['std'] = '';
1227
-        $desc = '';
1228
-        switch ($value['type']) :
1229
-            case 'dummy_installer':
1230
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1231
-                geodir_autoinstall_admin_header($post_type);
1232
-                break;
1233
-            case 'title':
1234
-
1235
-                if ($i == 0) {
1236
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1237
-                    echo '<div class="inner_content_tab_main">';
1238
-                }
1217
+	global $geodirectory;
1218
+
1219
+	$first_title = true;
1220
+	$tab_id = '';
1221
+	$i = 0;
1222
+	foreach ($options as $value) :
1223
+		if (!isset($value['name'])) $value['name'] = '';
1224
+		if (!isset($value['class'])) $value['class'] = '';
1225
+		if (!isset($value['css'])) $value['css'] = '';
1226
+		if (!isset($value['std'])) $value['std'] = '';
1227
+		$desc = '';
1228
+		switch ($value['type']) :
1229
+			case 'dummy_installer':
1230
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1231
+				geodir_autoinstall_admin_header($post_type);
1232
+				break;
1233
+			case 'title':
1234
+
1235
+				if ($i == 0) {
1236
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1237
+					echo '<div class="inner_content_tab_main">';
1238
+				}
1239 1239
 
1240
-                $i++;
1240
+				$i++;
1241 1241
 
1242
-                if (isset($value['id']) && $value['id'])
1243
-                    $tab_id = $value['id'];
1242
+				if (isset($value['id']) && $value['id'])
1243
+					$tab_id = $value['id'];
1244 1244
 
1245
-                if (isset($value['desc']) && $value['desc'])
1246
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1245
+				if (isset($value['desc']) && $value['desc'])
1246
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1247 1247
 
1248
-                if (isset($value['name']) && $value['name']) {
1249
-                    if ($first_title === true) {
1250
-                        $first_title = false;
1251
-                    } else {
1252
-                        echo '</div>';
1253
-                    }
1254
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1248
+				if (isset($value['name']) && $value['name']) {
1249
+					if ($first_title === true) {
1250
+						$first_title = false;
1251
+					} else {
1252
+						echo '</div>';
1253
+					}
1254
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1255 1255
 
1256
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1257
-                }
1256
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1257
+				}
1258 1258
 
1259
-                /**
1260
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
1261
-                 *
1262
-                 * The action is called dynamically geodir_settings_$value['id'].
1263
-                 *
1264
-                 * @since 1.0.0
1265
-                 */
1266
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1267
-                break;
1268
-
1269
-            case 'no_tabs':
1270
-
1271
-                echo '<div class="inner_content_tab_main">';
1272
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1273
-
1274
-                break;
1275
-
1276
-            case 'sectionstart':
1277
-                if (isset($value['desc']) && $value['desc'])
1278
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1279
-                if (isset($value['name']) && $value['name'])
1280
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1281
-                /**
1282
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1283
-                 *
1284
-                 * The action is called dynamically geodir_settings_$value['id']_start.
1285
-                 *
1286
-                 * @since 1.0.0
1287
-                 */
1288
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1289
-                echo '<table class="form-table">' . "\n\n";
1290
-
1291
-                break;
1292
-            case 'sectionend':
1293
-                /**
1294
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1295
-                 *
1296
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1297
-                 *
1298
-                 * @since 1.0.0
1299
-                 */
1300
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1301
-                echo '</table>';
1302
-                /**
1303
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1304
-                 *
1305
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1306
-                 *
1307
-                 * @since 1.0.0
1308
-                 */
1309
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1310
-                break;
1311
-            case 'text':
1312
-                ?>
1259
+				/**
1260
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
1261
+				 *
1262
+				 * The action is called dynamically geodir_settings_$value['id'].
1263
+				 *
1264
+				 * @since 1.0.0
1265
+				 */
1266
+				do_action('geodir_settings_' . sanitize_title($value['id']));
1267
+				break;
1268
+
1269
+			case 'no_tabs':
1270
+
1271
+				echo '<div class="inner_content_tab_main">';
1272
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1273
+
1274
+				break;
1275
+
1276
+			case 'sectionstart':
1277
+				if (isset($value['desc']) && $value['desc'])
1278
+					$desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1279
+				if (isset($value['name']) && $value['name'])
1280
+					echo '<h3>' . $value['name'] . $desc . '</h3>';
1281
+				/**
1282
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1283
+				 *
1284
+				 * The action is called dynamically geodir_settings_$value['id']_start.
1285
+				 *
1286
+				 * @since 1.0.0
1287
+				 */
1288
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1289
+				echo '<table class="form-table">' . "\n\n";
1290
+
1291
+				break;
1292
+			case 'sectionend':
1293
+				/**
1294
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1295
+				 *
1296
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1297
+				 *
1298
+				 * @since 1.0.0
1299
+				 */
1300
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1301
+				echo '</table>';
1302
+				/**
1303
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1304
+				 *
1305
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1306
+				 *
1307
+				 * @since 1.0.0
1308
+				 */
1309
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1310
+				break;
1311
+			case 'text':
1312
+				?>
1313 1313
                 <tr valign="top">
1314 1314
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1315 1315
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1318,15 +1318,15 @@  discard block
 block discarded – undo
1318 1318
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1319 1319
                                            style=" <?php echo esc_attr($value['css']); ?>"
1320 1320
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1321
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1322
-                                           } else {
1323
-                                               echo esc_attr($value['std']);
1324
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1321
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1322
+										   } else {
1323
+											   echo esc_attr($value['std']);
1324
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1325 1325
                 </tr><?php
1326
-                break;
1326
+				break;
1327 1327
 
1328
-            case 'password':
1329
-                ?>
1328
+			case 'password':
1329
+				?>
1330 1330
                 <tr valign="top">
1331 1331
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1332 1332
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1335,42 +1335,42 @@  discard block
 block discarded – undo
1335 1335
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1336 1336
                                            style="<?php echo esc_attr($value['css']); ?>"
1337 1337
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1338
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1339
-                                           } else {
1340
-                                               echo esc_attr($value['std']);
1341
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1338
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1339
+										   } else {
1340
+											   echo esc_attr($value['std']);
1341
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1342 1342
                 </tr><?php
1343
-                break;
1343
+				break;
1344 1344
 
1345
-            case 'html_content':
1346
-                ?>
1345
+			case 'html_content':
1346
+				?>
1347 1347
                 <tr valign="top">
1348 1348
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1349 1349
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
1350 1350
                 </tr><?php
1351
-                break;
1351
+				break;
1352 1352
 
1353
-            case 'color' :
1354
-                ?>
1353
+			case 'color' :
1354
+				?>
1355 1355
                 <tr valign="top">
1356 1356
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1357 1357
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1358 1358
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
1359 1359
                                            style="<?php echo esc_attr($value['css']); ?>"
1360 1360
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1361
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1362
-                                           } else {
1363
-                                               echo esc_attr($value['std']);
1364
-                                           } ?>" class="colorpick"/> <span
1361
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1362
+										   } else {
1363
+											   echo esc_attr($value['std']);
1364
+										   } ?>" class="colorpick"/> <span
1365 1365
                         class="description"><?php echo $value['desc']; ?></span>
1366 1366
 
1367 1367
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
1368 1368
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
1369 1369
                 </td>
1370 1370
                 </tr><?php
1371
-                break;
1372
-            case 'image_width' :
1373
-                ?>
1371
+				break;
1372
+			case 'image_width' :
1373
+				?>
1374 1374
                 <tr valign="top">
1375 1375
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1376 1376
                 <td class="forminp">
@@ -1392,11 +1392,11 @@  discard block
 block discarded – undo
1392 1392
 
1393 1393
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1394 1394
                 </tr><?php
1395
-                break;
1396
-            case 'select':
1397
-                $option_value = get_option($value['id']);
1398
-                $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1399
-                ?>
1395
+				break;
1396
+			case 'select':
1397
+				$option_value = get_option($value['id']);
1398
+				$option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1399
+				?>
1400 1400
                 <tr valign="top">
1401 1401
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1402 1402
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1405,33 +1405,33 @@  discard block
 block discarded – undo
1405 1405
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1406 1406
                                             option-ajaxchosen="false">
1407 1407
                         <?php
1408
-                        foreach ($value['options'] as $key => $val) {
1409
-                            $geodir_select_value = '';
1410
-                            if ($option_value != '') {
1411
-                                if ($option_value != '' && $option_value == $key)
1412
-                                    $geodir_select_value = ' selected="selected" ';
1413
-                            } else {
1414
-                                if ($value['std'] == $key)
1415
-                                    $geodir_select_value = ' selected="selected" ';
1416
-                            }
1417
-                            ?>
1408
+						foreach ($value['options'] as $key => $val) {
1409
+							$geodir_select_value = '';
1410
+							if ($option_value != '') {
1411
+								if ($option_value != '' && $option_value == $key)
1412
+									$geodir_select_value = ' selected="selected" ';
1413
+							} else {
1414
+								if ($value['std'] == $key)
1415
+									$geodir_select_value = ' selected="selected" ';
1416
+							}
1417
+							?>
1418 1418
                             <option
1419 1419
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option>
1420 1420
                         <?php
1421
-                        }
1422
-                        ?>
1421
+						}
1422
+						?>
1423 1423
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1424 1424
                 </td>
1425 1425
                 </tr><?php
1426
-                break;
1426
+				break;
1427 1427
 
1428
-            case 'multiselect':
1429
-                $option_values = get_option($value['id']);
1430
-                if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1431
-                   $option_values = $value['std'];
1432
-                }
1433
-                $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1434
-                ?>
1428
+			case 'multiselect':
1429
+				$option_values = get_option($value['id']);
1430
+				if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1431
+				   $option_values = $value['std'];
1432
+				}
1433
+				$option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1434
+				?>
1435 1435
                 <tr valign="top">
1436 1436
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1437 1437
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -1441,25 +1441,25 @@  discard block
 block discarded – undo
1441 1441
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1442 1442
                                             option-ajaxchosen="false">
1443 1443
                         <?php
1444
-                        foreach ($value['options'] as $key => $val) {
1445
-                            if (strpos($key, 'optgroup_start-') === 0) {
1446
-                                ?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1447
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
1448
-                                ?></optgroup><?php
1449
-                            } else {
1450
-                                ?>
1444
+						foreach ($value['options'] as $key => $val) {
1445
+							if (strpos($key, 'optgroup_start-') === 0) {
1446
+								?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1447
+							} else if (strpos($key, 'optgroup_end-') === 0) {
1448
+								?></optgroup><?php
1449
+							} else {
1450
+								?>
1451 1451
                                 <option
1452 1452
                                     value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1453 1453
                             <?php
1454
-                            }
1455
-                        }
1456
-                        ?>
1454
+							}
1455
+						}
1456
+						?>
1457 1457
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1458 1458
                 </td>
1459 1459
                 </tr><?php
1460
-                break;
1461
-            case 'file':
1462
-                ?>
1460
+				break;
1461
+			case 'file':
1462
+				?>
1463 1463
                 <tr valign="top">
1464 1464
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1465 1465
                 <td class="forminp">
@@ -1479,87 +1479,87 @@  discard block
 block discarded – undo
1479 1479
                     <?php } ?>
1480 1480
                 </td>
1481 1481
                 </tr><?php
1482
-                break;
1483
-            case 'map_default_settings' :
1484
-                ?>
1482
+				break;
1483
+			case 'map_default_settings' :
1484
+				?>
1485 1485
 
1486 1486
                 <tr valign="top">
1487 1487
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1488 1488
                     <td width="60%">
1489 1489
                         <select name="geodir_default_map_language" style="width:60%">
1490 1490
                             <?php
1491
-                            $arr_map_langages = array(
1492
-                                'ar' => __('ARABIC', 'geodirectory'),
1493
-                                'eu' => __('BASQUE', 'geodirectory'),
1494
-                                'bg' => __('BULGARIAN', 'geodirectory'),
1495
-                                'bn' => __('BENGALI', 'geodirectory'),
1496
-                                'ca' => __('CATALAN', 'geodirectory'),
1497
-                                'cs' => __('CZECH', 'geodirectory'),
1498
-                                'da' => __('DANISH', 'geodirectory'),
1499
-                                'de' => __('GERMAN', 'geodirectory'),
1500
-                                'el' => __('GREEK', 'geodirectory'),
1501
-                                'en' => __('ENGLISH', 'geodirectory'),
1502
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1503
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1504
-                                'es' => __('SPANISH', 'geodirectory'),
1505
-                                'eu' => __('BASQUE', 'geodirectory'),
1506
-                                'fa' => __('FARSI', 'geodirectory'),
1507
-                                'fi' => __('FINNISH', 'geodirectory'),
1508
-                                'fil' => __('FILIPINO', 'geodirectory'),
1509
-                                'fr' => __('FRENCH', 'geodirectory'),
1510
-                                'gl' => __('GALICIAN', 'geodirectory'),
1511
-                                'gu' => __('GUJARATI', 'geodirectory'),
1512
-                                'hi' => __('HINDI', 'geodirectory'),
1513
-                                'hr' => __('CROATIAN', 'geodirectory'),
1514
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
1515
-                                'id' => __('INDONESIAN', 'geodirectory'),
1516
-                                'it' => __('ITALIAN', 'geodirectory'),
1517
-                                'iw' => __('HEBREW', 'geodirectory'),
1518
-                                'ja' => __('JAPANESE', 'geodirectory'),
1519
-                                'kn' => __('KANNADA', 'geodirectory'),
1520
-                                'ko' => __('KOREAN', 'geodirectory'),
1521
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
1522
-                                'lv' => __('LATVIAN', 'geodirectory'),
1523
-                                'ml' => __('MALAYALAM', 'geodirectory'),
1524
-                                'mr' => __('MARATHI', 'geodirectory'),
1525
-                                'nl' => __('DUTCH', 'geodirectory'),
1526
-                                'no' => __('NORWEGIAN', 'geodirectory'),
1527
-                                'pl' => __('POLISH', 'geodirectory'),
1528
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
1529
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1530
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1531
-                                'ro' => __('ROMANIAN', 'geodirectory'),
1532
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1533
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1534
-                                'sk' => __('SLOVAK', 'geodirectory'),
1535
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
1536
-                                'sr' => __('SERBIAN', 'geodirectory'),
1537
-                                'sv' => __('	SWEDISH', 'geodirectory'),
1538
-                                'tl' => __('TAGALOG', 'geodirectory'),
1539
-                                'ta' => __('TAMIL', 'geodirectory'),
1540
-                                'te' => __('TELUGU', 'geodirectory'),
1541
-                                'th' => __('THAI', 'geodirectory'),
1542
-                                'tr' => __('TURKISH', 'geodirectory'),
1543
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
1544
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
1545
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1546
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1547
-                            );
1548
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
1549
-                            if (empty($geodir_default_map_language))
1550
-                                $geodir_default_map_language = 'en';
1551
-                            foreach ($arr_map_langages as $language_key => $language_txt) {
1552
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1553
-                                    $geodir_default_language_selected = "selected='selected'";
1554
-                                else
1555
-                                    $geodir_default_language_selected = '';
1556
-
1557
-                                ?>
1491
+							$arr_map_langages = array(
1492
+								'ar' => __('ARABIC', 'geodirectory'),
1493
+								'eu' => __('BASQUE', 'geodirectory'),
1494
+								'bg' => __('BULGARIAN', 'geodirectory'),
1495
+								'bn' => __('BENGALI', 'geodirectory'),
1496
+								'ca' => __('CATALAN', 'geodirectory'),
1497
+								'cs' => __('CZECH', 'geodirectory'),
1498
+								'da' => __('DANISH', 'geodirectory'),
1499
+								'de' => __('GERMAN', 'geodirectory'),
1500
+								'el' => __('GREEK', 'geodirectory'),
1501
+								'en' => __('ENGLISH', 'geodirectory'),
1502
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1503
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1504
+								'es' => __('SPANISH', 'geodirectory'),
1505
+								'eu' => __('BASQUE', 'geodirectory'),
1506
+								'fa' => __('FARSI', 'geodirectory'),
1507
+								'fi' => __('FINNISH', 'geodirectory'),
1508
+								'fil' => __('FILIPINO', 'geodirectory'),
1509
+								'fr' => __('FRENCH', 'geodirectory'),
1510
+								'gl' => __('GALICIAN', 'geodirectory'),
1511
+								'gu' => __('GUJARATI', 'geodirectory'),
1512
+								'hi' => __('HINDI', 'geodirectory'),
1513
+								'hr' => __('CROATIAN', 'geodirectory'),
1514
+								'hu' => __('HUNGARIAN', 'geodirectory'),
1515
+								'id' => __('INDONESIAN', 'geodirectory'),
1516
+								'it' => __('ITALIAN', 'geodirectory'),
1517
+								'iw' => __('HEBREW', 'geodirectory'),
1518
+								'ja' => __('JAPANESE', 'geodirectory'),
1519
+								'kn' => __('KANNADA', 'geodirectory'),
1520
+								'ko' => __('KOREAN', 'geodirectory'),
1521
+								'lt' => __('LITHUANIAN', 'geodirectory'),
1522
+								'lv' => __('LATVIAN', 'geodirectory'),
1523
+								'ml' => __('MALAYALAM', 'geodirectory'),
1524
+								'mr' => __('MARATHI', 'geodirectory'),
1525
+								'nl' => __('DUTCH', 'geodirectory'),
1526
+								'no' => __('NORWEGIAN', 'geodirectory'),
1527
+								'pl' => __('POLISH', 'geodirectory'),
1528
+								'pt' => __('PORTUGUESE', 'geodirectory'),
1529
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1530
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1531
+								'ro' => __('ROMANIAN', 'geodirectory'),
1532
+								'ru' => __('RUSSIAN', 'geodirectory'),
1533
+								'ru' => __('RUSSIAN', 'geodirectory'),
1534
+								'sk' => __('SLOVAK', 'geodirectory'),
1535
+								'sl' => __('SLOVENIAN', 'geodirectory'),
1536
+								'sr' => __('SERBIAN', 'geodirectory'),
1537
+								'sv' => __('	SWEDISH', 'geodirectory'),
1538
+								'tl' => __('TAGALOG', 'geodirectory'),
1539
+								'ta' => __('TAMIL', 'geodirectory'),
1540
+								'te' => __('TELUGU', 'geodirectory'),
1541
+								'th' => __('THAI', 'geodirectory'),
1542
+								'tr' => __('TURKISH', 'geodirectory'),
1543
+								'uk' => __('UKRAINIAN', 'geodirectory'),
1544
+								'vi' => __('VIETNAMESE', 'geodirectory'),
1545
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1546
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1547
+							);
1548
+							$geodir_default_map_language = get_option('geodir_default_map_language');
1549
+							if (empty($geodir_default_map_language))
1550
+								$geodir_default_map_language = 'en';
1551
+							foreach ($arr_map_langages as $language_key => $language_txt) {
1552
+								if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1553
+									$geodir_default_language_selected = "selected='selected'";
1554
+								else
1555
+									$geodir_default_language_selected = '';
1556
+
1557
+								?>
1558 1558
                                 <option
1559 1559
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
1560 1560
 
1561 1561
                             <?php }
1562
-                            ?>
1562
+							?>
1563 1563
                         </select>
1564 1564
                     </td>
1565 1565
                 </tr>
@@ -1570,46 +1570,46 @@  discard block
 block discarded – undo
1570 1570
                     <td width="60%">
1571 1571
                         <select name="geodir_default_map_search_pt" style="width:60%">
1572 1572
                             <?php
1573
-                            $post_types = geodir_get_posttypes('array');
1574
-                            $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1575
-                            if (empty($geodir_default_map_search_pt))
1576
-                                $geodir_default_map_search_pt = 'gd_place';
1577
-                            if (is_array($post_types)) {
1578
-                                foreach ($post_types as $key => $post_types_obj) {
1579
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1580
-                                        $geodir_search_pt_selected = "selected='selected'";
1581
-                                    else
1582
-                                        $geodir_search_pt_selected = '';
1583
-
1584
-                                    ?>
1573
+							$post_types = geodir_get_posttypes('array');
1574
+							$geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1575
+							if (empty($geodir_default_map_search_pt))
1576
+								$geodir_default_map_search_pt = 'gd_place';
1577
+							if (is_array($post_types)) {
1578
+								foreach ($post_types as $key => $post_types_obj) {
1579
+									if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1580
+										$geodir_search_pt_selected = "selected='selected'";
1581
+									else
1582
+										$geodir_search_pt_selected = '';
1583
+
1584
+									?>
1585 1585
                                     <option
1586 1586
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option>
1587 1587
 
1588 1588
                                 <?php }
1589 1589
 
1590
-                            }
1590
+							}
1591 1591
 
1592
-                            ?>
1592
+							?>
1593 1593
                         </select>
1594 1594
                     </td>
1595 1595
                 </tr>
1596 1596
 
1597 1597
                 <?php
1598
-                break;
1598
+				break;
1599 1599
 
1600
-            case 'map':
1601
-                ?>
1600
+			case 'map':
1601
+				?>
1602 1602
                 <tr valign="top">
1603 1603
                     <td class="forminp">
1604 1604
                         <?php
1605
-                        global $post_cat, $cat_display;
1606
-                        $post_types = geodir_get_posttypes('object');
1607
-                        $cat_display = 'checkbox';
1608
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1609
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
1610
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1611
-                        $count = 1;
1612
-                        ?>
1605
+						global $post_cat, $cat_display;
1606
+						$post_types = geodir_get_posttypes('object');
1607
+						$cat_display = 'checkbox';
1608
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
1609
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
1610
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1611
+						$count = 1;
1612
+						?>
1613 1613
                         <table width="70%" class="widefat">
1614 1614
                             <thead>
1615 1615
                             <tr>
@@ -1618,18 +1618,18 @@  discard block
 block discarded – undo
1618 1618
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
1619 1619
                             </tr>
1620 1620
                             <?php
1621
-                            $gd_categs = $gd_cats;
1622
-                            foreach ($post_types as $key => $post_types_obj) :
1623
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1624
-                                $gd_taxonomy = geodir_get_taxonomies($key);
1625
-                                if ($gd_cats_upgrade) {
1626
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1627
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1628
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1629
-                                }
1630
-                                $post_cat = implode(',', $gd_cats);
1631
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1632
-                                ?>
1621
+							$gd_categs = $gd_cats;
1622
+							foreach ($post_types as $key => $post_types_obj) :
1623
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1624
+								$gd_taxonomy = geodir_get_taxonomies($key);
1625
+								if ($gd_cats_upgrade) {
1626
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1627
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1628
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1629
+								}
1630
+								$post_cat = implode(',', $gd_cats);
1631
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1632
+								?>
1633 1633
                                 <tr>
1634 1634
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
1635 1635
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -1650,19 +1650,19 @@  discard block
 block discarded – undo
1650 1650
                     </td>
1651 1651
                 </tr>
1652 1652
                 <?php
1653
-                break;
1653
+				break;
1654 1654
 
1655
-            case 'checkbox' :
1655
+			case 'checkbox' :
1656 1656
 
1657
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1658
-                    ?>
1657
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1658
+					?>
1659 1659
                     <tr valign="top">
1660 1660
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1661 1661
                     <td class="forminp">
1662 1662
                 <?php
1663
-                endif;
1663
+				endif;
1664 1664
 
1665
-                ?>
1665
+				?>
1666 1666
                 <fieldset>
1667 1667
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1668 1668
                     <label for="<?php echo $value['id'] ?>">
@@ -1672,49 +1672,49 @@  discard block
 block discarded – undo
1672 1672
                 </fieldset>
1673 1673
                 <?php
1674 1674
 
1675
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1676
-                    ?>
1675
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1676
+					?>
1677 1677
                     </td>
1678 1678
                     </tr>
1679 1679
                 <?php
1680
-                endif;
1680
+				endif;
1681 1681
 
1682
-                break;
1682
+				break;
1683 1683
 
1684
-            case 'radio' :
1684
+			case 'radio' :
1685 1685
 
1686
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1687
-                    ?>
1686
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1687
+					?>
1688 1688
                     <tr valign="top">
1689 1689
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1690 1690
                     <td class="forminp">
1691 1691
                 <?php
1692
-                endif;
1692
+				endif;
1693 1693
 
1694
-                ?>
1694
+				?>
1695 1695
                 <fieldset>
1696 1696
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1697 1697
                     <label for="<?php echo $value['id'];?>">
1698 1698
                         <input name="<?php echo esc_attr($value['id']); ?>"
1699 1699
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1700 1700
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1701
-                            echo 'checked="checked"';
1702
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1701
+							echo 'checked="checked"';
1702
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1703 1703
                         <?php echo $value['desc']; ?></label><br>
1704 1704
                 </fieldset>
1705 1705
                 <?php
1706 1706
 
1707
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1708
-                    ?>
1707
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1708
+					?>
1709 1709
                     </td>
1710 1710
                     </tr>
1711 1711
                 <?php
1712
-                endif;
1712
+				endif;
1713 1713
 
1714
-                break;
1714
+				break;
1715 1715
 
1716
-            case 'textarea':
1717
-                ?>
1716
+			case 'textarea':
1717
+				?>
1718 1718
                 <tr valign="top">
1719 1719
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1720 1720
                 <td class="forminp">
@@ -1727,32 +1727,32 @@  discard block
 block discarded – undo
1727 1727
 
1728 1728
                 </td>
1729 1729
                 </tr><?php
1730
-                break;
1730
+				break;
1731 1731
 
1732
-            case 'editor':
1733
-                ?>
1732
+			case 'editor':
1733
+				?>
1734 1734
                 <tr valign="top">
1735 1735
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1736 1736
                 <td class="forminp"><?php
1737 1737
 
1738
-                    $content = '';
1739
-                    if (get_option($value['id']))
1740
-                        $content = stripslashes(get_option($value['id']));
1741
-                    else
1742
-                        $content = $value['std'];
1738
+					$content = '';
1739
+					if (get_option($value['id']))
1740
+						$content = stripslashes(get_option($value['id']));
1741
+					else
1742
+						$content = $value['std'];
1743 1743
 
1744
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1744
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1745 1745
 
1746
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
1746
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
1747 1747
 
1748
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
1748
+					?> <span class="description"><?php echo $value['desc'] ?></span>
1749 1749
 
1750 1750
                 </td>
1751 1751
                 </tr><?php
1752
-                break;
1752
+				break;
1753 1753
 
1754
-            case 'single_select_page' :
1755
-                // WPML
1754
+			case 'single_select_page' :
1755
+				// WPML
1756 1756
 				$switch_lang = false;
1757 1757
 				$disabled = '';
1758 1758
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -1770,18 +1770,18 @@  discard block
 block discarded – undo
1770 1770
 				//
1771 1771
 				$page_setting = (int)get_option($value['id']);
1772 1772
 
1773
-                $args = array('name' => $value['id'],
1774
-                    'id' => $value['id'],
1775
-                    'sort_column' => 'menu_order',
1776
-                    'sort_order' => 'ASC',
1777
-                    'show_option_none' => ' ',
1778
-                    'class' => $value['class'],
1779
-                    'echo' => false,
1780
-                    'selected' => $page_setting);
1773
+				$args = array('name' => $value['id'],
1774
+					'id' => $value['id'],
1775
+					'sort_column' => 'menu_order',
1776
+					'sort_order' => 'ASC',
1777
+					'show_option_none' => ' ',
1778
+					'class' => $value['class'],
1779
+					'echo' => false,
1780
+					'selected' => $page_setting);
1781 1781
 
1782
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1782
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1783 1783
 
1784
-                ?>
1784
+				?>
1785 1785
                 <tr valign="top" class="single_select_page">
1786 1786
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1787 1787
                 <td class="forminp">
@@ -1792,18 +1792,18 @@  discard block
 block discarded – undo
1792 1792
 				if ($switch_lang) {
1793 1793
 					$sitepress->switch_lang($switch_lang, true);
1794 1794
 				}
1795
-                break;
1796
-            case 'single_select_country' :
1797
-                $countries = $geodirectory->countries->countries;
1798
-                $country_setting = (string)get_option($value['id']);
1799
-                if (strstr($country_setting, ':')) :
1800
-                    $country = current(explode(':', $country_setting));
1801
-                    $state = end(explode(':', $country_setting));
1802
-                else :
1803
-                    $country = $country_setting;
1804
-                    $state = '*';
1805
-                endif;
1806
-                ?>
1795
+				break;
1796
+			case 'single_select_country' :
1797
+				$countries = $geodirectory->countries->countries;
1798
+				$country_setting = (string)get_option($value['id']);
1799
+				if (strstr($country_setting, ':')) :
1800
+					$country = current(explode(':', $country_setting));
1801
+					$state = end(explode(':', $country_setting));
1802
+				else :
1803
+					$country = $country_setting;
1804
+					$state = '*';
1805
+				endif;
1806
+				?>
1807 1807
                 <tr valign="top">
1808 1808
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
1809 1809
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1814,12 +1814,12 @@  discard block
 block discarded – undo
1814 1814
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1815 1815
                 </td>
1816 1816
                 </tr><?php
1817
-                break;
1818
-            case 'multi_select_countries' :
1819
-                $countries = $geodirectory->countries->countries;
1820
-                asort($countries);
1821
-                $selections = (array)get_option($value['id']);
1822
-                ?>
1817
+				break;
1818
+			case 'multi_select_countries' :
1819
+				$countries = $geodirectory->countries->countries;
1820
+				asort($countries);
1821
+				$selections = (array)get_option($value['id']);
1822
+				?>
1823 1823
                 <tr valign="top">
1824 1824
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1825 1825
                 <td class="forminp">
@@ -1827,22 +1827,22 @@  discard block
 block discarded – undo
1827 1827
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1828 1828
                             title="Country" class="chosen_select">
1829 1829
                         <?php
1830
-                        if ($countries) foreach ($countries as $key => $val) :
1831
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1832
-                        endforeach;
1833
-                        ?>
1830
+						if ($countries) foreach ($countries as $key => $val) :
1831
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1832
+						endforeach;
1833
+						?>
1834 1834
                     </select>
1835 1835
                 </td>
1836 1836
                 </tr>
1837 1837
 
1838 1838
                 <?php
1839 1839
 
1840
-                break;
1840
+				break;
1841 1841
 
1842
-            case 'google_analytics' :
1843
-                $selections = (array)get_option($value['id']);
1844
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1845
-                    ?>
1842
+			case 'google_analytics' :
1843
+				$selections = (array)get_option($value['id']);
1844
+				if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1845
+					?>
1846 1846
                     <tr valign="top">
1847 1847
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1848 1848
                         <td class="forminp">
@@ -1850,19 +1850,19 @@  discard block
 block discarded – undo
1850 1850
 
1851 1851
                             <?php
1852 1852
 
1853
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1854
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1855
-                            $state = "&state=123";//any string
1856
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1857
-                            $response_type = "&response_type=code";
1858
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1859
-                            $access_type = "&access_type=offline";
1860
-                            $approval_prompt = "&approval_prompt=force";
1853
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1854
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1855
+							$state = "&state=123";//any string
1856
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1857
+							$response_type = "&response_type=code";
1858
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
1859
+							$access_type = "&access_type=offline";
1860
+							$approval_prompt = "&approval_prompt=force";
1861 1861
 
1862
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1862
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1863 1863
 
1864 1864
 
1865
-                            ?>
1865
+							?>
1866 1866
                             <script>
1867 1867
                                 function gd_ga_popup() {
1868 1868
                                     var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
@@ -1877,47 +1877,47 @@  discard block
 block discarded – undo
1877 1877
                             </script>
1878 1878
 
1879 1879
                             <?php
1880
-                            if (get_option('gd_ga_refresh_token')) {
1881
-                                ?>
1880
+							if (get_option('gd_ga_refresh_token')) {
1881
+								?>
1882 1882
                                 <span class="button-primary"
1883 1883
                                       onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
1884 1884
                                 <span
1885 1885
                                     style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1886 1886
                             <?php
1887
-                            } else {
1888
-                                ?>
1887
+							} else {
1888
+								?>
1889 1889
                                 <span class="button-primary"
1890 1890
                                       onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1891 1891
                             <?php
1892
-                            }
1893
-                            ?>
1892
+							}
1893
+							?>
1894 1894
                         </td>
1895 1895
                     </tr>
1896 1896
 
1897 1897
                 <?php
1898
-                }
1898
+				}
1899 1899
 
1900
-                break;
1900
+				break;
1901 1901
 
1902
-            case 'field_seperator' :
1902
+			case 'field_seperator' :
1903 1903
 
1904
-                ?>
1904
+				?>
1905 1905
                 <tr valign="top">
1906 1906
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
1907 1907
                 </tr>
1908 1908
                 <?php
1909 1909
 
1910
-                break;
1910
+				break;
1911 1911
 
1912
-        endswitch;
1912
+		endswitch;
1913 1913
 
1914
-    endforeach;
1914
+	endforeach;
1915 1915
 
1916
-    if ($first_title === false) {
1917
-        echo "</div>";
1918
-    }
1916
+	if ($first_title === false) {
1917
+		echo "</div>";
1918
+	}
1919 1919
 
1920
-    ?>
1920
+	?>
1921 1921
 
1922 1922
     <script type="text/javascript">
1923 1923
 
@@ -1977,33 +1977,33 @@  discard block
 block discarded – undo
1977 1977
  */
1978 1978
 function geodir_post_info_setting()
1979 1979
 {
1980
-    global $post, $post_id;
1981
-
1982
-    $post_type = get_post_type();
1983
-
1984
-    $package_info = array();
1985
-
1986
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1987
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1988
-    echo '<div id="geodir_wrapper">';
1989
-    /**
1990
-     * Called before the GD custom fields are output in the wp-admin area.
1991
-     *
1992
-     * @since 1.0.0
1993
-     * @see 'geodir_after_default_field_in_meta_box'
1994
-     */
1995
-    do_action('geodir_before_default_field_in_meta_box');
1996
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
1997
-    // to display all fields in one information box
1998
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
1999
-    /**
2000
-     * Called after the GD custom fields are output in the wp-admin area.
2001
-     *
2002
-     * @since 1.0.0
2003
-     * @see 'geodir_before_default_field_in_meta_box'
2004
-     */
2005
-    do_action('geodir_after_default_field_in_meta_box');
2006
-    echo '</div>';
1980
+	global $post, $post_id;
1981
+
1982
+	$post_type = get_post_type();
1983
+
1984
+	$package_info = array();
1985
+
1986
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1987
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1988
+	echo '<div id="geodir_wrapper">';
1989
+	/**
1990
+	 * Called before the GD custom fields are output in the wp-admin area.
1991
+	 *
1992
+	 * @since 1.0.0
1993
+	 * @see 'geodir_after_default_field_in_meta_box'
1994
+	 */
1995
+	do_action('geodir_before_default_field_in_meta_box');
1996
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
1997
+	// to display all fields in one information box
1998
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
1999
+	/**
2000
+	 * Called after the GD custom fields are output in the wp-admin area.
2001
+	 *
2002
+	 * @since 1.0.0
2003
+	 * @see 'geodir_before_default_field_in_meta_box'
2004
+	 */
2005
+	do_action('geodir_after_default_field_in_meta_box');
2006
+	echo '</div>';
2007 2007
 }
2008 2008
 
2009 2009
 /**
@@ -2016,18 +2016,18 @@  discard block
 block discarded – undo
2016 2016
  */
2017 2017
 function geodir_post_addinfo_setting()
2018 2018
 {
2019
-    global $post, $post_id;
2019
+	global $post, $post_id;
2020 2020
 
2021
-    $post_type = get_post_type();
2021
+	$post_type = get_post_type();
2022 2022
 
2023
-    $package_info = array();
2023
+	$package_info = array();
2024 2024
 
2025
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2025
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2026 2026
 
2027
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2028
-    echo '<div id="geodir_wrapper">';
2029
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2030
-    echo '</div>';
2027
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2028
+	echo '<div id="geodir_wrapper">';
2029
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2030
+	echo '</div>';
2031 2031
 
2032 2032
 }
2033 2033
 
@@ -2041,60 +2041,60 @@  discard block
 block discarded – undo
2041 2041
  */
2042 2042
 function geodir_post_attachments()
2043 2043
 {
2044
-    global $post, $post_id;
2044
+	global $post, $post_id;
2045 2045
 
2046
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2046
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2047 2047
 
2048
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
2049
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2050
-        geodir_show_featured_image($post_id, 'thumbnail');
2051
-    }
2048
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
2049
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2050
+		geodir_show_featured_image($post_id, 'thumbnail');
2051
+	}
2052 2052
 
2053
-    $image_limit = 0;
2053
+	$image_limit = 0;
2054 2054
 
2055
-    ?>
2055
+	?>
2056 2056
 
2057 2057
 
2058 2058
     <h5 class="form_title">
2059 2059
         <?php if ($image_limit != 0 && $image_limit == 1) {
2060
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2061
-        } ?>
2060
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2061
+		} ?>
2062 2062
         <?php if ($image_limit != 0 && $image_limit > 1) {
2063
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2064
-        } ?>
2063
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2064
+		} ?>
2065 2065
         <?php if ($image_limit == 0) {
2066
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2067
-        } ?>
2066
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2067
+		} ?>
2068 2068
     </h5>
2069 2069
 
2070 2070
 
2071 2071
     <?php
2072 2072
 
2073
-    $curImages = geodir_get_images($post_id);
2074
-    $place_img_array = array();
2073
+	$curImages = geodir_get_images($post_id);
2074
+	$place_img_array = array();
2075 2075
 
2076
-    if (!empty($curImages)):
2077
-        foreach ($curImages as $p_img):
2078
-            $place_img_array[] = $p_img->src;
2079
-        endforeach;
2080
-    endif;
2076
+	if (!empty($curImages)):
2077
+		foreach ($curImages as $p_img):
2078
+			$place_img_array[] = $p_img->src;
2079
+		endforeach;
2080
+	endif;
2081 2081
 
2082
-    if (!empty($place_img_array))
2083
-        $curImages = implode(',', $place_img_array);
2082
+	if (!empty($place_img_array))
2083
+		$curImages = implode(',', $place_img_array);
2084 2084
 
2085 2085
 
2086
-    // adjust values here
2087
-    $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
2086
+	// adjust values here
2087
+	$id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
2088 2088
 
2089
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
2089
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
2090 2090
 
2091
-    $multiple = true; // allow multiple files upload
2091
+	$multiple = true; // allow multiple files upload
2092 2092
 
2093
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2093
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2094 2094
 
2095
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2095
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2096 2096
 
2097
-    ?>
2097
+	?>
2098 2098
 
2099 2099
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
2100 2100
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -2136,13 +2136,13 @@  discard block
 block discarded – undo
2136 2136
  */
2137 2137
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
2138 2138
 {
2139
-    $post_type = get_post_type($post_ID);
2139
+	$post_type = get_post_type($post_ID);
2140 2140
 
2141
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2142
-        if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
2143
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2144
-        }
2145
-    }
2141
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2142
+		if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
2143
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2144
+		}
2145
+	}
2146 2146
 }
2147 2147
 
2148 2148
 /**
@@ -2157,39 +2157,39 @@  discard block
 block discarded – undo
2157 2157
  */
2158 2158
 function geodir_notification_add_bcc_option($settings)
2159 2159
 {
2160
-    if (!empty($settings)) {
2161
-        $new_settings = array();
2162
-        foreach ($settings as $setting) {
2163
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2164
-                $geodir_bcc_listing_published_yes = array(
2165
-                    'name' => __('Listing published', 'geodirectory'),
2166
-                    'desc' => __('Yes', 'geodirectory'),
2167
-                    'id' => 'geodir_bcc_listing_published',
2168
-                    'std' => 'yes',
2169
-                    'type' => 'radio',
2170
-                    'value' => '1',
2171
-                    'radiogroup' => 'start'
2172
-                );
2173
-
2174
-                $geodir_bcc_listing_published_no = array(
2175
-                    'name' => __('Listing published', 'geodirectory'),
2176
-                    'desc' => __('No', 'geodirectory'),
2177
-                    'id' => 'geodir_bcc_listing_published',
2178
-                    'std' => 'yes',
2179
-                    'type' => 'radio',
2180
-                    'value' => '0',
2181
-                    'radiogroup' => 'end'
2182
-                );
2183
-
2184
-                $new_settings[] = $geodir_bcc_listing_published_yes;
2185
-                $new_settings[] = $geodir_bcc_listing_published_no;
2186
-            }
2187
-            $new_settings[] = $setting;
2188
-        }
2189
-        $settings = $new_settings;
2190
-    }
2160
+	if (!empty($settings)) {
2161
+		$new_settings = array();
2162
+		foreach ($settings as $setting) {
2163
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2164
+				$geodir_bcc_listing_published_yes = array(
2165
+					'name' => __('Listing published', 'geodirectory'),
2166
+					'desc' => __('Yes', 'geodirectory'),
2167
+					'id' => 'geodir_bcc_listing_published',
2168
+					'std' => 'yes',
2169
+					'type' => 'radio',
2170
+					'value' => '1',
2171
+					'radiogroup' => 'start'
2172
+				);
2173
+
2174
+				$geodir_bcc_listing_published_no = array(
2175
+					'name' => __('Listing published', 'geodirectory'),
2176
+					'desc' => __('No', 'geodirectory'),
2177
+					'id' => 'geodir_bcc_listing_published',
2178
+					'std' => 'yes',
2179
+					'type' => 'radio',
2180
+					'value' => '0',
2181
+					'radiogroup' => 'end'
2182
+				);
2183
+
2184
+				$new_settings[] = $geodir_bcc_listing_published_yes;
2185
+				$new_settings[] = $geodir_bcc_listing_published_no;
2186
+			}
2187
+			$new_settings[] = $setting;
2188
+		}
2189
+		$settings = $new_settings;
2190
+	}
2191 2191
 
2192
-    return $settings;
2192
+	return $settings;
2193 2193
 }
2194 2194
 
2195 2195
 
@@ -2204,19 +2204,19 @@  discard block
 block discarded – undo
2204 2204
  */
2205 2205
 function get_gd_theme_compat_callback()
2206 2206
 {
2207
-    global $wpdb;
2208
-    $themes = get_option('gd_theme_compats');
2209
-
2210
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2211
-        if (isset($_POST['export'])) {
2212
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2213
-        } else {
2214
-            echo json_encode($themes[$_POST['theme']]);
2215
-        }
2207
+	global $wpdb;
2208
+	$themes = get_option('gd_theme_compats');
2216 2209
 
2217
-    }
2210
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2211
+		if (isset($_POST['export'])) {
2212
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2213
+		} else {
2214
+			echo json_encode($themes[$_POST['theme']]);
2215
+		}
2216
+
2217
+	}
2218 2218
 
2219
-    die();
2219
+	die();
2220 2220
 }
2221 2221
 
2222 2222
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -2230,20 +2230,20 @@  discard block
 block discarded – undo
2230 2230
  */
2231 2231
 function get_gd_theme_compat_import_callback()
2232 2232
 {
2233
-    global $wpdb;
2234
-    $themes = get_option('gd_theme_compats');
2235
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2236
-        $json = json_decode(stripslashes($_POST['theme']), true);
2237
-        if (!empty($json) && is_array($json)) {
2238
-            $key = sanitize_text_field(key($json));
2239
-            $themes[$key] = $json[$key];
2240
-            update_option('gd_theme_compats', $themes);
2241
-            echo $key;
2242
-            die();
2243
-        }
2244
-    }
2245
-    echo '0';
2246
-    die();
2233
+	global $wpdb;
2234
+	$themes = get_option('gd_theme_compats');
2235
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2236
+		$json = json_decode(stripslashes($_POST['theme']), true);
2237
+		if (!empty($json) && is_array($json)) {
2238
+			$key = sanitize_text_field(key($json));
2239
+			$themes[$key] = $json[$key];
2240
+			update_option('gd_theme_compats', $themes);
2241
+			echo $key;
2242
+			die();
2243
+		}
2244
+	}
2245
+	echo '0';
2246
+	die();
2247 2247
 }
2248 2248
 
2249 2249
 
@@ -2256,39 +2256,39 @@  discard block
 block discarded – undo
2256 2256
  */
2257 2257
 function gd_set_theme_compat()
2258 2258
 {
2259
-    global $wpdb;
2260
-    $theme = wp_get_theme();
2259
+	global $wpdb;
2260
+	$theme = wp_get_theme();
2261 2261
 
2262
-    if ($theme->parent()) {
2263
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2264
-    } else {
2265
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
2266
-    }
2262
+	if ($theme->parent()) {
2263
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2264
+	} else {
2265
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
2266
+	}
2267 2267
 
2268
-    $theme_compats = get_option('gd_theme_compats');
2269
-    $current_compat = get_option('gd_theme_compat');
2270
-    $current_compat = str_replace("_custom", "", $current_compat);
2268
+	$theme_compats = get_option('gd_theme_compats');
2269
+	$current_compat = get_option('gd_theme_compat');
2270
+	$current_compat = str_replace("_custom", "", $current_compat);
2271 2271
 
2272
-    if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2273
-        return;
2274
-    }// if already running corect compat then bail
2272
+	if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2273
+		return;
2274
+	}// if already running corect compat then bail
2275 2275
 
2276
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2277
-        update_option('gd_theme_compat', $theme_name);
2278
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2276
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2277
+		update_option('gd_theme_compat', $theme_name);
2278
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2279 2279
 
2280
-        // if there are default options to set then set them
2281
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2280
+		// if there are default options to set then set them
2281
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2282 2282
 
2283
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2284
-                update_option($key, $val);
2285
-            }
2286
-        }
2283
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2284
+				update_option($key, $val);
2285
+			}
2286
+		}
2287 2287
 
2288
-    } else {
2289
-        update_option('gd_theme_compat', '');
2290
-        update_option('theme_compatibility_setting', '');
2291
-    }
2288
+	} else {
2289
+		update_option('gd_theme_compat', '');
2290
+		update_option('theme_compatibility_setting', '');
2291
+	}
2292 2292
 
2293 2293
 
2294 2294
 }
@@ -2303,9 +2303,9 @@  discard block
 block discarded – undo
2303 2303
  */
2304 2304
 function gd_check_avada_compat()
2305 2305
 {
2306
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2307
-        add_action('admin_notices', 'gd_avada_compat_warning');
2308
-    }
2306
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2307
+		add_action('admin_notices', 'gd_avada_compat_warning');
2308
+	}
2309 2309
 }
2310 2310
 
2311 2311
 
@@ -2318,22 +2318,22 @@  discard block
 block discarded – undo
2318 2318
 function gd_avada_compat_warning()
2319 2319
 {
2320 2320
 
2321
-    /*
2321
+	/*
2322 2322
     $msg_type = error
2323 2323
     $msg_type = updated fade
2324 2324
     $msg_type = update-nag
2325 2325
     */
2326 2326
 
2327
-    $plugin = 'avada-nag';
2328
-    $timestamp = 'avada-nag1234';
2329
-    $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
2330
-    echo '<div id="' . $timestamp . '"  class="error">';
2331
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2332
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2333
-    echo "<p>$message</p>";
2334
-    echo "</div>";
2327
+	$plugin = 'avada-nag';
2328
+	$timestamp = 'avada-nag1234';
2329
+	$message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
2330
+	echo '<div id="' . $timestamp . '"  class="error">';
2331
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2332
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2333
+	echo "<p>$message</p>";
2334
+	echo "</div>";
2335 2335
 
2336
-    ?>
2336
+	?>
2337 2337
     <script>
2338 2338
         function gdRemoveANotification($plugin, $timestamp) {
2339 2339
 
@@ -2401,10 +2401,10 @@  discard block
 block discarded – undo
2401 2401
  */
2402 2402
 function geodir_avada_remove_notification()
2403 2403
 {
2404
-    update_option('avada_nag', TRUE);
2404
+	update_option('avada_nag', TRUE);
2405 2405
 
2406
-    // Always die in functions echoing ajax content
2407
-    die();
2406
+	// Always die in functions echoing ajax content
2407
+	die();
2408 2408
 }
2409 2409
 
2410 2410
 
@@ -2463,7 +2463,7 @@  discard block
 block discarded – undo
2463 2463
 		// Don't allow same slug url for listing and location
2464 2464
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2465 2465
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2466
-        	wp_redirect($redirect_url);
2466
+			wp_redirect($redirect_url);
2467 2467
 			exit;
2468 2468
 		}
2469 2469
 		
@@ -2493,10 +2493,10 @@  discard block
 block discarded – undo
2493 2493
  * @package GeoDirectory
2494 2494
  */
2495 2495
 function geodir_hide_admin_preview_button() {
2496
-    global $post_type;
2497
-    $post_types = geodir_get_posttypes();
2498
-    if(in_array($post_type, $post_types))
2499
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2496
+	global $post_type;
2497
+	$post_types = geodir_get_posttypes();
2498
+	if(in_array($post_type, $post_types))
2499
+		echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2500 2500
 }
2501 2501
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2502 2502
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -2511,7 +2511,7 @@  discard block
 block discarded – undo
2511 2511
  */
2512 2512
 function geodir_import_export_tab( $tabs ) {
2513 2513
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2514
-    return $tabs;
2514
+	return $tabs;
2515 2515
 }
2516 2516
 
2517 2517
 /**
@@ -2526,26 +2526,26 @@  discard block
 block discarded – undo
2526 2526
 function geodir_import_export_page() {
2527 2527
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2528 2528
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2529
-    /**
2530
-     * Filter sample category data csv file url.
2531
-     *
2532
-     * @since 1.0.0
2533
-     * @package GeoDirectory
2534
-     *
2535
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
2536
-     */
2529
+	/**
2530
+	 * Filter sample category data csv file url.
2531
+	 *
2532
+	 * @since 1.0.0
2533
+	 * @package GeoDirectory
2534
+	 *
2535
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
2536
+	 */
2537 2537
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2538 2538
 	
2539 2539
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2540
-    /**
2541
-     * Filter sample post data csv file url.
2542
-     *
2543
-     * @since 1.0.0
2544
-     * @package GeoDirectory
2545
-     *
2546
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
2547
-     */
2548
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2540
+	/**
2541
+	 * Filter sample post data csv file url.
2542
+	 *
2543
+	 * @since 1.0.0
2544
+	 * @package GeoDirectory
2545
+	 *
2546
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
2547
+	 */
2548
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2549 2549
 	
2550 2550
 	$gd_posttypes = geodir_get_posttypes( 'array' );
2551 2551
 	
@@ -2568,14 +2568,14 @@  discard block
 block discarded – undo
2568 2568
 	$gd_chunksize_options[100000] = 100000;
2569 2569
 	 
2570 2570
 	 /**
2571
-     * Filter max entries per export csv file.
2572
-     *
2573
-     * @since 1.5.6
2574
-     * @package GeoDirectory
2575
-     *
2576
-     * @param string $gd_chunksize_options Entries options.
2577
-     */
2578
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2571
+	  * Filter max entries per export csv file.
2572
+	  *
2573
+	  * @since 1.5.6
2574
+	  * @package GeoDirectory
2575
+	  *
2576
+	  * @param string $gd_chunksize_options Entries options.
2577
+	  */
2578
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2579 2579
 	
2580 2580
 	$gd_chunksize_option = '';
2581 2581
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2591,12 +2591,12 @@  discard block
 block discarded – undo
2591 2591
   <div class="gd-content-heading">
2592 2592
 
2593 2593
   <?php
2594
-    ini_set('max_execution_time', 999999);
2595
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2596
-    ini_restore('max_execution_time');
2594
+	ini_set('max_execution_time', 999999);
2595
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2596
+	ini_restore('max_execution_time');
2597 2597
 
2598
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2599
-        ?>
2598
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2599
+		?>
2600 2600
 	<div id="gd_ie_reqs" class="metabox-holder">
2601 2601
       <div class="meta-box-sortables ui-sortable">
2602 2602
         <div class="postbox">
@@ -2765,7 +2765,7 @@  discard block
 block discarded – undo
2765 2765
 						 * Called just after the sample CSV download link.
2766 2766
 						 *
2767 2767
 						 * @since 1.0.0
2768
-                         * @package GeoDirectory
2768
+						 * @package GeoDirectory
2769 2769
 						 */
2770 2770
 						do_action('geodir_sample_cats_csv_download_link');
2771 2771
 						?>
@@ -2850,11 +2850,11 @@  discard block
 block discarded – undo
2850 2850
 	 *
2851 2851
 	 * Called after the last setting on the GD > Import & Export page.
2852 2852
 	 * @since 1.4.6
2853
-     * @package GeoDirectory
2853
+	 * @package GeoDirectory
2854 2854
 	 *
2855 2855
 	 * @param array $gd_posttypes GD post types.
2856
-     * @param array $gd_chunksize_options File chunk size options.
2857
-     * @param string $nonce Wordpress security token for GD import & export.
2856
+	 * @param array $gd_chunksize_options File chunk size options.
2857
+	 * @param string $nonce Wordpress security token for GD import & export.
2858 2858
 	 */
2859 2859
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2860 2860
 	?>
@@ -3519,44 +3519,44 @@  discard block
 block discarded – undo
3519 3519
 function geodir_init_filesystem()
3520 3520
 {
3521 3521
 
3522
-    if(!function_exists('get_filesystem_method')){
3523
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3524
-    }
3525
-    $access_type = get_filesystem_method();
3526
-    if ($access_type === 'direct') {
3527
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3528
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3529
-
3530
-        /* initialize the API */
3531
-        if (!WP_Filesystem($creds)) {
3532
-            /* any problems and we exit */
3533
-            //return '@@@3';
3534
-            return false;
3535
-        }
3536
-
3537
-        global $wp_filesystem;
3538
-        return $wp_filesystem;
3539
-        /* do our file manipulations below */
3540
-    } elseif (defined('FTP_USER')) {
3541
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3522
+	if(!function_exists('get_filesystem_method')){
3523
+		require_once(ABSPATH."/wp-admin/includes/file.php");
3524
+	}
3525
+	$access_type = get_filesystem_method();
3526
+	if ($access_type === 'direct') {
3527
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3528
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3529
+
3530
+		/* initialize the API */
3531
+		if (!WP_Filesystem($creds)) {
3532
+			/* any problems and we exit */
3533
+			//return '@@@3';
3534
+			return false;
3535
+		}
3542 3536
 
3543
-        /* initialize the API */
3544
-        if (!WP_Filesystem($creds)) {
3545
-            /* any problems and we exit */
3546
-            //return '@@@33';
3547
-            return false;
3548
-        }
3537
+		global $wp_filesystem;
3538
+		return $wp_filesystem;
3539
+		/* do our file manipulations below */
3540
+	} elseif (defined('FTP_USER')) {
3541
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3542
+
3543
+		/* initialize the API */
3544
+		if (!WP_Filesystem($creds)) {
3545
+			/* any problems and we exit */
3546
+			//return '@@@33';
3547
+			return false;
3548
+		}
3549 3549
 
3550
-        global $wp_filesystem;
3551
-        //return '@@@1';
3552
-        return $wp_filesystem;
3550
+		global $wp_filesystem;
3551
+		//return '@@@1';
3552
+		return $wp_filesystem;
3553 3553
 
3554
-    } else {
3555
-        //return '@@@2';
3556
-        /* don't have direct write access. Prompt user with our notice */
3557
-        add_action('admin_notice', 'geodir_filesystem_notice');
3558
-        return false;
3559
-    }
3554
+	} else {
3555
+		//return '@@@2';
3556
+		/* don't have direct write access. Prompt user with our notice */
3557
+		add_action('admin_notice', 'geodir_filesystem_notice');
3558
+		return false;
3559
+	}
3560 3560
 
3561 3561
 }
3562 3562
 
@@ -3574,10 +3574,10 @@  discard block
 block discarded – undo
3574 3574
  */
3575 3575
 function geodir_filesystem_notice()
3576 3576
 {   if ( defined( 'DOING_AJAX' ) ){return;}
3577
-    $access_type = get_filesystem_method();
3578
-    if ($access_type === 'direct') {
3579
-    } elseif (!defined('FTP_USER')) {
3580
-        ?>
3577
+	$access_type = get_filesystem_method();
3578
+	if ($access_type === 'direct') {
3579
+	} elseif (!defined('FTP_USER')) {
3580
+		?>
3581 3581
         <div class="error">
3582 3582
             <p><?php _e('GeoDirectory does not have access to your filesystem, thing like import/export will not work. Please define your details in wp-config.php as explained here', 'geodirectory'); ?>
3583 3583
                 <a target="_blank" href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants</a>
@@ -3603,1448 +3603,1448 @@  discard block
 block discarded – undo
3603 3603
  * @return string Json data.
3604 3604
  */
3605 3605
 function geodir_ajax_import_export() {
3606
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3606
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3607 3607
     
3608
-    error_reporting(0);
3608
+	error_reporting(0);
3609 3609
 
3610
-    // try to set higher limits for import
3611
-    $max_input_time = ini_get('max_input_time');
3612
-    $max_execution_time = ini_get('max_execution_time');
3613
-    $memory_limit= ini_get('memory_limit');
3610
+	// try to set higher limits for import
3611
+	$max_input_time = ini_get('max_input_time');
3612
+	$max_execution_time = ini_get('max_execution_time');
3613
+	$memory_limit= ini_get('memory_limit');
3614 3614
 
3615
-    if(!$max_input_time || $max_input_time<3000){
3616
-        ini_set('max_input_time', 3000);
3617
-    }
3615
+	if(!$max_input_time || $max_input_time<3000){
3616
+		ini_set('max_input_time', 3000);
3617
+	}
3618 3618
 
3619
-    if(!$max_execution_time || $max_execution_time<3000){
3620
-        ini_set('max_execution_time', 3000);
3621
-    }
3619
+	if(!$max_execution_time || $max_execution_time<3000){
3620
+		ini_set('max_execution_time', 3000);
3621
+	}
3622 3622
 
3623
-    if($memory_limit && str_replace('M','',$memory_limit)){
3624
-        if(str_replace('M','',$memory_limit)<256){
3625
-            ini_set('memory_limit', '256M');
3626
-        }
3627
-    }
3623
+	if($memory_limit && str_replace('M','',$memory_limit)){
3624
+		if(str_replace('M','',$memory_limit)<256){
3625
+			ini_set('memory_limit', '256M');
3626
+		}
3627
+	}
3628 3628
 
3629
-    $json = array();
3629
+	$json = array();
3630 3630
 
3631
-    if ( !current_user_can( 'manage_options' ) ) {
3632
-        wp_send_json( $json );
3633
-    }
3631
+	if ( !current_user_can( 'manage_options' ) ) {
3632
+		wp_send_json( $json );
3633
+	}
3634 3634
 
3635
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3636
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3637
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3635
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3636
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3637
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3638 3638
 
3639
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3640
-        wp_send_json( $json );
3641
-    }
3639
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3640
+		wp_send_json( $json );
3641
+	}
3642 3642
 
3643
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3644
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3645
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3646
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3643
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3644
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3645
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3646
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3647 3647
 
3648
-    $wp_filesystem = geodir_init_filesystem();
3649
-    if (!$wp_filesystem) {
3650
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3651
-        wp_send_json( $json );
3652
-    }
3648
+	$wp_filesystem = geodir_init_filesystem();
3649
+	if (!$wp_filesystem) {
3650
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3651
+		wp_send_json( $json );
3652
+	}
3653 3653
 
3654
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3655
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3656
-        wp_send_json( $json );
3657
-    }
3654
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3655
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3656
+		wp_send_json( $json );
3657
+	}
3658 3658
 
3659
-    $csv_file_dir = geodir_path_import_export( false );
3660
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3661
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3662
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3663
-            wp_send_json( $json );
3664
-        }
3665
-    }
3659
+	$csv_file_dir = geodir_path_import_export( false );
3660
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3661
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3662
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3663
+			wp_send_json( $json );
3664
+		}
3665
+	}
3666 3666
     
3667
-    $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3668
-    $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3669
-
3670
-    switch ( $task ) {
3671
-        case 'export_posts': {
3672
-            // WPML
3673
-            $is_wpml = geodir_is_wpml();
3674
-            if ($is_wpml) {
3675
-                global $sitepress;
3676
-                $active_lang = ICL_LANGUAGE_CODE;
3667
+	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3668
+	$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3669
+
3670
+	switch ( $task ) {
3671
+		case 'export_posts': {
3672
+			// WPML
3673
+			$is_wpml = geodir_is_wpml();
3674
+			if ($is_wpml) {
3675
+				global $sitepress;
3676
+				$active_lang = ICL_LANGUAGE_CODE;
3677 3677
                 
3678
-                $sitepress->switch_lang('all', true);
3679
-            }
3680
-            // WPML
3681
-            if ( $post_type == 'gd_event' ) {
3682
-                //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 );
3683
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3684
-            }
3685
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3686
-            $posts_count = geodir_get_posts_count( $post_type );
3687
-            $file_url_base = geodir_path_import_export() . '/';
3688
-            $file_url = $file_url_base . $file_name . '.csv';
3689
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3690
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3678
+				$sitepress->switch_lang('all', true);
3679
+			}
3680
+			// WPML
3681
+			if ( $post_type == 'gd_event' ) {
3682
+				//add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 );
3683
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3684
+			}
3685
+			$file_name = $post_type . '_' . date( 'dmyHi' );
3686
+			$posts_count = geodir_get_posts_count( $post_type );
3687
+			$file_url_base = geodir_path_import_export() . '/';
3688
+			$file_url = $file_url_base . $file_name . '.csv';
3689
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3690
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3691 3691
             
3692
-            $chunk_file_paths = array();
3692
+			$chunk_file_paths = array();
3693 3693
 
3694
-            if ( isset( $_REQUEST['_st'] ) ) {
3695
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3696
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3697
-                $percentage = min( $percentage, 100 );
3694
+			if ( isset( $_REQUEST['_st'] ) ) {
3695
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3696
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3697
+				$percentage = min( $percentage, 100 );
3698 3698
                 
3699
-                $json['percentage'] = $percentage;
3700
-                // WPML
3701
-                if ($is_wpml) {
3702
-                    $sitepress->switch_lang($active_lang, true);
3703
-                }
3704
-                // WPML
3705
-                wp_send_json( $json );
3706
-                exit;
3707
-            } else {
3708
-                if ( !$posts_count > 0 ) {
3709
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3710
-                } else {
3711
-                    $total_posts = $posts_count;
3712
-                    if ($chunk_per_page > $total_posts) {
3713
-                        $chunk_per_page = $total_posts;
3714
-                    }
3715
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3699
+				$json['percentage'] = $percentage;
3700
+				// WPML
3701
+				if ($is_wpml) {
3702
+					$sitepress->switch_lang($active_lang, true);
3703
+				}
3704
+				// WPML
3705
+				wp_send_json( $json );
3706
+				exit;
3707
+			} else {
3708
+				if ( !$posts_count > 0 ) {
3709
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3710
+				} else {
3711
+					$total_posts = $posts_count;
3712
+					if ($chunk_per_page > $total_posts) {
3713
+						$chunk_per_page = $total_posts;
3714
+					}
3715
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3716 3716
                     
3717
-                    $j = $chunk_page_no;
3718
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3717
+					$j = $chunk_page_no;
3718
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3719 3719
                     
3720
-                    $per_page = 500;
3721
-                    if ($per_page > $chunk_per_page) {
3722
-                        $per_page = $chunk_per_page;
3723
-                    }
3724
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3720
+					$per_page = 500;
3721
+					if ($per_page > $chunk_per_page) {
3722
+						$per_page = $chunk_per_page;
3723
+					}
3724
+					$total_pages = ceil( $chunk_per_page / $per_page );
3725 3725
                     
3726
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3727
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3726
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3727
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3728 3728
                         
3729
-                        $clear = $i == 0 ? true : false;
3730
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3731
-                    }
3729
+						$clear = $i == 0 ? true : false;
3730
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3731
+					}
3732 3732
                         
3733
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3734
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3735
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3736
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3737
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3733
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3734
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3735
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3736
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3737
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3738 3738
                         
3739
-                        $file_url = $file_url_base . $chunk_file_name;
3740
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3741
-                    }
3739
+						$file_url = $file_url_base . $chunk_file_name;
3740
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3741
+					}
3742 3742
                     
3743
-                    if ( !empty($chunk_file_paths) ) {
3744
-                        $json['total'] = $posts_count;
3745
-                        $json['files'] = $chunk_file_paths;
3746
-                    } else {
3747
-                        if ($j > 1) {
3748
-                            $json['total'] = $items_count;
3749
-                            $json['files'] = array();
3750
-                        } else {
3751
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3752
-                        }
3753
-                    }
3754
-                }
3755
-                // WPML
3756
-                if ($is_wpml) {
3757
-                    $sitepress->switch_lang($active_lang, true);
3758
-                }
3759
-                // WPML
3760
-                wp_send_json( $json );
3761
-            }
3762
-        }
3763
-        break;
3764
-        case 'export_cats': {
3765
-            // WPML
3766
-            $is_wpml = geodir_is_wpml();
3767
-            if ($is_wpml) {
3768
-                global $sitepress;
3769
-                $active_lang = ICL_LANGUAGE_CODE;
3743
+					if ( !empty($chunk_file_paths) ) {
3744
+						$json['total'] = $posts_count;
3745
+						$json['files'] = $chunk_file_paths;
3746
+					} else {
3747
+						if ($j > 1) {
3748
+							$json['total'] = $items_count;
3749
+							$json['files'] = array();
3750
+						} else {
3751
+							$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3752
+						}
3753
+					}
3754
+				}
3755
+				// WPML
3756
+				if ($is_wpml) {
3757
+					$sitepress->switch_lang($active_lang, true);
3758
+				}
3759
+				// WPML
3760
+				wp_send_json( $json );
3761
+			}
3762
+		}
3763
+		break;
3764
+		case 'export_cats': {
3765
+			// WPML
3766
+			$is_wpml = geodir_is_wpml();
3767
+			if ($is_wpml) {
3768
+				global $sitepress;
3769
+				$active_lang = ICL_LANGUAGE_CODE;
3770 3770
                 
3771
-                $sitepress->switch_lang('all', true);
3772
-            }
3773
-            // WPML
3774
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3771
+				$sitepress->switch_lang('all', true);
3772
+			}
3773
+			// WPML
3774
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
3775 3775
             
3776
-            $terms_count = geodir_get_terms_count( $post_type );
3777
-            $file_url_base = geodir_path_import_export() . '/';
3778
-            $file_url = $file_url_base . $file_name . '.csv';
3779
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3780
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3776
+			$terms_count = geodir_get_terms_count( $post_type );
3777
+			$file_url_base = geodir_path_import_export() . '/';
3778
+			$file_url = $file_url_base . $file_name . '.csv';
3779
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3780
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3781 3781
             
3782
-            $chunk_file_paths = array();
3782
+			$chunk_file_paths = array();
3783 3783
             
3784
-            if ( isset( $_REQUEST['_st'] ) ) {
3785
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3786
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3787
-                $percentage = min( $percentage, 100 );
3784
+			if ( isset( $_REQUEST['_st'] ) ) {
3785
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3786
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3787
+				$percentage = min( $percentage, 100 );
3788 3788
                 
3789
-                $json['percentage'] = $percentage;
3790
-                // WPML
3791
-                if ($is_wpml) {
3792
-                    $sitepress->switch_lang($active_lang, true);
3793
-                }
3794
-                // WPML
3795
-                wp_send_json( $json );
3796
-            } else {
3797
-                if ( !$terms_count > 0 ) {
3798
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3799
-                } else {
3800
-                    $total_terms = $terms_count;
3801
-                    if ($chunk_per_page > $terms_count) {
3802
-                        $chunk_per_page = $terms_count;
3803
-                    }
3804
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3789
+				$json['percentage'] = $percentage;
3790
+				// WPML
3791
+				if ($is_wpml) {
3792
+					$sitepress->switch_lang($active_lang, true);
3793
+				}
3794
+				// WPML
3795
+				wp_send_json( $json );
3796
+			} else {
3797
+				if ( !$terms_count > 0 ) {
3798
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3799
+				} else {
3800
+					$total_terms = $terms_count;
3801
+					if ($chunk_per_page > $terms_count) {
3802
+						$chunk_per_page = $terms_count;
3803
+					}
3804
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3805 3805
                     
3806
-                    $j = $chunk_page_no;
3807
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3806
+					$j = $chunk_page_no;
3807
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3808 3808
                     
3809
-                    $per_page = 500;
3810
-                    if ($per_page > $chunk_per_page) {
3811
-                        $per_page = $chunk_per_page;
3812
-                    }
3813
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3809
+					$per_page = 500;
3810
+					if ($per_page > $chunk_per_page) {
3811
+						$per_page = $chunk_per_page;
3812
+					}
3813
+					$total_pages = ceil( $chunk_per_page / $per_page );
3814 3814
                     
3815
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3816
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3815
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3816
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3817 3817
                         
3818
-                        $clear = $i == 0 ? true : false;
3819
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3820
-                    }
3818
+						$clear = $i == 0 ? true : false;
3819
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3820
+					}
3821 3821
                     
3822
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3823
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3824
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3825
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3826
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3822
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3823
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3824
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3825
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3826
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3827 3827
                         
3828
-                        $file_url = $file_url_base . $chunk_file_name;
3829
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3830
-                    }
3828
+						$file_url = $file_url_base . $chunk_file_name;
3829
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3830
+					}
3831 3831
                     
3832
-                    if ( !empty($chunk_file_paths) ) {
3833
-                        $json['total'] = $terms_count;
3834
-                        $json['files'] = $chunk_file_paths;
3835
-                    } else {
3836
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3837
-                    }
3838
-                }
3839
-                // WPML
3840
-                if ($is_wpml) {
3841
-                    $sitepress->switch_lang($active_lang, true);
3842
-                }
3843
-                // WPML
3844
-                wp_send_json( $json );
3845
-            }
3846
-        }
3847
-        break;
3848
-        case 'export_locations': {
3849
-            $file_url_base = geodir_path_import_export() . '/';
3850
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3851
-            $file_url = $file_url_base . $file_name . '.csv';
3852
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3853
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3832
+					if ( !empty($chunk_file_paths) ) {
3833
+						$json['total'] = $terms_count;
3834
+						$json['files'] = $chunk_file_paths;
3835
+					} else {
3836
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3837
+					}
3838
+				}
3839
+				// WPML
3840
+				if ($is_wpml) {
3841
+					$sitepress->switch_lang($active_lang, true);
3842
+				}
3843
+				// WPML
3844
+				wp_send_json( $json );
3845
+			}
3846
+		}
3847
+		break;
3848
+		case 'export_locations': {
3849
+			$file_url_base = geodir_path_import_export() . '/';
3850
+			$file_name = 'gd_locations_' . date( 'dmyHi' );
3851
+			$file_url = $file_url_base . $file_name . '.csv';
3852
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3853
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3854 3854
             
3855
-            $items_count = (int)geodir_location_imex_count_locations();
3855
+			$items_count = (int)geodir_location_imex_count_locations();
3856 3856
             
3857
-            if ( isset( $_REQUEST['_st'] ) ) {
3858
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3859
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3860
-                $percentage = min( $percentage, 100 );
3857
+			if ( isset( $_REQUEST['_st'] ) ) {
3858
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3859
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3860
+				$percentage = min( $percentage, 100 );
3861 3861
                 
3862
-                $json['percentage'] = $percentage;
3863
-                wp_send_json( $json );
3864
-            } else {
3865
-                $chunk_file_paths = array();
3862
+				$json['percentage'] = $percentage;
3863
+				wp_send_json( $json );
3864
+			} else {
3865
+				$chunk_file_paths = array();
3866 3866
                 
3867
-                if ( !$items_count > 0 ) {
3868
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3869
-                } else {
3870
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3871
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3867
+				if ( !$items_count > 0 ) {
3868
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3869
+				} else {
3870
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3871
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3872 3872
                     
3873
-                    $j = $chunk_page_no;
3874
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3873
+					$j = $chunk_page_no;
3874
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3875 3875
                     
3876
-                    $per_page = 500;
3877
-                    $per_page = min( $per_page, $chunk_per_page );
3878
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3876
+					$per_page = 500;
3877
+					$per_page = min( $per_page, $chunk_per_page );
3878
+					$total_pages = ceil( $chunk_per_page / $per_page );
3879 3879
                     
3880
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3881
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3880
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3881
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3882 3882
                         
3883
-                        $clear = $i == 0 ? true : false;
3884
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3885
-                    }
3883
+						$clear = $i == 0 ? true : false;
3884
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3885
+					}
3886 3886
                     
3887
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3888
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3889
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3890
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3891
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3887
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3888
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3889
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3890
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3891
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3892 3892
                         
3893
-                        $file_url = $file_url_base . $chunk_file_name;
3894
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3895
-                    }
3893
+						$file_url = $file_url_base . $chunk_file_name;
3894
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3895
+					}
3896 3896
                     
3897
-                    if ( !empty($chunk_file_paths) ) {
3898
-                        $json['total'] = $items_count;
3899
-                        $json['files'] = $chunk_file_paths;
3900
-                    } else {
3901
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3902
-                    }
3903
-                }
3904
-                wp_send_json( $json );
3905
-            }
3906
-        }
3907
-        break;
3908
-        case 'export_hoods': {
3909
-            $file_url_base = geodir_path_import_export() . '/';
3910
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3911
-            $file_url = $file_url_base . $file_name . '.csv';
3912
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3913
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3897
+					if ( !empty($chunk_file_paths) ) {
3898
+						$json['total'] = $items_count;
3899
+						$json['files'] = $chunk_file_paths;
3900
+					} else {
3901
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3902
+					}
3903
+				}
3904
+				wp_send_json( $json );
3905
+			}
3906
+		}
3907
+		break;
3908
+		case 'export_hoods': {
3909
+			$file_url_base = geodir_path_import_export() . '/';
3910
+			$file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3911
+			$file_url = $file_url_base . $file_name . '.csv';
3912
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3913
+			$file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3914 3914
             
3915
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3915
+			$items_count = (int)geodir_location_imex_count_neighbourhoods();
3916 3916
             
3917
-            if ( isset( $_REQUEST['_st'] ) ) {
3918
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3919
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3920
-                $percentage = min( $percentage, 100 );
3917
+			if ( isset( $_REQUEST['_st'] ) ) {
3918
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3919
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3920
+				$percentage = min( $percentage, 100 );
3921 3921
                 
3922
-                $json['percentage'] = $percentage;
3923
-                wp_send_json( $json );
3924
-            } else {
3925
-                $chunk_file_paths = array();
3922
+				$json['percentage'] = $percentage;
3923
+				wp_send_json( $json );
3924
+			} else {
3925
+				$chunk_file_paths = array();
3926 3926
                 
3927
-                if ( !$items_count > 0 ) {
3928
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3929
-                } else {
3930
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3931
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3927
+				if ( !$items_count > 0 ) {
3928
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3929
+				} else {
3930
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3931
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3932 3932
                     
3933
-                    $j = $chunk_page_no;
3934
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3933
+					$j = $chunk_page_no;
3934
+					$chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3935 3935
                     
3936
-                    $per_page = 500;
3937
-                    $per_page = min( $per_page, $chunk_per_page );
3938
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3936
+					$per_page = 500;
3937
+					$per_page = min( $per_page, $chunk_per_page );
3938
+					$total_pages = ceil( $chunk_per_page / $per_page );
3939 3939
                     
3940
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3941
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3940
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3941
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3942 3942
                         
3943
-                        $clear = $i == 0 ? true : false;
3944
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3945
-                    }
3943
+						$clear = $i == 0 ? true : false;
3944
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3945
+					}
3946 3946
                     
3947
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3948
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3949
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3950
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3951
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3947
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3948
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3949
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3950
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3951
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3952 3952
                         
3953
-                        $file_url = $file_url_base . $chunk_file_name;
3954
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3955
-                    }
3953
+						$file_url = $file_url_base . $chunk_file_name;
3954
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3955
+					}
3956 3956
                     
3957
-                    if ( !empty($chunk_file_paths) ) {
3958
-                        $json['total'] = $items_count;
3959
-                        $json['files'] = $chunk_file_paths;
3960
-                    } else {
3961
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3962
-                    }
3963
-                }
3964
-                wp_send_json( $json );
3965
-            }
3966
-        }
3967
-        break;
3968
-        case 'prepare_import':
3969
-        case 'import_cat':
3970
-        case 'import_post':
3971
-        case 'import_loc':
3972
-        case 'import_hood': {
3973
-            // WPML
3974
-            $is_wpml = geodir_is_wpml();
3975
-            if ($is_wpml) {
3976
-                global $sitepress;
3977
-                $active_lang = ICL_LANGUAGE_CODE;
3978
-            }
3979
-            // WPML
3957
+					if ( !empty($chunk_file_paths) ) {
3958
+						$json['total'] = $items_count;
3959
+						$json['files'] = $chunk_file_paths;
3960
+					} else {
3961
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3962
+					}
3963
+				}
3964
+				wp_send_json( $json );
3965
+			}
3966
+		}
3967
+		break;
3968
+		case 'prepare_import':
3969
+		case 'import_cat':
3970
+		case 'import_post':
3971
+		case 'import_loc':
3972
+		case 'import_hood': {
3973
+			// WPML
3974
+			$is_wpml = geodir_is_wpml();
3975
+			if ($is_wpml) {
3976
+				global $sitepress;
3977
+				$active_lang = ICL_LANGUAGE_CODE;
3978
+			}
3979
+			// WPML
3980 3980
             
3981
-            ini_set( 'auto_detect_line_endings', true );
3981
+			ini_set( 'auto_detect_line_endings', true );
3982 3982
             
3983
-            $uploads = wp_upload_dir();
3984
-            $uploads_dir = $uploads['path'];
3985
-            $uploads_subdir = $uploads['subdir'];
3983
+			$uploads = wp_upload_dir();
3984
+			$uploads_dir = $uploads['path'];
3985
+			$uploads_subdir = $uploads['subdir'];
3986 3986
             
3987
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3988
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3987
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3988
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3989 3989
             
3990
-            $csv_file_arr = explode( '/', $csv_file );
3991
-            $csv_filename = end( $csv_file_arr );
3992
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3990
+			$csv_file_arr = explode( '/', $csv_file );
3991
+			$csv_filename = end( $csv_file_arr );
3992
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3993 3993
             
3994
-            $json['file'] = $csv_file;
3995
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3994
+			$json['file'] = $csv_file;
3995
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3996 3996
 
3997
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3998
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3997
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3998
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3999 3999
                 
4000
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4001
-                    $json['error'] = NULL;
4002
-                    $json['rows'] = 0;
4000
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4001
+					$json['error'] = NULL;
4002
+					$json['rows'] = 0;
4003 4003
                     
4004
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4005
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4006
-                            if ( !empty( $data ) ) {
4007
-                                $file[] = $data;
4008
-                            }
4009
-                        }
4010
-                        fclose($handle);
4011
-                    }
4004
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4005
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4006
+							if ( !empty( $data ) ) {
4007
+								$file[] = $data;
4008
+							}
4009
+						}
4010
+						fclose($handle);
4011
+					}
4012 4012
 
4013
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4013
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4014 4014
                     
4015
-                    if (!$json['rows'] > 0) {
4016
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
4017
-                    }
4018
-                } else {
4019
-                    wp_send_json( $json );
4020
-                }
4021
-            } else {
4022
-                wp_send_json( $json );
4023
-            }
4015
+					if (!$json['rows'] > 0) {
4016
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
4017
+					}
4018
+				} else {
4019
+					wp_send_json( $json );
4020
+				}
4021
+			} else {
4022
+				wp_send_json( $json );
4023
+			}
4024 4024
             
4025
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4026
-                wp_send_json( $json );
4027
-            }
4025
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4026
+				wp_send_json( $json );
4027
+			}
4028 4028
             
4029
-            $total = $json['rows'];
4030
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4031
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4029
+			$total = $json['rows'];
4030
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4031
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4032 4032
             
4033
-            $count = $limit;
4034
-            $requested_limit = $limit;
4033
+			$count = $limit;
4034
+			$requested_limit = $limit;
4035 4035
             
4036
-            if ($count < $total) {
4037
-                $count = $processed + $count;
4038
-                if ($count > $total) {
4039
-                    $count = $total;
4040
-                }
4041
-            } else {
4042
-                $count = $total;
4043
-            }
4036
+			if ($count < $total) {
4037
+				$count = $processed + $count;
4038
+				if ($count > $total) {
4039
+					$count = $total;
4040
+				}
4041
+			} else {
4042
+				$count = $total;
4043
+			}
4044 4044
             
4045
-            $created = 0;
4046
-            $updated = 0;
4047
-            $skipped = 0;
4048
-            $invalid = 0;
4049
-            $invalid_addr = 0;
4050
-            $images = 0;
4045
+			$created = 0;
4046
+			$updated = 0;
4047
+			$skipped = 0;
4048
+			$invalid = 0;
4049
+			$invalid_addr = 0;
4050
+			$images = 0;
4051 4051
             
4052
-            $invalid_title = 0;
4053
-            $customKeyarray = array();
4054
-            $gd_post_info = array();
4055
-            $post_location = array();
4056
-            $countpost = 0;
4052
+			$invalid_title = 0;
4053
+			$customKeyarray = array();
4054
+			$gd_post_info = array();
4055
+			$post_location = array();
4056
+			$countpost = 0;
4057 4057
             
4058
-            $post_types = geodir_get_posttypes();
4058
+			$post_types = geodir_get_posttypes();
4059 4059
 
4060
-            if ( $task == 'import_cat' ) {				
4061
-                if (!empty($file)) {
4062
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4060
+			if ( $task == 'import_cat' ) {				
4061
+				if (!empty($file)) {
4062
+					$columns = isset($file[0]) ? $file[0] : NULL;
4063 4063
                     
4064
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4065
-                        $json['error'] = CSV_INVAILD_FILE;
4066
-                        wp_send_json( $json );
4067
-                        exit;
4068
-                    }
4064
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4065
+						$json['error'] = CSV_INVAILD_FILE;
4066
+						wp_send_json( $json );
4067
+						exit;
4068
+					}
4069 4069
                     
4070
-                    for ($i = 1; $i <= $limit; $i++) {
4071
-                        $index = $processed + $i;
4070
+					for ($i = 1; $i <= $limit; $i++) {
4071
+						$index = $processed + $i;
4072 4072
                         
4073
-                        if (isset($file[$index])) {
4074
-                            $row = $file[$index];
4075
-                            $row = array_map( 'trim', $row );
4076
-                            //$row = array_map( 'utf8_encode', $row );
4073
+						if (isset($file[$index])) {
4074
+							$row = $file[$index];
4075
+							$row = array_map( 'trim', $row );
4076
+							//$row = array_map( 'utf8_encode', $row );
4077 4077
                             
4078
-                            $cat_id = '';
4079
-                            $cat_name = '';
4080
-                            $cat_slug = '';
4081
-                            $cat_posttype = '';
4082
-                            $cat_parent = '';
4083
-                            $cat_description = '';
4084
-                            $cat_schema = '';
4085
-                            $cat_top_description = '';
4086
-                            $cat_image = '';
4087
-                            $cat_icon = '';
4088
-                            $cat_language = '';
4078
+							$cat_id = '';
4079
+							$cat_name = '';
4080
+							$cat_slug = '';
4081
+							$cat_posttype = '';
4082
+							$cat_parent = '';
4083
+							$cat_description = '';
4084
+							$cat_schema = '';
4085
+							$cat_top_description = '';
4086
+							$cat_image = '';
4087
+							$cat_icon = '';
4088
+							$cat_language = '';
4089 4089
                             
4090
-                            $c = 0;
4091
-                            foreach ($columns as $column ) {
4092
-                                if ( $column == 'cat_id' ) {
4093
-                                    $cat_id = (int)$row[$c];
4094
-                                } else if ( $column == 'cat_name' ) {
4095
-                                    $cat_name = $row[$c];
4096
-                                } else if ( $column == 'cat_slug' ) {
4097
-                                    $cat_slug = $row[$c];
4098
-                                } else if ( $column == 'cat_posttype' ) {
4099
-                                    $cat_posttype = $row[$c];
4100
-                                } else if ( $column == 'cat_parent' ) {
4101
-                                    $cat_parent = trim($row[$c]);
4102
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4103
-                                    $cat_schema = $row[$c];
4104
-                                } else if ( $column == 'cat_description' ) {
4105
-                                    $cat_description = $row[$c];
4106
-                                } else if ( $column == 'cat_top_description' ) {
4107
-                                    $cat_top_description = $row[$c];
4108
-                                } else if ( $column == 'cat_image' ) {
4109
-                                    $cat_image = $row[$c];
4110
-                                } else if ( $column == 'cat_icon' ) {
4111
-                                    $cat_icon = $row[$c];
4112
-                                }
4113
-                                // WPML
4114
-                                if ($is_wpml && $column == 'cat_language') {
4115
-                                    $cat_language = geodir_strtolower(trim($row[$c]));
4116
-                                }
4117
-                                // WPML
4118
-                                $c++;
4119
-                            }
4090
+							$c = 0;
4091
+							foreach ($columns as $column ) {
4092
+								if ( $column == 'cat_id' ) {
4093
+									$cat_id = (int)$row[$c];
4094
+								} else if ( $column == 'cat_name' ) {
4095
+									$cat_name = $row[$c];
4096
+								} else if ( $column == 'cat_slug' ) {
4097
+									$cat_slug = $row[$c];
4098
+								} else if ( $column == 'cat_posttype' ) {
4099
+									$cat_posttype = $row[$c];
4100
+								} else if ( $column == 'cat_parent' ) {
4101
+									$cat_parent = trim($row[$c]);
4102
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4103
+									$cat_schema = $row[$c];
4104
+								} else if ( $column == 'cat_description' ) {
4105
+									$cat_description = $row[$c];
4106
+								} else if ( $column == 'cat_top_description' ) {
4107
+									$cat_top_description = $row[$c];
4108
+								} else if ( $column == 'cat_image' ) {
4109
+									$cat_image = $row[$c];
4110
+								} else if ( $column == 'cat_icon' ) {
4111
+									$cat_icon = $row[$c];
4112
+								}
4113
+								// WPML
4114
+								if ($is_wpml && $column == 'cat_language') {
4115
+									$cat_language = geodir_strtolower(trim($row[$c]));
4116
+								}
4117
+								// WPML
4118
+								$c++;
4119
+							}
4120 4120
                             
4121
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4122
-                                $invalid++;
4123
-                                continue;
4124
-                            }
4121
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4122
+								$invalid++;
4123
+								continue;
4124
+							}
4125 4125
                             
4126
-                            // WPML
4127
-                            if ($is_wpml && $cat_language != '') {
4128
-                                $sitepress->switch_lang($cat_language, true);
4129
-                            }
4130
-                            // WPML
4126
+							// WPML
4127
+							if ($is_wpml && $cat_language != '') {
4128
+								$sitepress->switch_lang($cat_language, true);
4129
+							}
4130
+							// WPML
4131 4131
                                                         
4132
-                            $term_data = array();
4133
-                            $term_data['name'] = $cat_name;
4134
-                            $term_data['slug'] = $cat_slug;
4135
-                            $term_data['description'] = $cat_description;
4136
-                            $term_data['cat_schema'] = $cat_schema;
4137
-                            $term_data['top_description'] = $cat_top_description;
4138
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4139
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4132
+							$term_data = array();
4133
+							$term_data['name'] = $cat_name;
4134
+							$term_data['slug'] = $cat_slug;
4135
+							$term_data['description'] = $cat_description;
4136
+							$term_data['cat_schema'] = $cat_schema;
4137
+							$term_data['top_description'] = $cat_top_description;
4138
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4139
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4140 4140
                             
4141
-                            //$term_data = array_map( 'utf8_encode', $term_data );
4141
+							//$term_data = array_map( 'utf8_encode', $term_data );
4142 4142
                             
4143
-                            $taxonomy = $cat_posttype . 'category';
4143
+							$taxonomy = $cat_posttype . 'category';
4144 4144
                             
4145
-                            $term_data['taxonomy'] = $taxonomy;
4145
+							$term_data['taxonomy'] = $taxonomy;
4146 4146
 
4147
-                            $term_parent_id = 0;
4148
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4149
-                                $term_parent = '';
4147
+							$term_parent_id = 0;
4148
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
4149
+								$term_parent = '';
4150 4150
                                 
4151
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4152
-                                    $term_parent = $term_parent;
4153
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4154
-                                    $term_parent = $term_parent;
4155
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4156
-                                    $term_parent = $term_parent;
4157
-                                } else {
4158
-                                    $term_parent_data = array();
4159
-                                    $term_parent_data['name'] = $cat_parent;											
4160
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );										
4161
-                                    $term_parent_data['taxonomy'] = $taxonomy;
4151
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4152
+									$term_parent = $term_parent;
4153
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4154
+									$term_parent = $term_parent;
4155
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4156
+									$term_parent = $term_parent;
4157
+								} else {
4158
+									$term_parent_data = array();
4159
+									$term_parent_data['name'] = $cat_parent;											
4160
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );										
4161
+									$term_parent_data['taxonomy'] = $taxonomy;
4162 4162
                                     
4163
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4164
-                                }
4163
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4164
+								}
4165 4165
                                 
4166
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4167
-                                    $term_parent_id = (int)$term_parent->term_id;
4168
-                                }
4169
-                            }
4170
-                            $term_data['parent'] = (int)$term_parent_id;
4166
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4167
+									$term_parent_id = (int)$term_parent->term_id;
4168
+								}
4169
+							}
4170
+							$term_data['parent'] = (int)$term_parent_id;
4171 4171
 
4172
-                            $term_id = NULL;
4173
-                            if ( $import_choice == 'update' ) {
4174
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4175
-                                    $term_data['term_id'] = $term['term_id'];
4172
+							$term_id = NULL;
4173
+							if ( $import_choice == 'update' ) {
4174
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4175
+									$term_data['term_id'] = $term['term_id'];
4176 4176
                                     
4177
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4178
-                                        $updated++;
4179
-                                    } else {
4180
-                                        $invalid++;
4181
-                                    }
4182
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4183
-                                    $term_data['term_id'] = $term['term_id'];
4177
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4178
+										$updated++;
4179
+									} else {
4180
+										$invalid++;
4181
+									}
4182
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4183
+									$term_data['term_id'] = $term['term_id'];
4184 4184
                                     
4185
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4186
-                                        $updated++;
4187
-                                    } else {
4188
-                                        $invalid++;
4189
-                                    }
4190
-                                } else {
4191
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4192
-                                        $created++;
4193
-                                    } else {
4194
-                                        $invalid++;
4195
-                                    }
4196
-                                }
4197
-                            } else if ( $import_choice == 'skip' ) {
4198
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4199
-                                    $skipped++;
4200
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4201
-                                    $skipped++;
4202
-                                } else {
4203
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {										
4204
-                                        $created++;
4205
-                                    } else {
4206
-                                        $invalid++;
4207
-                                    }
4208
-                                }
4209
-                            } else {
4210
-                                $invalid++;
4211
-                            }
4185
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4186
+										$updated++;
4187
+									} else {
4188
+										$invalid++;
4189
+									}
4190
+								} else {
4191
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4192
+										$created++;
4193
+									} else {
4194
+										$invalid++;
4195
+									}
4196
+								}
4197
+							} else if ( $import_choice == 'skip' ) {
4198
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4199
+									$skipped++;
4200
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4201
+									$skipped++;
4202
+								} else {
4203
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {										
4204
+										$created++;
4205
+									} else {
4206
+										$invalid++;
4207
+									}
4208
+								}
4209
+							} else {
4210
+								$invalid++;
4211
+							}
4212 4212
                             
4213
-                            if ( $term_id ) {
4214
-                                if ( isset( $term_data['top_description'] ) ) {
4215
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4216
-                                }
4213
+							if ( $term_id ) {
4214
+								if ( isset( $term_data['top_description'] ) ) {
4215
+									update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4216
+								}
4217 4217
                                 
4218
-                                if ( isset( $term_data['cat_schema'] ) ) {
4219
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4220
-                                }
4218
+								if ( isset( $term_data['cat_schema'] ) ) {
4219
+									update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4220
+								}
4221 4221
             
4222
-                                $attachment = false;
4223
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4224
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4225
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4222
+								$attachment = false;
4223
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4224
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4225
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4226 4226
                                     
4227
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4228
-                                        $attachment = true;
4229
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4230
-                                    }
4231
-                                }
4227
+									if ( basename($cat_image) != $term_data['image'] ) {
4228
+										$attachment = true;
4229
+										update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4230
+									}
4231
+								}
4232 4232
                                 
4233
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4234
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4235
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4233
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4234
+									$cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4235
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4236 4236
                                         
4237
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4238
-                                        $attachment = true;
4239
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4240
-                                    }
4241
-                                }
4237
+									if ( basename($cat_icon) != $term_data['icon'] ) {
4238
+										$attachment = true;
4239
+										update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4240
+									}
4241
+								}
4242 4242
                                 
4243
-                                if ( $attachment ) {
4244
-                                    $images++;
4245
-                                }
4246
-                            }
4243
+								if ( $attachment ) {
4244
+									$images++;
4245
+								}
4246
+							}
4247 4247
                             
4248
-                            // WPML
4249
-                            if ($is_wpml && $cat_language != '') {
4250
-                                $sitepress->switch_lang($active_lang, true);
4251
-                            }
4252
-                            // WPML
4253
-                        }
4254
-                    }
4255
-                }
4248
+							// WPML
4249
+							if ($is_wpml && $cat_language != '') {
4250
+								$sitepress->switch_lang($active_lang, true);
4251
+							}
4252
+							// WPML
4253
+						}
4254
+					}
4255
+				}
4256 4256
                 
4257
-                $json = array();
4258
-                $json['processed'] = $limit;
4259
-                $json['created'] = $created;
4260
-                $json['updated'] = $updated;
4261
-                $json['skipped'] = $skipped;
4262
-                $json['invalid'] = $invalid;
4263
-                $json['images'] = $images;
4257
+				$json = array();
4258
+				$json['processed'] = $limit;
4259
+				$json['created'] = $created;
4260
+				$json['updated'] = $updated;
4261
+				$json['skipped'] = $skipped;
4262
+				$json['invalid'] = $invalid;
4263
+				$json['images'] = $images;
4264 4264
                 
4265
-                wp_send_json( $json );
4266
-                exit;
4267
-            } else if ( $task == 'import_post' ) {
4268
-
4269
-                //run some stuff to make the import quicker
4270
-                wp_defer_term_counting( true );
4271
-                wp_defer_comment_counting( true );
4272
-                $wpdb->query( 'SET autocommit = 0;' );
4273
-
4274
-                //remove_all_actions('publish_post');
4275
-                //remove_all_actions('transition_post_status');
4276
-                //remove_all_actions('publish_future_post');
4277
-
4278
-                if (!empty($file)) {
4279
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4280
-                    $default_status = 'publish';
4281
-                    $current_date = date_i18n( 'Y-m-d', time() );
4265
+				wp_send_json( $json );
4266
+				exit;
4267
+			} else if ( $task == 'import_post' ) {
4268
+
4269
+				//run some stuff to make the import quicker
4270
+				wp_defer_term_counting( true );
4271
+				wp_defer_comment_counting( true );
4272
+				$wpdb->query( 'SET autocommit = 0;' );
4273
+
4274
+				//remove_all_actions('publish_post');
4275
+				//remove_all_actions('transition_post_status');
4276
+				//remove_all_actions('publish_future_post');
4277
+
4278
+				if (!empty($file)) {
4279
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4280
+					$default_status = 'publish';
4281
+					$current_date = date_i18n( 'Y-m-d', time() );
4282 4282
                     
4283
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4283
+					$columns = isset($file[0]) ? $file[0] : NULL;
4284 4284
                     
4285
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4286
-                        $json['error'] = CSV_INVAILD_FILE;
4287
-                        wp_send_json( $json );
4288
-                        exit;
4289
-                    }
4285
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4286
+						$json['error'] = CSV_INVAILD_FILE;
4287
+						wp_send_json( $json );
4288
+						exit;
4289
+					}
4290 4290
 
4291
-                    $processed_actual=0;
4292
-                    for ($i = 1; $i <= $limit; $i++) {
4293
-                        $index = $processed + $i;
4294
-                        $gd_post = array();
4291
+					$processed_actual=0;
4292
+					for ($i = 1; $i <= $limit; $i++) {
4293
+						$index = $processed + $i;
4294
+						$gd_post = array();
4295 4295
                         
4296
-                        if (isset($file[$index])) {$processed_actual++;
4297
-                            $row = $file[$index];
4298
-                            $row = array_map( 'trim', $row );
4299
-                            //$row = array_map( 'utf8_encode', $row );
4300
-                            $row = array_map( 'addslashes_gpc', $row );
4296
+						if (isset($file[$index])) {$processed_actual++;
4297
+							$row = $file[$index];
4298
+							$row = array_map( 'trim', $row );
4299
+							//$row = array_map( 'utf8_encode', $row );
4300
+							$row = array_map( 'addslashes_gpc', $row );
4301 4301
                             
4302
-                            $post_id = '';
4303
-                            $post_title = '';
4304
-                            $post_author = '';
4305
-                            $post_content = '';
4306
-                            $post_category_arr = array();
4307
-                            $default_category = '';
4308
-                            $post_tags = array();
4309
-                            $post_type = '';
4310
-                            $post_status = '';
4311
-                            $geodir_video = '';
4312
-                            $post_address = '';
4313
-                            $post_city = '';
4314
-                            $post_region = '';
4315
-                            $post_country = '';
4316
-                            $post_zip = '';
4317
-                            $post_latitude = '';
4318
-                            $post_longitude = '';
4319
-                            $post_neighbourhood = '';
4320
-                            $neighbourhood_latitude = '';
4321
-                            $neighbourhood_longitude = '';
4322
-                            $geodir_timing = '';
4323
-                            $geodir_contact = '';
4324
-                            $geodir_email = '';
4325
-                            $geodir_website = '';
4326
-                            $geodir_twitter = '';
4327
-                            $geodir_facebook = '';
4328
-                            $geodir_twitter = '';
4329
-                            $post_images = array();
4302
+							$post_id = '';
4303
+							$post_title = '';
4304
+							$post_author = '';
4305
+							$post_content = '';
4306
+							$post_category_arr = array();
4307
+							$default_category = '';
4308
+							$post_tags = array();
4309
+							$post_type = '';
4310
+							$post_status = '';
4311
+							$geodir_video = '';
4312
+							$post_address = '';
4313
+							$post_city = '';
4314
+							$post_region = '';
4315
+							$post_country = '';
4316
+							$post_zip = '';
4317
+							$post_latitude = '';
4318
+							$post_longitude = '';
4319
+							$post_neighbourhood = '';
4320
+							$neighbourhood_latitude = '';
4321
+							$neighbourhood_longitude = '';
4322
+							$geodir_timing = '';
4323
+							$geodir_contact = '';
4324
+							$geodir_email = '';
4325
+							$geodir_website = '';
4326
+							$geodir_twitter = '';
4327
+							$geodir_facebook = '';
4328
+							$geodir_twitter = '';
4329
+							$post_images = array();
4330 4330
                             
4331
-                            $expire_date = 'Never';
4331
+							$expire_date = 'Never';
4332 4332
                             
4333
-                            $language = '';
4334
-                            $original_post_id = '';
4333
+							$language = '';
4334
+							$original_post_id = '';
4335 4335
                                                         
4336
-                            $c = 0;
4337
-                            foreach ($columns as $column ) {
4338
-                                $gd_post[$column] = $row[$c];
4336
+							$c = 0;
4337
+							foreach ($columns as $column ) {
4338
+								$gd_post[$column] = $row[$c];
4339 4339
                                 
4340
-                                if ( $column == 'post_id' ) {
4341
-                                    $post_id = $row[$c];
4342
-                                } else if ( $column == 'post_title' ) {
4343
-                                    $post_title = sanitize_text_field($row[$c]);
4344
-                                } else if ( $column == 'post_author' ) {
4345
-                                    $post_author = $row[$c];
4346
-                                } else if ( $column == 'post_content' ) {
4347
-                                    $post_content = $row[$c];
4348
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4349
-                                    $post_category_arr = explode( ',', $row[$c] );
4350
-                                } else if ( $column == 'default_category' ) {
4351
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
4352
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4353
-                                    $post_tags = explode( ',', $row[$c] );
4354
-                                } else if ( $column == 'post_type' ) {
4355
-                                    $post_type = $row[$c];
4356
-                                } else if ( $column == 'post_status' ) {
4357
-                                    $post_status = sanitize_key( $row[$c] );
4358
-                                } else if ( $column == 'is_featured' ) {
4359
-                                    $is_featured = (int)$row[$c];
4360
-                                } else if ( $column == 'geodir_video' ) {
4361
-                                    $geodir_video = $row[$c];
4362
-                                } else if ( $column == 'post_address' ) {
4363
-                                    $post_address = $row[$c];
4364
-                                } else if ( $column == 'post_city' ) {
4365
-                                    $post_city = $row[$c];
4366
-                                } else if ( $column == 'post_region' ) {
4367
-                                    $post_region = $row[$c];
4368
-                                } else if ( $column == 'post_country' ) {
4369
-                                    $post_country = $row[$c];
4370
-                                } else if ( $column == 'post_zip' ) {
4371
-                                    $post_zip = $row[$c];
4372
-                                } else if ( $column == 'post_latitude' ) {
4373
-                                    $post_latitude = $row[$c];
4374
-                                } else if ( $column == 'post_longitude' ) {
4375
-                                    $post_longitude = $row[$c];
4376
-                                } else if ( $column == 'post_neighbourhood' ) {
4377
-                                    $post_neighbourhood = $row[$c];
4378
-                                    unset($gd_post[$column]);
4379
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4380
-                                    $neighbourhood_latitude = $row[$c];
4381
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4382
-                                    $neighbourhood_longitude = $row[$c];
4383
-                                } else if ( $column == 'geodir_timing' ) {
4384
-                                    $geodir_timing = $row[$c];
4385
-                                } else if ( $column == 'geodir_contact' ) {
4386
-                                    $geodir_contact = $row[$c];
4387
-                                } else if ( $column == 'geodir_email' ) {
4388
-                                    $geodir_email = $row[$c];
4389
-                                } else if ( $column == 'geodir_website' ) {
4390
-                                    $geodir_website = $row[$c];
4391
-                                } else if ( $column == 'geodir_twitter' ) {
4392
-                                    $geodir_twitter = $row[$c];
4393
-                                } else if ( $column == 'geodir_facebook' ) {
4394
-                                    $geodir_facebook = $row[$c];
4395
-                                } else if ( $column == 'geodir_twitter' ) {
4396
-                                    $geodir_twitter = $row[$c];
4397
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4398
-                                    $post_images[] = $row[$c];
4399
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4400
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4401
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4402
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
4403
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4404
-                                }
4405
-                                // WPML
4406
-                                if ($is_wpml) {
4407
-                                    if ($column == 'language') {
4408
-                                        $language = geodir_strtolower(trim($row[$c]));
4409
-                                    } else if ($column == 'original_post_id') {
4410
-                                        $original_post_id = (int)$row[$c];
4411
-                                    }
4412
-                                }
4413
-                                // WPML
4414
-                                $c++;
4415
-                            }
4340
+								if ( $column == 'post_id' ) {
4341
+									$post_id = $row[$c];
4342
+								} else if ( $column == 'post_title' ) {
4343
+									$post_title = sanitize_text_field($row[$c]);
4344
+								} else if ( $column == 'post_author' ) {
4345
+									$post_author = $row[$c];
4346
+								} else if ( $column == 'post_content' ) {
4347
+									$post_content = $row[$c];
4348
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
4349
+									$post_category_arr = explode( ',', $row[$c] );
4350
+								} else if ( $column == 'default_category' ) {
4351
+									$default_category = wp_kses_normalize_entities($row[$c]);
4352
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
4353
+									$post_tags = explode( ',', $row[$c] );
4354
+								} else if ( $column == 'post_type' ) {
4355
+									$post_type = $row[$c];
4356
+								} else if ( $column == 'post_status' ) {
4357
+									$post_status = sanitize_key( $row[$c] );
4358
+								} else if ( $column == 'is_featured' ) {
4359
+									$is_featured = (int)$row[$c];
4360
+								} else if ( $column == 'geodir_video' ) {
4361
+									$geodir_video = $row[$c];
4362
+								} else if ( $column == 'post_address' ) {
4363
+									$post_address = $row[$c];
4364
+								} else if ( $column == 'post_city' ) {
4365
+									$post_city = $row[$c];
4366
+								} else if ( $column == 'post_region' ) {
4367
+									$post_region = $row[$c];
4368
+								} else if ( $column == 'post_country' ) {
4369
+									$post_country = $row[$c];
4370
+								} else if ( $column == 'post_zip' ) {
4371
+									$post_zip = $row[$c];
4372
+								} else if ( $column == 'post_latitude' ) {
4373
+									$post_latitude = $row[$c];
4374
+								} else if ( $column == 'post_longitude' ) {
4375
+									$post_longitude = $row[$c];
4376
+								} else if ( $column == 'post_neighbourhood' ) {
4377
+									$post_neighbourhood = $row[$c];
4378
+									unset($gd_post[$column]);
4379
+								} else if ( $column == 'neighbourhood_latitude' ) {
4380
+									$neighbourhood_latitude = $row[$c];
4381
+								} else if ( $column == 'neighbourhood_longitude' ) {
4382
+									$neighbourhood_longitude = $row[$c];
4383
+								} else if ( $column == 'geodir_timing' ) {
4384
+									$geodir_timing = $row[$c];
4385
+								} else if ( $column == 'geodir_contact' ) {
4386
+									$geodir_contact = $row[$c];
4387
+								} else if ( $column == 'geodir_email' ) {
4388
+									$geodir_email = $row[$c];
4389
+								} else if ( $column == 'geodir_website' ) {
4390
+									$geodir_website = $row[$c];
4391
+								} else if ( $column == 'geodir_twitter' ) {
4392
+									$geodir_twitter = $row[$c];
4393
+								} else if ( $column == 'geodir_facebook' ) {
4394
+									$geodir_facebook = $row[$c];
4395
+								} else if ( $column == 'geodir_twitter' ) {
4396
+									$geodir_twitter = $row[$c];
4397
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4398
+									$post_images[] = $row[$c];
4399
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4400
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4401
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4402
+									$row[$c] = str_replace('/', '-', $row[$c]);
4403
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4404
+								}
4405
+								// WPML
4406
+								if ($is_wpml) {
4407
+									if ($column == 'language') {
4408
+										$language = geodir_strtolower(trim($row[$c]));
4409
+									} else if ($column == 'original_post_id') {
4410
+										$original_post_id = (int)$row[$c];
4411
+									}
4412
+								}
4413
+								// WPML
4414
+								$c++;
4415
+							}
4416 4416
                             
4417
-                            // WPML
4418
-                            if ($is_wpml && $language != '') {
4419
-                                $sitepress->switch_lang($language, true);
4420
-                            }
4421
-                            // WPML
4417
+							// WPML
4418
+							if ($is_wpml && $language != '') {
4419
+								$sitepress->switch_lang($language, true);
4420
+							}
4421
+							// WPML
4422 4422
 
4423
-                            $gd_post['IMAGE'] = $post_images;
4423
+							$gd_post['IMAGE'] = $post_images;
4424 4424
                             
4425
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4426
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4425
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4426
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4427 4427
                                                                                                                 
4428
-                            $valid = true;
4428
+							$valid = true;
4429 4429
                             
4430
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4431
-                                $invalid++;
4432
-                                $valid = false;
4433
-                            }
4430
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4431
+								$invalid++;
4432
+								$valid = false;
4433
+							}
4434 4434
                             
4435
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4436
-                            if ( $location_allowed ) {
4437
-                                $location_result = geodir_get_default_location();
4438
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4439
-                                    $invalid_addr++;
4440
-                                    $valid = false;
4441
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4442
-                                    if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4443
-                                        $invalid_addr++;
4444
-                                        $valid = false;
4445
-                                    } else {
4446
-                                        if (!$location_manager) {
4447
-                                            $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated.
4448
-                                        }
4449
-                                    }
4450
-                                }
4451
-                            }
4435
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4436
+							if ( $location_allowed ) {
4437
+								$location_result = geodir_get_default_location();
4438
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4439
+									$invalid_addr++;
4440
+									$valid = false;
4441
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4442
+									if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4443
+										$invalid_addr++;
4444
+										$valid = false;
4445
+									} else {
4446
+										if (!$location_manager) {
4447
+											$gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated.
4448
+										}
4449
+									}
4450
+								}
4451
+							}
4452 4452
                             
4453
-                            if ( !$valid ) {
4454
-                                continue;
4455
-                            }
4453
+							if ( !$valid ) {
4454
+								continue;
4455
+							}
4456 4456
 
4457
-                            $cat_taxonomy = $post_type . 'category';
4458
-                            $tags_taxonomy = $post_type . '_tags';
4457
+							$cat_taxonomy = $post_type . 'category';
4458
+							$tags_taxonomy = $post_type . '_tags';
4459 4459
                             
4460
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4461
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
4462
-                            }
4460
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4461
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
4462
+							}
4463 4463
 
4464
-                            $post_category = array();
4465
-                            $default_category_id = NULL;
4466
-                            if ( !empty( $post_category_arr ) ) {
4467
-                                foreach ( $post_category_arr as $value ) {
4468
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4464
+							$post_category = array();
4465
+							$default_category_id = NULL;
4466
+							if ( !empty( $post_category_arr ) ) {
4467
+								foreach ( $post_category_arr as $value ) {
4468
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
4469 4469
                                     
4470
-                                    if ( $category_name != '' ) {
4471
-                                        $term_category = array();
4470
+									if ( $category_name != '' ) {
4471
+										$term_category = array();
4472 4472
                                         
4473
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4474
-                                            $term_category = $term;
4475
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4476
-                                            $term_category = $term;
4477
-                                        } else {
4478
-                                            $term_data = array();
4479
-                                            $term_data['name'] = $category_name;
4480
-                                            $term_data['taxonomy'] = $cat_taxonomy;
4473
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4474
+											$term_category = $term;
4475
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4476
+											$term_category = $term;
4477
+										} else {
4478
+											$term_data = array();
4479
+											$term_data['name'] = $category_name;
4480
+											$term_data['taxonomy'] = $cat_taxonomy;
4481 4481
                                             
4482
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4483
-                                            if ( $term_id ) {
4484
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4485
-                                            }
4486
-                                        }
4482
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4483
+											if ( $term_id ) {
4484
+												$term_category = get_term( $term_id, $cat_taxonomy );
4485
+											}
4486
+										}
4487 4487
                                         
4488
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4489
-                                            $post_category[] = intval($term_category->term_id);
4488
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4489
+											$post_category[] = intval($term_category->term_id);
4490 4490
                                             
4491
-                                            if ($category_name == $default_category) {
4492
-                                                $default_category_id = intval($term_category->term_id);
4493
-                                            }
4494
-                                        }
4495
-                                    }
4496
-                                }
4497
-                            }
4491
+											if ($category_name == $default_category) {
4492
+												$default_category_id = intval($term_category->term_id);
4493
+											}
4494
+										}
4495
+									}
4496
+								}
4497
+							}
4498 4498
 
4499
-                            $save_post = array();
4500
-                            $save_post['post_title'] = $post_title;
4501
-                            $save_post['post_content'] = $post_content;
4502
-                            $save_post['post_type'] = $post_type;
4503
-                            $save_post['post_author'] = $post_author;
4504
-                            $save_post['post_status'] = $post_status;
4505
-                            $save_post['post_category'] = $post_category;
4506
-                            $save_post['post_tags'] = $post_tags;
4507
-
4508
-                            $saved_post_id = NULL;
4509
-                            if ( $import_choice == 'update' ) {
4510
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4511
-                                    $save_post['ID'] = $post_id;
4499
+							$save_post = array();
4500
+							$save_post['post_title'] = $post_title;
4501
+							$save_post['post_content'] = $post_content;
4502
+							$save_post['post_type'] = $post_type;
4503
+							$save_post['post_author'] = $post_author;
4504
+							$save_post['post_status'] = $post_status;
4505
+							$save_post['post_category'] = $post_category;
4506
+							$save_post['post_tags'] = $post_tags;
4507
+
4508
+							$saved_post_id = NULL;
4509
+							if ( $import_choice == 'update' ) {
4510
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4511
+									$save_post['ID'] = $post_id;
4512 4512
                                     
4513
-                                    if ( wp_update_post( $save_post ) ) {
4514
-                                        $saved_post_id = $post_id;
4515
-                                        $updated++;
4516
-                                    }
4517
-                                } else {
4518
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
4519
-                                        $created++;
4520
-                                    }
4521
-                                }
4513
+									if ( wp_update_post( $save_post ) ) {
4514
+										$saved_post_id = $post_id;
4515
+										$updated++;
4516
+									}
4517
+								} else {
4518
+									if ( $saved_post_id = wp_insert_post( $save_post ) ) {
4519
+										$created++;
4520
+									}
4521
+								}
4522 4522
                                 
4523
-                                if ( !$saved_post_id > 0 ) {
4524
-                                    $invalid++;
4525
-                                }
4526
-                            } else if ( $import_choice == 'skip' ) {
4527
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4528
-                                    $skipped++;	
4529
-                                } else {
4530
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
4531
-                                        $created++;	
4532
-                                    } else {
4533
-                                        $invalid++;
4534
-                                    }
4535
-                                }
4536
-                            } else {
4537
-                                $invalid++;
4538
-                            }
4523
+								if ( !$saved_post_id > 0 ) {
4524
+									$invalid++;
4525
+								}
4526
+							} else if ( $import_choice == 'skip' ) {
4527
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4528
+									$skipped++;	
4529
+								} else {
4530
+									if ( $saved_post_id = wp_insert_post( $save_post ) ) {
4531
+										$created++;	
4532
+									} else {
4533
+										$invalid++;
4534
+									}
4535
+								}
4536
+							} else {
4537
+								$invalid++;
4538
+							}
4539 4539
 
4540
-                            if ( (int)$saved_post_id > 0 ) {
4541
-                                // WPML
4542
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
4543
-                                    $wpml_post_type = 'post_' . $post_type;
4544
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4545
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4540
+							if ( (int)$saved_post_id > 0 ) {
4541
+								// WPML
4542
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
4543
+									$wpml_post_type = 'post_' . $post_type;
4544
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4545
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4546 4546
 
4547
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4547
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4548 4548
                                     
4549
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4550
-                                }
4551
-                                // WPML
4552
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4549
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4550
+								}
4551
+								// WPML
4552
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
4553 4553
                                 
4554
-                                $gd_post['post_id'] = $saved_post_id;
4555
-                                $gd_post['ID'] = $saved_post_id;
4556
-                                $gd_post['post_tags'] = $post_tags;
4557
-                                $gd_post['post_title'] = $post_title;
4558
-                                $gd_post['post_status'] = $post_status;
4559
-                                $gd_post['submit_time'] = time();
4560
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4554
+								$gd_post['post_id'] = $saved_post_id;
4555
+								$gd_post['ID'] = $saved_post_id;
4556
+								$gd_post['post_tags'] = $post_tags;
4557
+								$gd_post['post_title'] = $post_title;
4558
+								$gd_post['post_status'] = $post_status;
4559
+								$gd_post['submit_time'] = time();
4560
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4561 4561
                                                     
4562
-                                // post location
4563
-                                $post_location_id = 0;
4564
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4565
-                                    $gd_post['post_neighbourhood'] = '';
4562
+								// post location
4563
+								$post_location_id = 0;
4564
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4565
+									$gd_post['post_neighbourhood'] = '';
4566 4566
                                     
4567
-                                    $post_location_info = array(
4568
-                                                                'city' => $post_city,
4569
-                                                                'region' => $post_region,
4570
-                                                                'country' => $post_country,
4571
-                                                                'geo_lat' => $post_latitude,
4572
-                                                                'geo_lng' => $post_longitude
4573
-                                                            );
4574
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4575
-                                        $post_location_id = $location_id;
4576
-                                    }
4567
+									$post_location_info = array(
4568
+																'city' => $post_city,
4569
+																'region' => $post_region,
4570
+																'country' => $post_country,
4571
+																'geo_lat' => $post_latitude,
4572
+																'geo_lng' => $post_longitude
4573
+															);
4574
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4575
+										$post_location_id = $location_id;
4576
+									}
4577 4577
                                     
4578
-                                    if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4579
-                                        $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4578
+									if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4579
+										$neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4580 4580
 
4581
-                                        $hood_data = array();
4582
-                                        $hood_data['hood_location_id'] = $post_location_id;
4583
-                                        $hood_data['hood_name'] = $post_neighbourhood;
4581
+										$hood_data = array();
4582
+										$hood_data['hood_location_id'] = $post_location_id;
4583
+										$hood_data['hood_name'] = $post_neighbourhood;
4584 4584
                                         
4585
-                                        if (!empty($neighbourhood_info)) {
4586
-                                            $hood_data['hood_id'] = $neighbourhood_info->hood_id;
4587
-                                            $hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4585
+										if (!empty($neighbourhood_info)) {
4586
+											$hood_data['hood_id'] = $neighbourhood_info->hood_id;
4587
+											$hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4588 4588
                                             
4589
-                                            if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4590
-                                                $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4591
-                                                $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4592
-                                            }
4593
-                                        }
4589
+											if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4590
+												$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4591
+												$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4592
+											}
4593
+										}
4594 4594
                                         
4595
-                                        if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4596
-                                            $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4597
-                                            $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4598
-                                        }
4595
+										if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4596
+											$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4597
+											$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4598
+										}
4599 4599
                                         
4600
-                                        $hood_data['hood_latitude'] = $post_latitude;
4601
-                                        $hood_data['hood_longitude'] = $post_longitude;
4600
+										$hood_data['hood_latitude'] = $post_latitude;
4601
+										$hood_data['hood_longitude'] = $post_longitude;
4602 4602
 
4603
-                                        $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4604
-                                        if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4605
-                                            $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4606
-                                        }
4607
-                                    }
4608
-                                }
4609
-                                $gd_post['post_location_id'] = $post_location_id;
4603
+										$neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4604
+										if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4605
+											$gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4606
+										}
4607
+									}
4608
+								}
4609
+								$gd_post['post_location_id'] = $post_location_id;
4610 4610
                                 
4611
-                                // post package info
4612
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4613
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4614
-                                    $package_id = $gd_post_info->package_id;
4615
-                                }
4611
+								// post package info
4612
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4613
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4614
+									$package_id = $gd_post_info->package_id;
4615
+								}
4616 4616
                                 
4617
-                                $package_info = array();
4618
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4619
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4617
+								$package_info = array();
4618
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4619
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
4620 4620
                                     
4621
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4622
-                                        $package_info = array();
4623
-                                    }
4624
-                                }
4621
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4622
+										$package_info = array();
4623
+									}
4624
+								}
4625 4625
                                 
4626
-                                if (empty($package_info)) {
4627
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4628
-                                }
4626
+								if (empty($package_info)) {
4627
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
4628
+								}
4629 4629
                                  
4630
-                                if (!empty($package_info))	 {
4631
-                                    $package_id = $package_info['pid'];
4630
+								if (!empty($package_info))	 {
4631
+									$package_id = $package_info['pid'];
4632 4632
                                     
4633
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4634
-                                        $gd_post['expire_date'] = $expire_date;
4635
-                                    } else {
4636
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4637
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4638
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4639
-                                        } else {
4640
-                                            $gd_post['expire_date'] = 'Never';
4641
-                                        }
4642
-                                    }
4633
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4634
+										$gd_post['expire_date'] = $expire_date;
4635
+									} else {
4636
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4637
+											$gd_post['alive_days'] = (int)$package_info['days'];
4638
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4639
+										} else {
4640
+											$gd_post['expire_date'] = 'Never';
4641
+										}
4642
+									}
4643 4643
                                     
4644
-                                    $gd_post['package_id'] = $package_id;
4645
-                                }
4644
+									$gd_post['package_id'] = $package_id;
4645
+								}
4646 4646
 
4647
-                                $table = $plugin_prefix . $post_type . '_detail';
4647
+								$table = $plugin_prefix . $post_type . '_detail';
4648 4648
                                 
4649
-                                if ($post_type == 'gd_event') {
4650
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
4651
-                                }
4649
+								if ($post_type == 'gd_event') {
4650
+									$gd_post = geodir_imex_process_event_data($gd_post);
4651
+								}
4652 4652
                                 
4653
-                                if (isset($gd_post['post_id'])) {
4654
-                                    unset($gd_post['post_id']);
4655
-                                }
4653
+								if (isset($gd_post['post_id'])) {
4654
+									unset($gd_post['post_id']);
4655
+								}
4656 4656
 
4657
-                                // Export franchise fields
4658
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4659
-                                if ($is_franchise_active) {
4660
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4661
-                                        $gd_franchise_lock = array();
4657
+								// Export franchise fields
4658
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4659
+								if ($is_franchise_active) {
4660
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4661
+										$gd_franchise_lock = array();
4662 4662
                                         
4663
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4664
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4665
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4666
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4667
-                                        }
4663
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4664
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4665
+											$gd_franchise_lock = trim( $gd_franchise_lock );
4666
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
4667
+										}
4668 4668
                                         
4669
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4670
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4671
-                                    } else {
4672
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4673
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4674
-                                        }
4675
-                                    }
4676
-                                }
4669
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4670
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4671
+									} else {
4672
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4673
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4674
+										}
4675
+									}
4676
+								}
4677 4677
                                 
4678
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4679
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4680
-                                    if ($default_category_id) {
4681
-                                        $save_post['post_default_category'] = $default_category_id;
4682
-                                        $gd_post['default_category'] = $default_category_id;
4683
-                                    }
4684
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
4685
-                                }
4678
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4679
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4680
+									if ($default_category_id) {
4681
+										$save_post['post_default_category'] = $default_category_id;
4682
+										$gd_post['default_category'] = $default_category_id;
4683
+									}
4684
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
4685
+								}
4686 4686
                                 
4687
-                                // Save post info
4688
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4689
-                                // post taxonomies
4690
-                                if ( !empty( $save_post['post_category'] ) ) {
4691
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4687
+								// Save post info
4688
+								geodir_save_post_info( $saved_post_id, $gd_post );
4689
+								// post taxonomies
4690
+								if ( !empty( $save_post['post_category'] ) ) {
4691
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4692 4692
                                     
4693
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4694
-                                    if ($default_category_id) {
4695
-                                        $post_default_category = $default_category_id;
4696
-                                    }
4697
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4698
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4699
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4693
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4694
+									if ($default_category_id) {
4695
+										$post_default_category = $default_category_id;
4696
+									}
4697
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4698
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4699
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4700 4700
                                     
4701
-                                    if ($post_category_str != '' && $post_default_category) {
4702
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4703
-                                    }
4701
+									if ($post_category_str != '' && $post_default_category) {
4702
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4703
+									}
4704 4704
                                     
4705
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4705
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4706 4706
                                     
4707
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4708
-                                }
4707
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4708
+								}
4709 4709
 
4710
-                                if ( !empty( $save_post['post_tags'] ) ) {
4711
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4712
-                                }
4710
+								if ( !empty( $save_post['post_tags'] ) ) {
4711
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4712
+								}
4713 4713
 
4714
-                                // Post images
4715
-                                if ( !empty( $post_images ) ) {
4716
-                                    $post_images = array_unique($post_images);
4714
+								// Post images
4715
+								if ( !empty( $post_images ) ) {
4716
+									$post_images = array_unique($post_images);
4717 4717
                                     
4718
-                                    $old_post_images_arr = array();
4719
-                                    $saved_post_images_arr = array();
4718
+									$old_post_images_arr = array();
4719
+									$saved_post_images_arr = array();
4720 4720
                                     
4721
-                                    $order = 1;
4721
+									$order = 1;
4722 4722
                                     
4723
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4724
-                                    if (!empty($old_post_images)) {
4725
-                                        foreach( $old_post_images as $old_post_image ) {
4726
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4727
-                                                $old_post_images_arr[] = $old_post_image->file;
4728
-                                            }
4729
-                                        }
4730
-                                    }
4723
+									$old_post_images = geodir_get_images( $saved_post_id );
4724
+									if (!empty($old_post_images)) {
4725
+										foreach( $old_post_images as $old_post_image ) {
4726
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4727
+												$old_post_images_arr[] = $old_post_image->file;
4728
+											}
4729
+										}
4730
+									}
4731 4731
                                     
4732
-                                    foreach ( $post_images as $post_image ) {
4733
-                                        $image_name = basename( $post_image );
4734
-                                        $saved_post_images_arr[] = $image_name;
4732
+									foreach ( $post_images as $post_image ) {
4733
+										$image_name = basename( $post_image );
4734
+										$saved_post_images_arr[] = $image_name;
4735 4735
                                         
4736
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4737
-                                            continue; // Skip if image already exists.
4738
-                                        }
4736
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4737
+											continue; // Skip if image already exists.
4738
+										}
4739 4739
                                         
4740
-                                        $image_name_parts = explode( '.', $image_name );
4741
-                                        array_pop( $image_name_parts );
4742
-                                        $proper_image_name = implode( '.', $image_name_parts );
4740
+										$image_name_parts = explode( '.', $image_name );
4741
+										array_pop( $image_name_parts );
4742
+										$proper_image_name = implode( '.', $image_name_parts );
4743 4743
                                         
4744
-                                        $arr_file_type = wp_check_filetype( $image_name );
4744
+										$arr_file_type = wp_check_filetype( $image_name );
4745 4745
                                         
4746
-                                        if ( !empty( $arr_file_type ) ) {
4747
-                                            $uploaded_file_type = $arr_file_type['type'];
4746
+										if ( !empty( $arr_file_type ) ) {
4747
+											$uploaded_file_type = $arr_file_type['type'];
4748 4748
                                             
4749
-                                            $attachment = array();
4750
-                                            $attachment['post_id'] = $saved_post_id;
4751
-                                            $attachment['title'] = $proper_image_name;
4752
-                                            $attachment['content'] = '';
4753
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4754
-                                            $attachment['mime_type'] = $uploaded_file_type;
4755
-                                            $attachment['menu_order'] = $order;
4756
-                                            $attachment['is_featured'] = 0;
4757
-
4758
-                                            $attachment_set = '';
4759
-                                            foreach ( $attachment as $key => $val ) {
4760
-                                                if ( $val != '' ) {
4761
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4762
-                                                }
4763
-                                            }
4764
-                                            $attachment_set = trim( $attachment_set, ", " );
4749
+											$attachment = array();
4750
+											$attachment['post_id'] = $saved_post_id;
4751
+											$attachment['title'] = $proper_image_name;
4752
+											$attachment['content'] = '';
4753
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
4754
+											$attachment['mime_type'] = $uploaded_file_type;
4755
+											$attachment['menu_order'] = $order;
4756
+											$attachment['is_featured'] = 0;
4757
+
4758
+											$attachment_set = '';
4759
+											foreach ( $attachment as $key => $val ) {
4760
+												if ( $val != '' ) {
4761
+													$attachment_set .= $key . " = '" . $val . "', ";
4762
+												}
4763
+											}
4764
+											$attachment_set = trim( $attachment_set, ", " );
4765 4765
                                                                                         
4766
-                                            // Add new attachment
4767
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4766
+											// Add new attachment
4767
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4768 4768
                                                                                         
4769
-                                            $order++;
4770
-                                        }
4771
-                                    }
4769
+											$order++;
4770
+										}
4771
+									}
4772 4772
 
4773
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4774
-                                    // Remove previous attachment
4775
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4773
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4774
+									// Remove previous attachment
4775
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4776 4776
                                     
4777
-                                    if ( !empty( $saved_post_images_arr ) ) {
4778
-                                        $menu_order = 1;
4777
+									if ( !empty( $saved_post_images_arr ) ) {
4778
+										$menu_order = 1;
4779 4779
                                         
4780
-                                        foreach ( $saved_post_images_arr as $img_name ) {
4781
-                                            $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4780
+										foreach ( $saved_post_images_arr as $img_name ) {
4781
+											$wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4782 4782
                                             
4783
-                                            if( $menu_order == 1 ) {
4784
-                                                if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4785
-                                                    $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4786
-                                                }
4787
-                                            }
4788
-                                            $menu_order++;
4789
-                                        }
4790
-                                    }
4783
+											if( $menu_order == 1 ) {
4784
+												if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4785
+													$wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4786
+												}
4787
+											}
4788
+											$menu_order++;
4789
+										}
4790
+									}
4791 4791
                                     
4792
-                                    if ( $order > 1 ) {
4793
-                                        $images++;
4794
-                                    }
4795
-                                }
4792
+									if ( $order > 1 ) {
4793
+										$images++;
4794
+									}
4795
+								}
4796 4796
 
4797
-                                /** This action is documented in geodirectory-functions/post-functions.php */
4798
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4797
+								/** This action is documented in geodirectory-functions/post-functions.php */
4798
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4799 4799
                                 
4800
-                                if (isset($is_featured)) {
4801
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4802
-                                }
4803
-                                if (isset($gd_post['expire_date'])) {
4804
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4805
-                                }
4806
-                            }
4800
+								if (isset($is_featured)) {
4801
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4802
+								}
4803
+								if (isset($gd_post['expire_date'])) {
4804
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4805
+								}
4806
+							}
4807 4807
                             
4808
-                            // WPML
4809
-                            if ($is_wpml && $language != '') {
4810
-                                $sitepress->switch_lang($active_lang, true);
4811
-                            }
4812
-                            // WPML
4813
-                        }
4814
-                    }
4815
-                }
4808
+							// WPML
4809
+							if ($is_wpml && $language != '') {
4810
+								$sitepress->switch_lang($active_lang, true);
4811
+							}
4812
+							// WPML
4813
+						}
4814
+					}
4815
+				}
4816 4816
 
4817
-                //undo some stuff to make the import quicker
4818
-                wp_defer_term_counting( false );
4819
-                wp_defer_comment_counting( false );
4820
-                $wpdb->query( 'COMMIT;' );
4821
-                $wpdb->query( 'SET autocommit = 1;' );
4822
-
4823
-                $json = array();
4824
-                $json['processed'] = $processed_actual;
4825
-                $json['created'] = $created;
4826
-                $json['updated'] = $updated;
4827
-                $json['skipped'] = $skipped;
4828
-                $json['invalid'] = $invalid;
4829
-                $json['invalid_addr'] = $invalid_addr;
4830
-                $json['images'] = $images;
4817
+				//undo some stuff to make the import quicker
4818
+				wp_defer_term_counting( false );
4819
+				wp_defer_comment_counting( false );
4820
+				$wpdb->query( 'COMMIT;' );
4821
+				$wpdb->query( 'SET autocommit = 1;' );
4822
+
4823
+				$json = array();
4824
+				$json['processed'] = $processed_actual;
4825
+				$json['created'] = $created;
4826
+				$json['updated'] = $updated;
4827
+				$json['skipped'] = $skipped;
4828
+				$json['invalid'] = $invalid;
4829
+				$json['invalid_addr'] = $invalid_addr;
4830
+				$json['images'] = $images;
4831 4831
                 
4832
-                wp_send_json( $json );
4833
-                exit;
4834
-            } else if ( $task == 'import_loc' ) {
4835
-                global $gd_post_types;
4836
-                $gd_post_types = $post_types;
4832
+				wp_send_json( $json );
4833
+				exit;
4834
+			} else if ( $task == 'import_loc' ) {
4835
+				global $gd_post_types;
4836
+				$gd_post_types = $post_types;
4837 4837
                 
4838
-                if (!empty($file)) {
4839
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4838
+				if (!empty($file)) {
4839
+					$columns = isset($file[0]) ? $file[0] : NULL;
4840 4840
                     
4841
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4842
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4843
-                        wp_send_json( $json );
4844
-                    }
4841
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4842
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4843
+						wp_send_json( $json );
4844
+					}
4845 4845
                     
4846
-                    for ($i = 1; $i <= $limit; $i++) {
4847
-                        $index = $processed + $i;
4846
+					for ($i = 1; $i <= $limit; $i++) {
4847
+						$index = $processed + $i;
4848 4848
                         
4849
-                        if (isset($file[$index])) {
4850
-                            $row = $file[$index];
4851
-                            $row = array_map( 'trim', $row );
4852
-                            $data = array();
4849
+						if (isset($file[$index])) {
4850
+							$row = $file[$index];
4851
+							$row = array_map( 'trim', $row );
4852
+							$data = array();
4853 4853
                             
4854
-                            foreach ($columns as $c => $column ) {
4855
-                                if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
4856
-                                    $data[$column] = $row[$c];
4857
-                                }
4858
-                            }
4854
+							foreach ($columns as $c => $column ) {
4855
+								if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
4856
+									$data[$column] = $row[$c];
4857
+								}
4858
+							}
4859 4859
 
4860
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4861
-                                $invalid++;
4862
-                                continue;
4863
-                            }
4860
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4861
+								$invalid++;
4862
+								continue;
4863
+							}
4864 4864
                             
4865
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4865
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4866 4866
                             
4867
-                            if ( $import_choice == 'update' ) {
4868
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4869
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4870
-                                        $updated++;
4871
-                                    } else {
4872
-                                        $invalid++;
4873
-                                    }
4874
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4875
-                                    $data['location_id'] = (int)$location->location_id;
4867
+							if ( $import_choice == 'update' ) {
4868
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4869
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4870
+										$updated++;
4871
+									} else {
4872
+										$invalid++;
4873
+									}
4874
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4875
+									$data['location_id'] = (int)$location->location_id;
4876 4876
                                     
4877
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4878
-                                        $data['location_id'] = (int)$location->location_id;
4879
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4880
-                                        $data['location_id'] = (int)$location->location_id;
4881
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4882
-                                        $data['location_id'] = (int)$location->location_id;
4883
-                                    }
4877
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4878
+										$data['location_id'] = (int)$location->location_id;
4879
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4880
+										$data['location_id'] = (int)$location->location_id;
4881
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4882
+										$data['location_id'] = (int)$location->location_id;
4883
+									}
4884 4884
                                     
4885
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4886
-                                        $updated++;
4887
-                                    } else {
4888
-                                        $invalid++;
4889
-                                    }
4890
-                                } else {
4891
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4892
-                                        $created++;
4893
-                                    } else {
4894
-                                        $invalid++;
4895
-                                    }
4896
-                                }
4897
-                            } elseif ( $import_choice == 'skip' ) {
4898
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4899
-                                    $skipped++;
4900
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4901
-                                    $skipped++;
4902
-                                } else {
4903
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4904
-                                        $created++;
4905
-                                    } else {
4906
-                                        $invalid++;
4907
-                                    }
4908
-                                }
4909
-                            } else {
4910
-                                $invalid++;
4911
-                            }
4912
-                        }
4913
-                    }
4914
-                }
4885
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4886
+										$updated++;
4887
+									} else {
4888
+										$invalid++;
4889
+									}
4890
+								} else {
4891
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4892
+										$created++;
4893
+									} else {
4894
+										$invalid++;
4895
+									}
4896
+								}
4897
+							} elseif ( $import_choice == 'skip' ) {
4898
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4899
+									$skipped++;
4900
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4901
+									$skipped++;
4902
+								} else {
4903
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4904
+										$created++;
4905
+									} else {
4906
+										$invalid++;
4907
+									}
4908
+								}
4909
+							} else {
4910
+								$invalid++;
4911
+							}
4912
+						}
4913
+					}
4914
+				}
4915 4915
                 
4916
-                $json = array();
4917
-                $json['processed'] = $limit;
4918
-                $json['created'] = $created;
4919
-                $json['updated'] = $updated;
4920
-                $json['skipped'] = $skipped;
4921
-                $json['invalid'] = $invalid;
4922
-                $json['images'] = $images;
4916
+				$json = array();
4917
+				$json['processed'] = $limit;
4918
+				$json['created'] = $created;
4919
+				$json['updated'] = $updated;
4920
+				$json['skipped'] = $skipped;
4921
+				$json['invalid'] = $invalid;
4922
+				$json['images'] = $images;
4923 4923
                 
4924
-                wp_send_json( $json );
4925
-            } else if ( $task == 'import_hood' ) {               
4926
-                if (!empty($file)) {
4927
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4924
+				wp_send_json( $json );
4925
+			} else if ( $task == 'import_hood' ) {               
4926
+				if (!empty($file)) {
4927
+					$columns = isset($file[0]) ? $file[0] : NULL;
4928 4928
                     
4929
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4930
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4931
-                        wp_send_json( $json );
4932
-                    }
4929
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4930
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4931
+						wp_send_json( $json );
4932
+					}
4933 4933
                     
4934
-                    for ($i = 1; $i <= $limit; $i++) {
4935
-                        $index = $processed + $i;
4934
+					for ($i = 1; $i <= $limit; $i++) {
4935
+						$index = $processed + $i;
4936 4936
                         
4937
-                        if (isset($file[$index])) {
4938
-                            $row = $file[$index];
4939
-                            $row = array_map( 'trim', $row );
4940
-                            $data = array();
4937
+						if (isset($file[$index])) {
4938
+							$row = $file[$index];
4939
+							$row = array_map( 'trim', $row );
4940
+							$data = array();
4941 4941
                             
4942
-                            foreach ($columns as $c => $column) {
4943
-                                if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
4944
-                                    $data[$column] = sanitize_text_field($row[$c]);
4945
-                                }
4946
-                            }
4942
+							foreach ($columns as $c => $column) {
4943
+								if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
4944
+									$data[$column] = sanitize_text_field($row[$c]);
4945
+								}
4946
+							}
4947 4947
 
4948
-                            if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
4949
-                                $invalid++;
4950
-                                continue;
4951
-                            }
4948
+							if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
4949
+								$invalid++;
4950
+								continue;
4951
+							}
4952 4952
                             
4953
-                            $location_info = array();
4954
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4955
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4956
-                            } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4957
-                                $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4958
-                            }
4953
+							$location_info = array();
4954
+							if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4955
+								$location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4956
+							} else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4957
+								$location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4958
+							}
4959 4959
 
4960
-                            if (empty($location_info)) {
4961
-                                $invalid++;
4962
-                                continue;
4963
-                            }
4960
+							if (empty($location_info)) {
4961
+								$invalid++;
4962
+								continue;
4963
+							}
4964 4964
                             
4965
-                            $location_id = $location_info->location_id;
4965
+							$location_id = $location_info->location_id;
4966 4966
 
4967
-                            $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
4967
+							$data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
4968 4968
                             
4969
-                            $hood_data = array();
4970
-                            $hood_data['hood_name'] = $data['neighbourhood_name'];
4971
-                            $hood_data['hood_slug'] = $data['neighbourhood_slug'];
4972
-                            $hood_data['hood_latitude'] = $data['longitude'];
4973
-                            $hood_data['hood_longitude'] = $data['longitude'];
4974
-                            $hood_data['hood_location_id'] = $location_id;
4969
+							$hood_data = array();
4970
+							$hood_data['hood_name'] = $data['neighbourhood_name'];
4971
+							$hood_data['hood_slug'] = $data['neighbourhood_slug'];
4972
+							$hood_data['hood_latitude'] = $data['longitude'];
4973
+							$hood_data['hood_longitude'] = $data['longitude'];
4974
+							$hood_data['hood_location_id'] = $location_id;
4975 4975
                                     
4976
-                            if ( $import_choice == 'update' ) {
4977
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4978
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4976
+							if ( $import_choice == 'update' ) {
4977
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4978
+									$hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4979 4979
                                     
4980
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4981
-                                        $updated++;
4982
-                                    } else {
4983
-                                        $invalid++;
4984
-                                    }
4985
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4986
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4980
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4981
+										$updated++;
4982
+									} else {
4983
+										$invalid++;
4984
+									}
4985
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4986
+									$hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4987 4987
                                     
4988
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4989
-                                        $updated++;
4990
-                                    } else {
4991
-                                        $invalid++;
4992
-                                    }
4993
-                                } else {
4994
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4995
-                                        $created++;
4996
-                                    } else {
4997
-                                        $invalid++;
4998
-                                    }
4999
-                                }
5000
-                            } elseif ( $import_choice == 'skip' ) {
5001
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5002
-                                    $skipped++;
5003
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5004
-                                    $skipped++;
5005
-                                } else {
4988
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4989
+										$updated++;
4990
+									} else {
4991
+										$invalid++;
4992
+									}
4993
+								} else {
4994
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4995
+										$created++;
4996
+									} else {
4997
+										$invalid++;
4998
+									}
4999
+								}
5000
+							} elseif ( $import_choice == 'skip' ) {
5001
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5002
+									$skipped++;
5003
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5004
+									$skipped++;
5005
+								} else {
5006 5006
                                     
5007
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5008
-                                        $created++;
5009
-                                    } else {
5010
-                                        $invalid++;
5011
-                                    }
5012
-                                }
5013
-                            } else {
5014
-                                $invalid++;
5015
-                            }
5016
-                        }
5017
-                    }
5018
-                }
5007
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5008
+										$created++;
5009
+									} else {
5010
+										$invalid++;
5011
+									}
5012
+								}
5013
+							} else {
5014
+								$invalid++;
5015
+							}
5016
+						}
5017
+					}
5018
+				}
5019 5019
                 
5020
-                $json = array();
5021
-                $json['processed'] = $limit;
5022
-                $json['created'] = $created;
5023
-                $json['updated'] = $updated;
5024
-                $json['skipped'] = $skipped;
5025
-                $json['invalid'] = $invalid;
5026
-                $json['images'] = $images;
5020
+				$json = array();
5021
+				$json['processed'] = $limit;
5022
+				$json['created'] = $created;
5023
+				$json['updated'] = $updated;
5024
+				$json['skipped'] = $skipped;
5025
+				$json['invalid'] = $invalid;
5026
+				$json['images'] = $images;
5027 5027
                 
5028
-                wp_send_json( $json );
5029
-            }
5030
-        }
5031
-        break;
5032
-        case 'import_finish':{
5033
-            /**
5034
-             * Run an action when an import finishes.
5035
-             *
5036
-             * This action can be used to fire functions after an import ends.
5037
-             *
5038
-             * @since 1.5.3
5039
-             * @package GeoDirectory
5040
-             */
5041
-            do_action('geodir_import_finished');
5042
-        }
5043
-        break;
5028
+				wp_send_json( $json );
5029
+			}
5030
+		}
5031
+		break;
5032
+		case 'import_finish':{
5033
+			/**
5034
+			 * Run an action when an import finishes.
5035
+			 *
5036
+			 * This action can be used to fire functions after an import ends.
5037
+			 *
5038
+			 * @since 1.5.3
5039
+			 * @package GeoDirectory
5040
+			 */
5041
+			do_action('geodir_import_finished');
5042
+		}
5043
+		break;
5044 5044
 
5045
-    }
5046
-    echo '0';
5047
-    wp_die();
5045
+	}
5046
+	echo '0';
5047
+	wp_die();
5048 5048
 }
5049 5049
 
5050 5050
 /**
@@ -5088,12 +5088,12 @@  discard block
 block discarded – undo
5088 5088
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5089 5089
 	}
5090 5090
 	
5091
-    if( !empty( $term ) ) {
5091
+	if( !empty( $term ) ) {
5092 5092
 		$result = wp_insert_term( $term, $taxonomy, $args );
5093
-        if( !is_wp_error( $result ) ) {
5094
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5095
-        }
5096
-    }
5093
+		if( !is_wp_error( $result ) ) {
5094
+			return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5095
+		}
5096
+	}
5097 5097
 	
5098 5098
 	return false;
5099 5099
 }
@@ -5140,16 +5140,16 @@  discard block
 block discarded – undo
5140 5140
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5141 5141
 		
5142 5142
 		if( !is_wp_error( $result ) ) {
5143
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5144
-        }
5143
+			return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5144
+		}
5145 5145
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5146 5146
 		$term_data['term_id'] = $term_info['term_id'];
5147 5147
 		
5148 5148
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5149 5149
 		
5150 5150
 		if( !is_wp_error( $result ) ) {
5151
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5152
-        }
5151
+			return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5152
+		}
5153 5153
 	} else {
5154 5154
 		return geodir_imex_insert_term( $taxonomy, $term_data );
5155 5155
 	}
@@ -5174,7 +5174,7 @@  discard block
 block discarded – undo
5174 5174
 	 * Modify returned post counts for the current post type.
5175 5175
 	 *
5176 5176
 	 * @since 1.4.6
5177
-     * @package GeoDirectory
5177
+	 * @package GeoDirectory
5178 5178
 	 *
5179 5179
 	 * @param int $posts_count Post counts.
5180 5180
 	 * @param string $post_type Post type.
@@ -5237,9 +5237,9 @@  discard block
 block discarded – undo
5237 5237
 	
5238 5238
 	if ( !empty( $posts ) ) {
5239 5239
 		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5240
-        $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5241
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5242
-        $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5240
+		$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5241
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5242
+		$neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5243 5243
 		
5244 5244
 		$csv_row = array();
5245 5245
 		$csv_row[] = 'post_id';
@@ -5283,11 +5283,11 @@  discard block
 block discarded – undo
5283 5283
 		$csv_row[] = 'post_zip';
5284 5284
 		$csv_row[] = 'post_latitude';
5285 5285
 		$csv_row[] = 'post_longitude';
5286
-        if ($neighbourhood_active) {
5287
-            $csv_row[] = 'post_neighbourhood';
5288
-            $csv_row[] = 'neighbourhood_latitude';
5289
-            $csv_row[] = 'neighbourhood_longitude';
5290
-        }
5286
+		if ($neighbourhood_active) {
5287
+			$csv_row[] = 'post_neighbourhood';
5288
+			$csv_row[] = 'neighbourhood_latitude';
5289
+			$csv_row[] = 'neighbourhood_longitude';
5290
+		}
5291 5291
 		$csv_row[] = 'geodir_timing';
5292 5292
 		$csv_row[] = 'geodir_contact';
5293 5293
 		$csv_row[] = 'geodir_email';
@@ -5322,7 +5322,7 @@  discard block
 block discarded – undo
5322 5322
 		$csv_rows[] = $csv_row;
5323 5323
 
5324 5324
 		$images_count = 5;
5325
-        $xx=0;
5325
+		$xx=0;
5326 5326
 		foreach ( $posts as $post ) {$xx++;
5327 5327
 			$post_id = $post['ID'];
5328 5328
 			
@@ -5469,21 +5469,21 @@  discard block
 block discarded – undo
5469 5469
 			$csv_row[] = $post_info['post_zip']; // post_zip
5470 5470
 			$csv_row[] = $post_info['post_latitude']; // post_latitude
5471 5471
 			$csv_row[] = $post_info['post_longitude']; // post_longitude
5472
-            if ($neighbourhood_active) {
5473
-                $post_neighbourhood = '';
5474
-                $neighbourhood_latitude = '';
5475
-                $neighbourhood_longitude = '';
5476
-                if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5477
-                    if (!empty($hood_info)) {
5478
-                        $post_neighbourhood = $hood_info->hood_name;
5479
-                        $neighbourhood_latitude = $hood_info->hood_latitude;
5480
-                        $neighbourhood_longitude = $hood_info->hood_longitude;
5481
-                    }
5482
-                }
5483
-                $csv_row[] = $post_neighbourhood; // post_neighbourhood
5484
-                $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5485
-                $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5486
-            }
5472
+			if ($neighbourhood_active) {
5473
+				$post_neighbourhood = '';
5474
+				$neighbourhood_latitude = '';
5475
+				$neighbourhood_longitude = '';
5476
+				if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5477
+					if (!empty($hood_info)) {
5478
+						$post_neighbourhood = $hood_info->hood_name;
5479
+						$neighbourhood_latitude = $hood_info->hood_latitude;
5480
+						$neighbourhood_longitude = $hood_info->hood_longitude;
5481
+					}
5482
+				}
5483
+				$csv_row[] = $post_neighbourhood; // post_neighbourhood
5484
+				$csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5485
+				$csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5486
+			}
5487 5487
 			$csv_row[] = $post_info['geodir_timing']; // geodir_timing
5488 5488
 			$csv_row[] = $post_info['geodir_contact']; // geodir_contact
5489 5489
 			$csv_row[] = $post_info['geodir_email']; // geodir_email
@@ -5577,7 +5577,7 @@  discard block
 block discarded – undo
5577 5577
 	 * Modify returned posts SQL query for the current post type.
5578 5578
 	 *
5579 5579
 	 * @since 1.4.6
5580
-     * @package GeoDirectory
5580
+	 * @package GeoDirectory
5581 5581
 	 *
5582 5582
 	 * @param int $query The SQL query.
5583 5583
 	 * @param string $post_type Post type.
@@ -5590,7 +5590,7 @@  discard block
 block discarded – undo
5590 5590
 	 * Modify returned post results for the current post type.
5591 5591
 	 *
5592 5592
 	 * @since 1.4.6
5593
-     * @package GeoDirectory
5593
+	 * @package GeoDirectory
5594 5594
 	 *
5595 5595
 	 * @param object $results An object containing all post ids.
5596 5596
 	 * @param string $post_type Post type.
@@ -6315,43 +6315,43 @@  discard block
 block discarded – undo
6315 6315
  * @param string $status Post status.
6316 6316
  */
6317 6317
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
6318
-    global $wpdb, $current_user;
6319
-
6320
-    $option_value = get_option($option);
6321
-
6322
-    if ($option_value > 0) :
6323
-        if (get_post($option_value)) :
6324
-            // Page exists
6325
-            return;
6326
-        endif;
6327
-    endif;
6328
-
6329
-    $page_found = $wpdb->get_var(
6330
-        $wpdb->prepare(
6331
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6332
-            array($slug)
6333
-        )
6334
-    );
6335
-
6336
-    if ($page_found) :
6337
-        // Page exists
6338
-        if (!$option_value) update_option($option, $page_found);
6339
-        return;
6340
-    endif;
6341
-
6342
-    $page_data = array(
6343
-        'post_status' => $status,
6344
-        'post_type' => 'page',
6345
-        'post_author' => $current_user->ID,
6346
-        'post_name' => $slug,
6347
-        'post_title' => $page_title,
6348
-        'post_content' => $page_content,
6349
-        'post_parent' => $post_parent,
6350
-        'comment_status' => 'closed'
6351
-    );
6352
-    $page_id = wp_insert_post($page_data);
6353
-
6354
-    add_option($option, $page_id);
6318
+	global $wpdb, $current_user;
6319
+
6320
+	$option_value = get_option($option);
6321
+
6322
+	if ($option_value > 0) :
6323
+		if (get_post($option_value)) :
6324
+			// Page exists
6325
+			return;
6326
+		endif;
6327
+	endif;
6328
+
6329
+	$page_found = $wpdb->get_var(
6330
+		$wpdb->prepare(
6331
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6332
+			array($slug)
6333
+		)
6334
+	);
6335
+
6336
+	if ($page_found) :
6337
+		// Page exists
6338
+		if (!$option_value) update_option($option, $page_found);
6339
+		return;
6340
+	endif;
6341
+
6342
+	$page_data = array(
6343
+		'post_status' => $status,
6344
+		'post_type' => 'page',
6345
+		'post_author' => $current_user->ID,
6346
+		'post_name' => $slug,
6347
+		'post_title' => $page_title,
6348
+		'post_content' => $page_content,
6349
+		'post_parent' => $post_parent,
6350
+		'comment_status' => 'closed'
6351
+	);
6352
+	$page_id = wp_insert_post($page_data);
6353
+
6354
+	add_option($option, $page_id);
6355 6355
 
6356 6356
 }
6357 6357
 
@@ -6382,9 +6382,9 @@  discard block
 block discarded – undo
6382 6382
  * @package GeoDirectory
6383 6383
  */
6384 6384
 function geodir_admin_upgrade_notice() {
6385
-    $class = "error";
6386
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6387
-    echo"<div class=\"$class\"> <p>$message</p></div>";
6385
+	$class = "error";
6386
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6387
+	echo"<div class=\"$class\"> <p>$message</p></div>";
6388 6388
 }
6389 6389
 
6390 6390
 /**
@@ -6397,18 +6397,18 @@  discard block
 block discarded – undo
6397 6397
  */
6398 6398
 function geodire_admin_upgrade_notice( $plugin_data, $r )
6399 6399
 {
6400
-    // readme contents
6401
-    $args = array(
6402
-        'timeout'     => 15,
6403
-        'redirection' => 5
6404
-    );
6405
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6406
-    $data       = wp_remote_get( $url, $args );
6400
+	// readme contents
6401
+	$args = array(
6402
+		'timeout'     => 15,
6403
+		'redirection' => 5
6404
+	);
6405
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6406
+	$data       = wp_remote_get( $url, $args );
6407 6407
 
6408
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
6408
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
6409 6409
 
6410
-        geodir_in_plugin_update_message($data['body']);
6411
-    }
6410
+		geodir_in_plugin_update_message($data['body']);
6411
+	}
6412 6412
 }
6413 6413
 
6414 6414
 
@@ -6416,28 +6416,28 @@  discard block
 block discarded – undo
6416 6416
 * @param string $body http response body
6417 6417
 */
6418 6418
 function geodir_in_plugin_update_message($content) {
6419
-    // Output Upgrade Notice
6420
-    $matches        = null;
6421
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6422
-    $upgrade_notice = '';
6423
-    if ( preg_match( $regexp, $content, $matches ) ) {
6424
-        if(empty($matches)){return;}
6425
-
6426
-        $version = trim( $matches[1] );
6427
-        if($version && $version>GEODIRECTORY_VERSION){
6428
-
6429
-
6430
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6431
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6432
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6433
-            foreach ( $notices as $index => $line ) {
6434
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6435
-            }
6436
-            $upgrade_notice .= '</div> ';
6437
-        }
6438
-        }
6439
-    }
6440
-    echo $upgrade_notice;
6419
+	// Output Upgrade Notice
6420
+	$matches        = null;
6421
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6422
+	$upgrade_notice = '';
6423
+	if ( preg_match( $regexp, $content, $matches ) ) {
6424
+		if(empty($matches)){return;}
6425
+
6426
+		$version = trim( $matches[1] );
6427
+		if($version && $version>GEODIRECTORY_VERSION){
6428
+
6429
+
6430
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6431
+		if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6432
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6433
+			foreach ( $notices as $index => $line ) {
6434
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6435
+			}
6436
+			$upgrade_notice .= '</div> ';
6437
+		}
6438
+		}
6439
+	}
6440
+	echo $upgrade_notice;
6441 6441
 }
6442 6442
 
6443 6443
 /**
Please login to merge, or discard this patch.
geodirectory-admin/admin_hooks_actions.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -1639,6 +1639,7 @@
 block discarded – undo
1639 1639
  * @since 1.0.0
1640 1640
  * @package GeoDirectory
1641 1641
  * @global object $current_user Current user object.
1642
+ * @param string|null $input
1642 1643
  * @return array Returns parsed data as array.
1643 1644
  */
1644 1645
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+    geodir_admin_option_form($current_tab); // defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
71 71
 add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
72 72
 add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
73
-add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
73
+add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
74 74
 
75 75
 //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
76 76
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 }
238 238
 
239
-add_action('save_post', 'geodir_post_information_save',10,2);
239
+add_action('save_post', 'geodir_post_information_save', 10, 2);
240 240
 
241 241
 
242 242
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
             $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
265 265
 
266
-            if(!empty($gd_taxonomy)) {
266
+            if (!empty($gd_taxonomy)) {
267 267
                 foreach ($gd_taxonomy as $tax) {
268 268
 
269 269
                     remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     global $wpdb;
416 416
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
417 417
     ?>
418
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
418
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
419 419
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
420 420
     <ul>
421 421
     <?php
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
             
434 434
             $display = $check_html_variable ? ' style="display:none;"' : '';
435 435
             ?>
436
-            <li <?php echo $display;?>>
437
-            <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>"
438
-               title="<?php echo $val['site_title'];?>"
439
-               class="gt-draggable-form-items gt-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>"
440
-               href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a>
436
+            <li <?php echo $display; ?>>
437
+            <a id="gt-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>"
438
+               title="<?php echo $val['site_title']; ?>"
439
+               class="gt-draggable-form-items gt-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>"
440
+               href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory'); ?></a>
441 441
             </li>
442 442
             <?php
443 443
         }
@@ -491,39 +491,39 @@  discard block
 block discarded – undo
491 491
 {
492 492
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
493 493
     ?>
494
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
494
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
495 495
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
496 496
     <ul class="full">
497
-        <li><a id="gt-fieldset" class="gt-draggable-form-items gt-fieldset" href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory');?></a></li>
497
+        <li><a id="gt-fieldset" class="gt-draggable-form-items gt-fieldset" href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory'); ?></a></li>
498 498
     </ul>
499 499
     <ul>
500 500
         <li><a id="gt-text" class="gt-draggable-form-items gt-text"
501
-               href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory');?></a></li>
501
+               href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory'); ?></a></li>
502 502
         <li><a id="gt-datepicker" class="gt-draggable-form-items gt-datepicker"
503
-               href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory');?></a></li>
503
+               href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory'); ?></a></li>
504 504
         <li><a id="gt-textarea" class="gt-draggable-form-items gt-textarea"
505
-               href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory');?></a></li>
505
+               href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory'); ?></a></li>
506 506
         <li><a id="gt-time" class="gt-draggable-form-items gt-time"
507
-               href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory');?></a></li>
507
+               href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory'); ?></a></li>
508 508
         <li><a id="gt-checkbox" class="gt-draggable-form-items gt-checkbox"
509
-               href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory');?></a></li>
509
+               href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory'); ?></a></li>
510 510
         <li><a id="gt-phone" class="gt-draggable-form-items gt-phone"
511
-               href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory');?></a></li>
511
+               href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory'); ?></a></li>
512 512
         <li><a id="gt-radio" class="gt-draggable-form-items gt-radio"
513
-               href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory');?></a></li>
513
+               href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory'); ?></a></li>
514 514
         <li><a id="gt-email" class="gt-draggable-form-items gt-email"
515
-               href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory');?></a></li>
515
+               href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory'); ?></a></li>
516 516
         <li><a id="gt-select" class="gt-draggable-form-items gt-select"
517
-               href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory');?></a></li>
518
-        <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory');?></a></li>-->
517
+               href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory'); ?></a></li>
518
+        <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory'); ?></a></li>-->
519 519
         <li><a id="gt-multiselect" class="gt-draggable-form-items gt-multiselect"
520
-               href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory');?></a></li>
520
+               href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory'); ?></a></li>
521 521
         <li><a id="gt-url" class="gt-draggable-form-items gt-url"
522
-               href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory');?></a></li>
522
+               href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory'); ?></a></li>
523 523
         <li><a id="gt-html" class="gt-draggable-form-items gt-html"
524
-               href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory');?></a></li>
524
+               href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory'); ?></a></li>
525 525
         <li><a id="gt-file" class="gt-draggable-form-items gt-file"
526
-               href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory');?></a></li>
526
+               href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory'); ?></a></li>
527 527
 
528 528
     </ul>
529 529
 
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 
635 635
     switch ($sub_tab) {
636 636
         case 'custom_fields':
637
-            $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));;
637
+            $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)); ;
638 638
             break;
639 639
 
640 640
         case 'sorting_options':
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 
689 689
     switch ($sub_tab) {
690 690
         case 'custom_fields':
691
-            $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));;
691
+            $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)); ;
692 692
             break;
693 693
 
694 694
         case 'sorting_options':
@@ -787,13 +787,13 @@  discard block
 block discarded – undo
787 787
         $filter_arr['is_error_during_diagnose'] = true;
788 788
 
789 789
         if ($fix) {
790
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
791
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
790
+            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak"); // get backup table count
791
+            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table"); // get new table count
792 792
 
793 793
             if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
794 794
                 //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
795 795
 
796
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
796
+                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2"); // rename bak table to new table
797 797
 
798 798
                 if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
799 799
                     $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 
804 804
             } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
805 805
 
806
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
807
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
806
+                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2"); // rename new table to bak2
807
+                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table"); // rename bak table to new table
808 808
 
809 809
                 if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
810 810
                     $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 
815 815
             } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
816 816
 
817
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
817
+                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2"); // rename ms_bak table to ms_bak2
818 818
 
819 819
                 if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
820 820
                     $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
                             $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
999 999
                             foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1000 1000
                                 if (is_numeric($cat_part)) {
1001
-                                    $raw_cats[] = (int)$cat_part;
1001
+                                    $raw_cats[] = (int) $cat_part;
1002 1002
                                 }
1003 1003
                             }
1004 1004
 
@@ -1308,9 +1308,9 @@  discard block
 block discarded – undo
1308 1308
     //////////////////////////////////
1309 1309
     $option_value = get_option('geodir_home_page');
1310 1310
     $page = get_post($option_value);
1311
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1311
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1312 1312
 
1313
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1313
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1314 1314
         $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1315 1315
     else {
1316 1316
         $is_error_during_diagnose = true;
@@ -1333,9 +1333,9 @@  discard block
 block discarded – undo
1333 1333
     //////////////////////////////////
1334 1334
     $option_value = get_option('geodir_add_listing_page');
1335 1335
     $page = get_post($option_value);
1336
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1336
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1337 1337
 
1338
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1338
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1339 1339
         $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1340 1340
     else {
1341 1341
         $is_error_during_diagnose = true;
@@ -1359,9 +1359,9 @@  discard block
 block discarded – undo
1359 1359
     //////////////////////////////////
1360 1360
     $option_value = get_option('geodir_preview_page');
1361 1361
     $page = get_post($option_value);
1362
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1362
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1363 1363
 
1364
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1364
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1365 1365
         $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1366 1366
     else {
1367 1367
         $is_error_during_diagnose = true;
@@ -1384,9 +1384,9 @@  discard block
 block discarded – undo
1384 1384
     //////////////////////////////////
1385 1385
     $option_value = get_option('geodir_success_page');
1386 1386
     $page = get_post($option_value);
1387
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1387
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1388 1388
 
1389
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1389
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1390 1390
         $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1391 1391
     else {
1392 1392
         $is_error_during_diagnose = true;
@@ -1409,9 +1409,9 @@  discard block
 block discarded – undo
1409 1409
     //////////////////////////////////
1410 1410
     $option_value = get_option('geodir_info_page');
1411 1411
     $page = get_post($option_value);
1412
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1412
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1413 1413
 
1414
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1414
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1415 1415
         $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1416 1416
     else {
1417 1417
         $is_error_during_diagnose = true;
@@ -1434,9 +1434,9 @@  discard block
 block discarded – undo
1434 1434
     //////////////////////////////////
1435 1435
     $option_value = get_option('geodir_login_page');
1436 1436
     $page = get_post($option_value);
1437
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1437
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1438 1438
 
1439
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1439
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1440 1440
         $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1441 1441
     else {
1442 1442
         $is_error_during_diagnose = true;
@@ -1459,9 +1459,9 @@  discard block
 block discarded – undo
1459 1459
     //////////////////////////////////
1460 1460
     $option_value = get_option('geodir_location_page');
1461 1461
     $page = get_post($option_value);
1462
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1462
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1463 1463
 
1464
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1464
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1465 1465
         $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1466 1466
     else {
1467 1467
         $is_error_during_diagnose = true;
@@ -1479,13 +1479,13 @@  discard block
 block discarded – undo
1479 1479
     /* Diagnose Location Page Ends */
1480 1480
     ////////////////////////////////
1481 1481
 
1482
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1482
+    $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
1483 1483
     /**
1484 1484
      * This action is called at the end of the GD Tools page check function.
1485 1485
      *
1486 1486
      * @since 1.5.2
1487 1487
      */
1488
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1488
+    $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
1489 1489
 
1490 1490
     $output_str = $page_chk_arr['output_str'];
1491 1491
     $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 
1683 1683
                 if (($handle = fopen($target_path, "r")) !== FALSE) {
1684 1684
                     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1685
-                        if(is_array($data) && !empty($data)) {
1685
+                        if (is_array($data) && !empty($data)) {
1686 1686
                             $file[] = '"' . implode('","', $data) . '"';
1687 1687
                         }
1688 1688
                     }
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
 						
1858 1858
 						// Post status
1859 1859
 						if ($customKeyarray[$c] == 'post_status') {
1860
-                            $post_status = sanitize_key( $buffer[$c] );
1860
+                            $post_status = sanitize_key($buffer[$c]);
1861 1861
                         }
1862 1862
                     }
1863 1863
 
@@ -1875,8 +1875,8 @@  discard block
 block discarded – undo
1875 1875
 					
1876 1876
 					// Default post status
1877 1877
 					$default_status = 'publish';
1878
-					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
1879
-					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
1878
+					$post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
1879
+					$post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
1880 1880
 
1881 1881
                     $my_post['post_title'] = $post_title;
1882 1882
                     $my_post['post_content'] = $post_desc;
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
                     $payment_info = array();
1921 1921
                     $package_info = array();
1922 1922
 
1923
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1923
+                    $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]);
1924 1924
                     $package_id = '';
1925 1925
                     if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1926 1926
                         $package_id = $gd_post_info['package_id'];
@@ -2021,11 +2021,11 @@  discard block
 block discarded – undo
2021 2021
 }
2022 2022
 
2023 2023
 // Add the tab in left sidebar menu fro import & export page.
2024
-add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 );
2024
+add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
2025 2025
 
2026 2026
 // Handle ajax request for impot/export.
2027
-add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' );
2028
-add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' );
2027
+add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
2028
+add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
2029 2029
 
2030 2030
 
2031 2031
 /**
@@ -2036,40 +2036,40 @@  discard block
 block discarded – undo
2036 2036
  * @param $post_id int $post_id The post ID of the post being saved.
2037 2037
  * @param $post object $post The post object of the post being saved.
2038 2038
  */
2039
-function geodir_update_location_prefix($post_id,$post){
2040
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2041
-        update_option('geodir_location_prefix',$post->post_name);
2039
+function geodir_update_location_prefix($post_id, $post) {
2040
+    if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
2041
+        update_option('geodir_location_prefix', $post->post_name);
2042 2042
     }
2043 2043
 
2044 2044
 }
2045 2045
 
2046
-add_action('save_post', 'geodir_update_location_prefix',10,2);
2046
+add_action('save_post', 'geodir_update_location_prefix', 10, 2);
2047 2047
 
2048
-add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' );
2048
+add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
2049 2049
 
2050
-function geodir_ga_callback(){
2050
+function geodir_ga_callback() {
2051 2051
 
2052
-if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2052
+if (isset($_REQUEST['code']) && $_REQUEST['code']) {
2053 2053
     $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2054
-    $code = "code=".$_REQUEST['code'];
2054
+    $code = "code=" . $_REQUEST['code'];
2055 2055
     $grant_type = "&grant_type=authorization_code";
2056 2056
     $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2057
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2058
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2057
+    $client_id = "&client_id=" . get_option('geodir_ga_client_id');
2058
+    $client_secret = "&client_secret=" . get_option('geodir_ga_client_secret');
2059 2059
 
2060
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2060
+    $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id . $client_secret;
2061 2061
 
2062 2062
     $response = wp_remote_post($auth_url, array('timeout' => 15));
2063 2063
 
2064 2064
     //print_r($response);
2065 2065
 
2066
-    $error_msg =  __('Something went wrong','geodirectory');
2067
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2066
+    $error_msg = __('Something went wrong', 'geodirectory');
2067
+    if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
2068 2068
 
2069 2069
         $parts = json_decode($response['body']);
2070 2070
         //print_r($parts);
2071
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2072
-        else{
2071
+        if (!isset($parts->access_token)) {echo $error_msg . " - #1"; exit; }
2072
+        else {
2073 2073
 
2074 2074
             update_option('gd_ga_access_token', $parts->access_token);
2075 2075
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2078,25 +2078,25 @@  discard block
 block discarded – undo
2078 2078
 
2079 2079
 
2080 2080
     }
2081
-    elseif(!empty($response['response']['code'])) {
2081
+    elseif (!empty($response['response']['code'])) {
2082 2082
         $parts = json_decode($response['body']);
2083 2083
 
2084
-        if(isset($parts->error)){
2085
-            echo $parts->error.": ".$parts->error_description;exit;
2086
-        }else{
2087
-            echo $error_msg." - #2";exit;
2084
+        if (isset($parts->error)) {
2085
+            echo $parts->error . ": " . $parts->error_description; exit;
2086
+        } else {
2087
+            echo $error_msg . " - #2"; exit;
2088 2088
         }
2089 2089
 
2090
-    }else{
2090
+    } else {
2091 2091
 
2092
-        echo $error_msg." - #3";exit;
2092
+        echo $error_msg . " - #3"; exit;
2093 2093
 
2094 2094
     }
2095 2095
 }
2096 2096
     exit;
2097 2097
 }
2098 2098
 
2099
-add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
2099
+add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
2100 2100
 
2101 2101
 if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
2102 2102
 	add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
Please login to merge, or discard this patch.
Braces   +58 added lines, -50 removed lines patch added patch discarded remove patch
@@ -24,8 +24,11 @@  discard block
 block discarded – undo
24 24
             global $current_tab;
25 25
             geodir_redirect_to_admin_panel_on_installed();
26 26
             $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoide Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
27
+            if (!(isset($_REQUEST['action']))) {
28
+            	// this will avoide Ajax requests
29
+                geodir_handle_option_form_submit($current_tab);
30
+            }
31
+            // located in admin function.php
29 32
             /**
30 33
              * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31 34
              *
@@ -313,8 +316,9 @@  discard block
 block discarded – undo
313 316
     if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
314 317
 
315 318
         foreach ($notification as $key => $value) {
316
-            if ($value['type'] == 'textarea')
317
-                $notification[$key]['type'] = 'editor';
319
+            if ($value['type'] == 'textarea') {
320
+                            $notification[$key]['type'] = 'editor';
321
+            }
318 322
         }
319 323
 
320 324
     }
@@ -339,8 +343,9 @@  discard block
 block discarded – undo
339 343
     if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
340 344
 
341 345
         foreach ($design_setting as $key => $value) {
342
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
343
-                $design_setting[$key]['type'] = 'editor';
346
+            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') {
347
+                            $design_setting[$key]['type'] = 'editor';
348
+            }
344 349
         }
345 350
 
346 351
     }
@@ -715,8 +720,9 @@  discard block
 block discarded – undo
715 720
 
716 721
     if (!get_option('geodir_remove_unnecessary_fields')) {
717 722
 
718
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
719
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
723
+        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) {
724
+                    $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
725
+        }
720 726
 
721 727
         update_option('geodir_remove_unnecessary_fields', '1');
722 728
 
@@ -742,15 +748,17 @@  discard block
 block discarded – undo
742 748
         $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
743 749
         switch ($geodir_admin_ajax_action) {
744 750
             case 'diagnosis' :
745
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
746
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
751
+                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
752
+                                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
753
+                }
747 754
                 call_user_func('geodir_diagnose_' . $diagnose_this);
748 755
                 exit();
749 756
                 break;
750 757
 
751 758
             case 'diagnosis-fix' :
752
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
753
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
759
+                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
760
+                                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
761
+                }
754 762
                 call_user_func('geodir_diagnose_' . $diagnose_this);
755 763
                 exit();
756 764
                 break;
@@ -1308,11 +1316,11 @@  discard block
 block discarded – undo
1308 1316
     //////////////////////////////////
1309 1317
     $option_value = get_option('geodir_home_page');
1310 1318
     $page = get_post($option_value);
1311
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1319
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1312 1320
 
1313
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1314
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1315
-    else {
1321
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1322
+            $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1323
+    } else {
1316 1324
         $is_error_during_diagnose = true;
1317 1325
         $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1318 1326
         if ($fix) {
@@ -1333,11 +1341,11 @@  discard block
 block discarded – undo
1333 1341
     //////////////////////////////////
1334 1342
     $option_value = get_option('geodir_add_listing_page');
1335 1343
     $page = get_post($option_value);
1336
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1344
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1337 1345
 
1338
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1339
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1340
-    else {
1346
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1347
+            $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1348
+    } else {
1341 1349
         $is_error_during_diagnose = true;
1342 1350
         $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1343 1351
         if ($fix) {
@@ -1359,11 +1367,11 @@  discard block
 block discarded – undo
1359 1367
     //////////////////////////////////
1360 1368
     $option_value = get_option('geodir_preview_page');
1361 1369
     $page = get_post($option_value);
1362
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1370
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1363 1371
 
1364
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1365
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1366
-    else {
1372
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1373
+            $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1374
+    } else {
1367 1375
         $is_error_during_diagnose = true;
1368 1376
         $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1369 1377
         if ($fix) {
@@ -1384,11 +1392,11 @@  discard block
 block discarded – undo
1384 1392
     //////////////////////////////////
1385 1393
     $option_value = get_option('geodir_success_page');
1386 1394
     $page = get_post($option_value);
1387
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1395
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1388 1396
 
1389
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1390
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1391
-    else {
1397
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1398
+            $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1399
+    } else {
1392 1400
         $is_error_during_diagnose = true;
1393 1401
         $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1394 1402
         if ($fix) {
@@ -1409,11 +1417,11 @@  discard block
 block discarded – undo
1409 1417
     //////////////////////////////////
1410 1418
     $option_value = get_option('geodir_info_page');
1411 1419
     $page = get_post($option_value);
1412
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1420
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1413 1421
 
1414
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1415
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1416
-    else {
1422
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1423
+            $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1424
+    } else {
1417 1425
         $is_error_during_diagnose = true;
1418 1426
         $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1419 1427
         if ($fix) {
@@ -1434,11 +1442,11 @@  discard block
 block discarded – undo
1434 1442
     //////////////////////////////////
1435 1443
     $option_value = get_option('geodir_login_page');
1436 1444
     $page = get_post($option_value);
1437
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1445
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1438 1446
 
1439
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1440
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1441
-    else {
1447
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1448
+            $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1449
+    } else {
1442 1450
         $is_error_during_diagnose = true;
1443 1451
         $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1444 1452
         if ($fix) {
@@ -1459,11 +1467,11 @@  discard block
 block discarded – undo
1459 1467
     //////////////////////////////////
1460 1468
     $option_value = get_option('geodir_location_page');
1461 1469
     $page = get_post($option_value);
1462
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1470
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1463 1471
 
1464
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1465
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1466
-    else {
1472
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1473
+            $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1474
+    } else {
1467 1475
         $is_error_during_diagnose = true;
1468 1476
         $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1469 1477
         if ($fix) {
@@ -1907,8 +1915,9 @@  discard block
 block discarded – undo
1907 1915
                             );
1908 1916
 
1909 1917
                             $post_location_info = $request_info['post_location'];
1910
-                            if ($location_id = geodir_add_new_location($post_location_info))
1911
-                                $post_location_id = $location_id;
1918
+                            if ($location_id = geodir_add_new_location($post_location_info)) {
1919
+                                                            $post_location_id = $location_id;
1920
+                            }
1912 1921
                         } else {
1913 1922
                             $post_location_id = 0;
1914 1923
                         }
@@ -1971,8 +1980,9 @@  discard block
 block discarded – undo
1971 1980
                             $attachment_set = '';
1972 1981
 
1973 1982
                             foreach ($attachment as $key => $val) {
1974
-                                if ($val != '')
1975
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1983
+                                if ($val != '') {
1984
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
1985
+                                }
1976 1986
                             }
1977 1987
                             $attachment_set = trim($attachment_set, ", ");
1978 1988
 
@@ -2068,8 +2078,7 @@  discard block
 block discarded – undo
2068 2078
 
2069 2079
         $parts = json_decode($response['body']);
2070 2080
         //print_r($parts);
2071
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2072
-        else{
2081
+        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{
2073 2082
 
2074 2083
             update_option('gd_ga_access_token', $parts->access_token);
2075 2084
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2077,17 +2086,16 @@  discard block
 block discarded – undo
2077 2086
         }
2078 2087
 
2079 2088
 
2080
-    }
2081
-    elseif(!empty($response['response']['code'])) {
2089
+    } elseif(!empty($response['response']['code'])) {
2082 2090
         $parts = json_decode($response['body']);
2083 2091
 
2084 2092
         if(isset($parts->error)){
2085 2093
             echo $parts->error.": ".$parts->error_description;exit;
2086
-        }else{
2094
+        } else{
2087 2095
             echo $error_msg." - #2";exit;
2088 2096
         }
2089 2097
 
2090
-    }else{
2098
+    } else{
2091 2099
 
2092 2100
         echo $error_msg." - #3";exit;
2093 2101
 
Please login to merge, or discard this patch.
Indentation   +1298 added lines, -1298 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 avoide 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 avoide 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
 
@@ -83,18 +83,18 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function geodir_conditional_admin_script_load()
85 85
 {
86
-    global $pagenow;
86
+	global $pagenow;
87 87
 	
88 88
 	// Get the current post type
89 89
 	$post_type = geodir_admin_current_post_type();
90 90
 	$geodir_post_types = geodir_get_posttypes();
91 91
     
92 92
 	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 == 'edit-comments.php' || $pagenow == 'comment.php')) {
93
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
94
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
95
-    }
93
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
94
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
95
+	}
96 96
 
97
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
97
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
98 98
 
99 99
 }
100 100
 
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
  */
129 129
 function create_default_admin_main_nav()
130 130
 {
131
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
132
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
133
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
134
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
135
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
136
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
131
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
132
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
133
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
134
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
135
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
136
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
137 137
 
138 138
 }
139 139
 
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
  */
147 147
 function geodir_admin_list_columns()
148 148
 {
149
-    if ($post_types = geodir_get_posttypes()) {
149
+	if ($post_types = geodir_get_posttypes()) {
150 150
 
151
-        foreach ($post_types as $post_type):
152
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
153
-            //Filter-Payment-Manager to show Package
154
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
151
+		foreach ($post_types as $post_type):
152
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
153
+			//Filter-Payment-Manager to show Package
154
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
155 155
 
156
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
157
-        endforeach;
158
-    }
156
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
157
+		endforeach;
158
+	}
159 159
 }
160 160
 
161 161
 /**
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
  */
169 169
 function geodir_default_admin_main_tabs($tabs)
170 170
 {
171
-    return $tabs = array(
172
-        'general_settings' => array('label' => __('General', 'geodirectory')),
173
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
174
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
175
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
176
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
177
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
178
-
179
-    );
171
+	return $tabs = array(
172
+		'general_settings' => array('label' => __('General', 'geodirectory')),
173
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
174
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
175
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
176
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
177
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
178
+
179
+	);
180 180
 }
181 181
 
182 182
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
  */
190 190
 function geodir_remove_image_box()
191 191
 {
192
-    global $post;
192
+	global $post;
193 193
 
194
-    $geodir_posttypes = geodir_get_posttypes();
194
+	$geodir_posttypes = geodir_get_posttypes();
195 195
 
196
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
196
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
197 197
 
198
-        remove_meta_box('postimagediv', $post->post_type, 'side');
199
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
198
+		remove_meta_box('postimagediv', $post->post_type, 'side');
199
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
200 200
 
201
-    endif;
201
+	endif;
202 202
 
203 203
 }
204 204
 
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
  */
214 214
 function geodir_meta_box_add()
215 215
 {
216
-    global $post;
216
+	global $post;
217 217
 
218
-    $geodir_post_types = geodir_get_posttypes('array');
219
-    $geodir_posttypes = array_keys($geodir_post_types);
218
+	$geodir_post_types = geodir_get_posttypes('array');
219
+	$geodir_posttypes = array_keys($geodir_post_types);
220 220
 
221
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
221
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
222 222
 
223
-        $geodir_posttype = $post->post_type;
224
-        $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
223
+		$geodir_posttype = $post->post_type;
224
+		$post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
225 225
 
226
-        // Filter-Payment-Manager
226
+		// Filter-Payment-Manager
227 227
 
228
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
228
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
229 229
 
230
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
230
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
231 231
 
232
-        // no need of this box as all fields moved to main informain box
233
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
232
+		// no need of this box as all fields moved to main informain box
233
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
234 234
 
235
-    endif;
235
+	endif;
236 236
 
237 237
 }
238 238
 
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 function geodir_hide_post_taxonomy_meta_boxes()
257 257
 {
258 258
 
259
-    $geodir_post_types = get_option('geodir_post_types');
259
+	$geodir_post_types = get_option('geodir_post_types');
260 260
 
261
-    if (!empty($geodir_post_types)) {
262
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
261
+	if (!empty($geodir_post_types)) {
262
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
263 263
 
264
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
264
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
265 265
 
266
-            if(!empty($gd_taxonomy)) {
267
-                foreach ($gd_taxonomy as $tax) {
266
+			if(!empty($gd_taxonomy)) {
267
+				foreach ($gd_taxonomy as $tax) {
268 268
 
269
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
269
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
270 270
 
271
-                }
272
-            }
271
+				}
272
+			}
273 273
 
274
-        }
275
-    }
274
+		}
275
+	}
276 276
 }
277 277
 
278 278
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
  */
287 287
 function geodir_add_listing_map_restrict($map_restirct)
288 288
 {
289
-    if (is_admin()) {
290
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
291
-            $map_restirct = false;
292
-        }
293
-    }
294
-    return $map_restirct;
289
+	if (is_admin()) {
290
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
291
+			$map_restirct = false;
292
+		}
293
+	}
294
+	return $map_restirct;
295 295
 }
296 296
 
297 297
 
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 function geodir_enable_editor_on_notifications($notification)
311 311
 {
312 312
 
313
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
313
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
314 314
 
315
-        foreach ($notification as $key => $value) {
316
-            if ($value['type'] == 'textarea')
317
-                $notification[$key]['type'] = 'editor';
318
-        }
315
+		foreach ($notification as $key => $value) {
316
+			if ($value['type'] == 'textarea')
317
+				$notification[$key]['type'] = 'editor';
318
+		}
319 319
 
320
-    }
320
+	}
321 321
 
322
-    return $notification;
322
+	return $notification;
323 323
 }
324 324
 
325 325
 
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 function geodir_enable_editor_on_design_settings($design_setting)
337 337
 {
338 338
 
339
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
339
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
340 340
 
341
-        foreach ($design_setting as $key => $value) {
342
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
343
-                $design_setting[$key]['type'] = 'editor';
344
-        }
341
+		foreach ($design_setting as $key => $value) {
342
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
343
+				$design_setting[$key]['type'] = 'editor';
344
+		}
345 345
 
346
-    }
346
+	}
347 347
 
348
-    return $design_setting;
348
+	return $design_setting;
349 349
 }
350 350
 
351 351
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -366,16 +366,16 @@  discard block
 block discarded – undo
366 366
 function geodir_manage_available_fields($sub_tab)
367 367
 {
368 368
 
369
-    switch ($sub_tab) {
370
-        case 'custom_fields':
371
-            geodir_custom_available_fields();
372
-            break;
369
+	switch ($sub_tab) {
370
+		case 'custom_fields':
371
+			geodir_custom_available_fields();
372
+			break;
373 373
 
374
-        case 'sorting_options':
375
-            geodir_sorting_options_available_fields();
376
-            break;
374
+		case 'sorting_options':
375
+			geodir_sorting_options_available_fields();
376
+			break;
377 377
 
378
-    }
378
+	}
379 379
 }
380 380
 
381 381
 
@@ -391,16 +391,16 @@  discard block
 block discarded – undo
391 391
 function geodir_manage_selected_fields($sub_tab)
392 392
 {
393 393
 
394
-    switch ($sub_tab) {
395
-        case 'custom_fields':
396
-            geodir_custom_selected_fields();
397
-            break;
394
+	switch ($sub_tab) {
395
+		case 'custom_fields':
396
+			geodir_custom_selected_fields();
397
+			break;
398 398
 
399
-        case 'sorting_options':
400
-            geodir_sorting_options_selected_fields();
401
-            break;
399
+		case 'sorting_options':
400
+			geodir_sorting_options_selected_fields();
401
+			break;
402 402
 
403
-    }
403
+	}
404 404
 }
405 405
 
406 406
 /**
@@ -412,27 +412,27 @@  discard block
 block discarded – undo
412 412
  */
413 413
 function geodir_sorting_options_available_fields()
414 414
 {
415
-    global $wpdb;
416
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
417
-    ?>
415
+	global $wpdb;
416
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
417
+	?>
418 418
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
419 419
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
420 420
     <ul>
421 421
     <?php
422
-        $sort_options = geodir_get_custom_sort_options($listing_type);
422
+		$sort_options = geodir_get_custom_sort_options($listing_type);
423 423
         
424
-        foreach ($sort_options as $key => $val) {
425
-            $val = stripslashes_deep($val); // strip slashes
426
-
427
-            $check_html_variable = $wpdb->get_var(
428
-                $wpdb->prepare(
429
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
430
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
431
-                )
432
-            );
424
+		foreach ($sort_options as $key => $val) {
425
+			$val = stripslashes_deep($val); // strip slashes
426
+
427
+			$check_html_variable = $wpdb->get_var(
428
+				$wpdb->prepare(
429
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
430
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
431
+				)
432
+			);
433 433
             
434
-            $display = $check_html_variable ? ' style="display:none;"' : '';
435
-            ?>
434
+			$display = $check_html_variable ? ' style="display:none;"' : '';
435
+			?>
436 436
             <li <?php echo $display;?>>
437 437
             <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>"
438 438
                title="<?php echo $val['site_title'];?>"
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
                href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a>
441 441
             </li>
442 442
             <?php
443
-        }
444
-    ?>
443
+		}
444
+	?>
445 445
     </ul>
446 446
     <?php
447 447
 }
@@ -455,28 +455,28 @@  discard block
 block discarded – undo
455 455
  */
456 456
 function geodir_sorting_options_selected_fields()
457 457
 {
458
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
459
-    ?>
458
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
459
+	?>
460 460
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
461 461
     <ul class="core">
462 462
     <?php 
463
-        global $wpdb;
463
+		global $wpdb;
464 464
         
465
-        $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)));
465
+		$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)));
466 466
 
467
-        if (!empty($fields)) {
468
-            foreach ($fields as $field) {
469
-                //$result_str = $field->id;
470
-                $result_str = $field;
471
-                $field_type = $field->field_type;
472
-                $field_ins_upd = 'display';
467
+		if (!empty($fields)) {
468
+			foreach ($fields as $field) {
469
+				//$result_str = $field->id;
470
+				$result_str = $field;
471
+				$field_type = $field->field_type;
472
+				$field_ins_upd = 'display';
473 473
 
474
-                $default = false;
474
+				$default = false;
475 475
 
476
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
477
-            }
478
-        }
479
-    ?>
476
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
477
+			}
478
+		}
479
+	?>
480 480
     </ul>
481 481
     <?php
482 482
 }
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
  */
490 490
 function geodir_custom_available_fields()
491 491
 {
492
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
493
-    ?>
492
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
493
+	?>
494 494
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
495 495
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
496 496
     <ul class="full">
@@ -541,25 +541,25 @@  discard block
 block discarded – undo
541 541
  */
542 542
 function geodir_custom_selected_fields()
543 543
 {
544
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
545
-    ?>
544
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
545
+	?>
546 546
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
547 547
     <ul class="core">
548 548
     <?php 
549
-        global $wpdb;
550
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
551
-
552
-        if (!empty($fields)) {
553
-            foreach ($fields as $field) {
554
-                //$result_str = $field->id;
555
-                $result_str = $field;
556
-                $field_type = $field->field_type;
557
-                $field_ins_upd = 'display';
558
-
559
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
560
-            }
561
-        }
562
-        ?></ul>
549
+		global $wpdb;
550
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
551
+
552
+		if (!empty($fields)) {
553
+			foreach ($fields as $field) {
554
+				//$result_str = $field->id;
555
+				$result_str = $field;
556
+				$field_type = $field->field_type;
557
+				$field_ins_upd = 'display';
558
+
559
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
560
+			}
561
+		}
562
+		?></ul>
563 563
 <?php
564 564
 
565 565
 }
@@ -578,16 +578,16 @@  discard block
 block discarded – undo
578 578
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
579 579
 {
580 580
 
581
-    switch ($sub_tab) {
582
-        case 'custom_fields':
583
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
584
-            break;
581
+	switch ($sub_tab) {
582
+		case 'custom_fields':
583
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
584
+			break;
585 585
 
586
-        case 'sorting_options':
587
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
588
-            break;
589
-    }
590
-    return $heading;
586
+		case 'sorting_options':
587
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
588
+			break;
589
+	}
590
+	return $heading;
591 591
 }
592 592
 
593 593
 
@@ -605,16 +605,16 @@  discard block
 block discarded – undo
605 605
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
606 606
 {
607 607
 
608
-    switch ($sub_tab) {
609
-        case 'custom_fields':
610
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
611
-            break;
608
+	switch ($sub_tab) {
609
+		case 'custom_fields':
610
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
611
+			break;
612 612
 
613
-        case 'sorting_options':
614
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
615
-            break;
616
-    }
617
-    return $heading;
613
+		case 'sorting_options':
614
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
615
+			break;
616
+	}
617
+	return $heading;
618 618
 }
619 619
 
620 620
 
@@ -632,16 +632,16 @@  discard block
 block discarded – undo
632 632
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
633 633
 {
634 634
 
635
-    switch ($sub_tab) {
636
-        case 'custom_fields':
637
-            $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));;
638
-            break;
635
+	switch ($sub_tab) {
636
+		case 'custom_fields':
637
+			$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));;
638
+			break;
639 639
 
640
-        case 'sorting_options':
641
-            $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));
642
-            break;
643
-    }
644
-    return $note;
640
+		case 'sorting_options':
641
+			$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));
642
+			break;
643
+	}
644
+	return $note;
645 645
 }
646 646
 
647 647
 
@@ -659,16 +659,16 @@  discard block
 block discarded – undo
659 659
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
660 660
 {
661 661
 
662
-    switch ($sub_tab) {
663
-        case 'custom_fields':
664
-            $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
665
-            break;
662
+	switch ($sub_tab) {
663
+		case 'custom_fields':
664
+			$heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
665
+			break;
666 666
 
667
-        case 'sorting_options':
668
-            $heading = sprintf(__('List of fields those will appear in %s listing and search resutls sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
669
-            break;
670
-    }
671
-    return $heading;
667
+		case 'sorting_options':
668
+			$heading = sprintf(__('List of fields those will appear in %s listing and search resutls sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
669
+			break;
670
+	}
671
+	return $heading;
672 672
 }
673 673
 
674 674
 
@@ -686,16 +686,16 @@  discard block
 block discarded – undo
686 686
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
687 687
 {
688 688
 
689
-    switch ($sub_tab) {
690
-        case 'custom_fields':
691
-            $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));;
692
-            break;
689
+	switch ($sub_tab) {
690
+		case 'custom_fields':
691
+			$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));;
692
+			break;
693 693
 
694
-        case 'sorting_options':
695
-            $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));
696
-            break;
697
-    }
698
-    return $note;
694
+		case 'sorting_options':
695
+			$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));
696
+			break;
697
+	}
698
+	return $note;
699 699
 }
700 700
 
701 701
 
@@ -711,16 +711,16 @@  discard block
 block discarded – undo
711 711
  */
712 712
 function geodir_remove_unnecessary_fields()
713 713
 {
714
-    global $wpdb, $plugin_prefix;
714
+	global $wpdb, $plugin_prefix;
715 715
 
716
-    if (!get_option('geodir_remove_unnecessary_fields')) {
716
+	if (!get_option('geodir_remove_unnecessary_fields')) {
717 717
 
718
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
719
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
718
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
719
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
720 720
 
721
-        update_option('geodir_remove_unnecessary_fields', '1');
721
+		update_option('geodir_remove_unnecessary_fields', '1');
722 722
 
723
-    }
723
+	}
724 724
 
725 725
 }
726 726
 
@@ -738,25 +738,25 @@  discard block
 block discarded – undo
738 738
  */
739 739
 function geodir_admin_ajax_handler()
740 740
 {
741
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
742
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
743
-        switch ($geodir_admin_ajax_action) {
744
-            case 'diagnosis' :
745
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
746
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
747
-                call_user_func('geodir_diagnose_' . $diagnose_this);
748
-                exit();
749
-                break;
750
-
751
-            case 'diagnosis-fix' :
752
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
753
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
754
-                call_user_func('geodir_diagnose_' . $diagnose_this);
755
-                exit();
756
-                break;
757
-        }
758
-    }
759
-    exit();
741
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
742
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
743
+		switch ($geodir_admin_ajax_action) {
744
+			case 'diagnosis' :
745
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
746
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
747
+				call_user_func('geodir_diagnose_' . $diagnose_this);
748
+				exit();
749
+				break;
750
+
751
+			case 'diagnosis-fix' :
752
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
753
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
754
+				call_user_func('geodir_diagnose_' . $diagnose_this);
755
+				exit();
756
+				break;
757
+		}
758
+	}
759
+	exit();
760 760
 }
761 761
 
762 762
 
@@ -774,127 +774,127 @@  discard block
 block discarded – undo
774 774
  */
775 775
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
776 776
 {
777
-    global $wpdb;
778
-    //$filter_arr['output_str'] .='###'.$table.'###';
779
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
780
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You didnt follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
781
-        $filter_arr['is_error_during_diagnose'] = true;
782
-
783
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
784
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
785
-        $filter_arr['is_error_during_diagnose'] = true;
786
-        $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>";
787
-        $filter_arr['is_error_during_diagnose'] = true;
788
-
789
-        if ($fix) {
790
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
791
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
792
-
793
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
794
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
795
-
796
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
797
-
798
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
799
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
800
-                } else {
801
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
802
-                }
803
-
804
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
805
-
806
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
807
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
808
-
809
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
810
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
811
-                } else {
812
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
813
-                }
814
-
815
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
816
-
817
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
818
-
819
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
820
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
821
-                } else {
822
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
823
-                }
824
-
825
-            }
826
-
827
-        }
828
-
829
-
830
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
831
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
832
-        $filter_arr['is_error_during_diagnose'] = true;
833
-
834
-        if ($fix) {
835
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
836
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
837
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
838
-                } else {
839
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
840
-                }
841
-
842
-            } 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
843
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
844
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
845
-                } else {
846
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
847
-                }
848
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
849
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
850
-                } else {
851
-                    $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>";
852
-                }
853
-            } else {// else rename the original table to _ms_bak
854
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
855
-                    $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>";
856
-                } else {
857
-                    $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>";
858
-                }
859
-            }
860
-        }
861
-
862
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
863
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
864
-        $filter_arr['is_error_during_diagnose'] = true;
865
-
866
-        if ($fix) {
867
-            // if orignal table exists but new does not, rename
868
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
869
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
870
-            } else {
871
-                $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>";
872
-            }
873
-
874
-        }
875
-
876
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
877
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
878
-        $filter_arr['is_error_during_diagnose'] = true;
879
-
880
-        if ($fix) {
881
-            // if orignal table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
882
-            delete_option('geodirlocation_db_version');
883
-            delete_option('geodirevents_db_version');
884
-            delete_option('geodir_reviewrating_db_version');
885
-            delete_option('gdevents_db_version');
886
-            delete_option('geodirectory_db_version');
887
-            delete_option('geodirclaim_db_version');
888
-            delete_option('geodir_custom_posts_db_version');
889
-            delete_option('geodir_reviewratings_db_version');
890
-            delete_option('geodiradvancesearch_db_version');
891
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
892
-        }
893
-
894
-    } else {
895
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
896
-    }
897
-    return $filter_arr;
777
+	global $wpdb;
778
+	//$filter_arr['output_str'] .='###'.$table.'###';
779
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
780
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You didnt follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
781
+		$filter_arr['is_error_during_diagnose'] = true;
782
+
783
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
784
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
785
+		$filter_arr['is_error_during_diagnose'] = true;
786
+		$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>";
787
+		$filter_arr['is_error_during_diagnose'] = true;
788
+
789
+		if ($fix) {
790
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
791
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
792
+
793
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
794
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
795
+
796
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
797
+
798
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
799
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
800
+				} else {
801
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
802
+				}
803
+
804
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
805
+
806
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
807
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
808
+
809
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
810
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
811
+				} else {
812
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
813
+				}
814
+
815
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
816
+
817
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
818
+
819
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
820
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
821
+				} else {
822
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
823
+				}
824
+
825
+			}
826
+
827
+		}
828
+
829
+
830
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
831
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
832
+		$filter_arr['is_error_during_diagnose'] = true;
833
+
834
+		if ($fix) {
835
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
836
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
837
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
838
+				} else {
839
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
840
+				}
841
+
842
+			} 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
843
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
844
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
845
+				} else {
846
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
847
+				}
848
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
849
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
850
+				} else {
851
+					$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>";
852
+				}
853
+			} else {// else rename the original table to _ms_bak
854
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
855
+					$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>";
856
+				} else {
857
+					$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>";
858
+				}
859
+			}
860
+		}
861
+
862
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
863
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
864
+		$filter_arr['is_error_during_diagnose'] = true;
865
+
866
+		if ($fix) {
867
+			// if orignal table exists but new does not, rename
868
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
869
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
870
+			} else {
871
+				$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>";
872
+			}
873
+
874
+		}
875
+
876
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
877
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
878
+		$filter_arr['is_error_during_diagnose'] = true;
879
+
880
+		if ($fix) {
881
+			// if orignal table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
882
+			delete_option('geodirlocation_db_version');
883
+			delete_option('geodirevents_db_version');
884
+			delete_option('geodir_reviewrating_db_version');
885
+			delete_option('gdevents_db_version');
886
+			delete_option('geodirectory_db_version');
887
+			delete_option('geodirclaim_db_version');
888
+			delete_option('geodir_custom_posts_db_version');
889
+			delete_option('geodir_reviewratings_db_version');
890
+			delete_option('geodiradvancesearch_db_version');
891
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
892
+		}
893
+
894
+	} else {
895
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
896
+	}
897
+	return $filter_arr;
898 898
 }
899 899
 
900 900
 
@@ -908,53 +908,53 @@  discard block
 block discarded – undo
908 908
  */
909 909
 function geodir_diagnose_tags_sync()
910 910
 {
911
-    global $wpdb, $plugin_prefix;
912
-    $fix = isset($_POST['fix']) ? true : false;
913
-
914
-    //if($fix){echo 'true';}else{echo 'false';}
915
-    $is_error_during_diagnose = false;
916
-    $output_str = '';
917
-
918
-
919
-    $all_postypes = geodir_get_posttypes();
920
-
921
-    if (!empty($all_postypes)) {
922
-        foreach ($all_postypes as $key) {
923
-            // update each GD CTP
924
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
925
-
926
-            if (!empty($posts)) {
927
-
928
-                foreach ($posts as $p) {
929
-                    $p->post_type = $key;
930
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
931
-                    if (empty($raw_tags)) {
932
-                        $post_tags = '';
933
-                    } else {
934
-                        $post_tags = implode(",", $raw_tags);
935
-                    }
936
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
937
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
938
-
939
-                }
940
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
941
-            }
942
-
943
-        }
944
-
945
-    }
946
-
947
-    if ($is_error_during_diagnose) {
948
-        $info_div_class = "geodir_problem_info";
949
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
950
-    } else {
951
-        $info_div_class = "geodir_noproblem_info";
952
-        $fix_button_txt = '';
953
-    }
954
-    echo "<ul class='$info_div_class'>";
955
-    echo $output_str;
956
-    echo $fix_button_txt;
957
-    echo "</ul>";
911
+	global $wpdb, $plugin_prefix;
912
+	$fix = isset($_POST['fix']) ? true : false;
913
+
914
+	//if($fix){echo 'true';}else{echo 'false';}
915
+	$is_error_during_diagnose = false;
916
+	$output_str = '';
917
+
918
+
919
+	$all_postypes = geodir_get_posttypes();
920
+
921
+	if (!empty($all_postypes)) {
922
+		foreach ($all_postypes as $key) {
923
+			// update each GD CTP
924
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
925
+
926
+			if (!empty($posts)) {
927
+
928
+				foreach ($posts as $p) {
929
+					$p->post_type = $key;
930
+					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
931
+					if (empty($raw_tags)) {
932
+						$post_tags = '';
933
+					} else {
934
+						$post_tags = implode(",", $raw_tags);
935
+					}
936
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
937
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
938
+
939
+				}
940
+				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
941
+			}
942
+
943
+		}
944
+
945
+	}
946
+
947
+	if ($is_error_during_diagnose) {
948
+		$info_div_class = "geodir_problem_info";
949
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
950
+	} else {
951
+		$info_div_class = "geodir_noproblem_info";
952
+		$fix_button_txt = '';
953
+	}
954
+	echo "<ul class='$info_div_class'>";
955
+	echo $output_str;
956
+	echo $fix_button_txt;
957
+	echo "</ul>";
958 958
 
959 959
 }
960 960
 
@@ -970,75 +970,75 @@  discard block
 block discarded – undo
970 970
  */
971 971
 function geodir_diagnose_cats_sync()
972 972
 {
973
-    global $wpdb, $plugin_prefix;
974
-    $fix = isset($_POST['fix']) ? true : false;
973
+	global $wpdb, $plugin_prefix;
974
+	$fix = isset($_POST['fix']) ? true : false;
975 975
 
976
-    //if($fix){echo 'true';}else{echo 'false';}
977
-    $is_error_during_diagnose = false;
978
-    $output_str = '';
976
+	//if($fix){echo 'true';}else{echo 'false';}
977
+	$is_error_during_diagnose = false;
978
+	$output_str = '';
979 979
 
980 980
 
981
-    $all_postypes = geodir_get_posttypes();
981
+	$all_postypes = geodir_get_posttypes();
982 982
 
983
-    if (!empty($all_postypes)) {
984
-        foreach ($all_postypes as $key) {
985
-            // update each GD CTP
986
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
983
+	if (!empty($all_postypes)) {
984
+		foreach ($all_postypes as $key) {
985
+			// update each GD CTP
986
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
987 987
 
988
-            if (!empty($posts)) {
988
+			if (!empty($posts)) {
989 989
 
990
-                foreach ($posts as $p) {
991
-                    $p->post_type = $key;
992
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
990
+				foreach ($posts as $p) {
991
+					$p->post_type = $key;
992
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
993 993
 
994
-                    if (empty($raw_cats)) {
995
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
994
+					if (empty($raw_cats)) {
995
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
996 996
 
997
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
998
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
999
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1000
-                                if (is_numeric($cat_part)) {
1001
-                                    $raw_cats[] = (int)$cat_part;
1002
-                                }
1003
-                            }
997
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
998
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
999
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1000
+								if (is_numeric($cat_part)) {
1001
+									$raw_cats[] = (int)$cat_part;
1002
+								}
1003
+							}
1004 1004
 
1005
-                        }
1005
+						}
1006 1006
 
1007
-                        if (!empty($raw_cats)) {
1008
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1007
+						if (!empty($raw_cats)) {
1008
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1009 1009
 
1010
-                        }
1010
+						}
1011 1011
 
1012
-                    }
1012
+					}
1013 1013
 
1014 1014
 
1015
-                    if (empty($raw_cats)) {
1016
-                        $post_cats = '';
1017
-                    } else {
1018
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1019
-                    }
1020
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1021
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1022
-                }
1015
+					if (empty($raw_cats)) {
1016
+						$post_cats = '';
1017
+					} else {
1018
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1019
+					}
1020
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1021
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1022
+				}
1023 1023
 
1024
-            }
1025
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1024
+			}
1025
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1026 1026
 
1027
-        }
1027
+		}
1028 1028
 
1029
-    }
1029
+	}
1030 1030
 
1031
-    if ($is_error_during_diagnose) {
1032
-        $info_div_class = "geodir_problem_info";
1033
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1034
-    } else {
1035
-        $info_div_class = "geodir_noproblem_info";
1036
-        $fix_button_txt = '';
1037
-    }
1038
-    echo "<ul class='$info_div_class'>";
1039
-    echo $output_str;
1040
-    echo $fix_button_txt;
1041
-    echo "</ul>";
1031
+	if ($is_error_during_diagnose) {
1032
+		$info_div_class = "geodir_problem_info";
1033
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1034
+	} else {
1035
+		$info_div_class = "geodir_noproblem_info";
1036
+		$fix_button_txt = '';
1037
+	}
1038
+	echo "<ul class='$info_div_class'>";
1039
+	echo $output_str;
1040
+	echo $fix_button_txt;
1041
+	echo "</ul>";
1042 1042
 
1043 1043
 }
1044 1044
 
@@ -1052,61 +1052,61 @@  discard block
 block discarded – undo
1052 1052
  */
1053 1053
 function geodir_diagnose_version_clear()
1054 1054
 {
1055
-    global $wpdb, $plugin_prefix;
1056
-    $fix = isset($_POST['fix']) ? true : false;
1057
-
1058
-    //if($fix){echo 'true';}else{echo 'false';}
1059
-    $is_error_during_diagnose = false;
1060
-    $output_str = '';
1061
-
1062
-
1063
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1064
-        'Payment Manager' => 'geodir_payments_db_version',
1065
-        'GeoDirectory Framework' => 'gdf_db_version',
1066
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1067
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1068
-        'Claim Manager' => 'geodirclaim_db_version',
1069
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1070
-        'Location Manager' => 'geodirlocation_db_version',
1071
-        'Payment Manager' => 'geodir_payments_db_version',
1072
-        'Events Manager' => 'geodirevents_db_version',
1073
-    );
1074
-
1075
-    /**
1076
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1077
-     *
1078
-     * @since 1.0.0
1079
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1080
-     */
1081
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1082
-
1083
-    if (!empty($ver_arr)) {
1084
-        foreach ($ver_arr as $key => $val) {
1085
-            if (delete_option($val)) {
1086
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1087
-            } else {
1088
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1089
-            }
1090
-
1091
-        }
1092
-
1093
-        if ($output_str) {
1094
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1095
-        }
1096
-
1097
-    }
1098
-
1099
-    if ($is_error_during_diagnose) {
1100
-        $info_div_class = "geodir_problem_info";
1101
-        $fix_button_txt = "";
1102
-    } else {
1103
-        $info_div_class = "geodir_noproblem_info";
1104
-        $fix_button_txt = '';
1105
-    }
1106
-    echo "<ul class='$info_div_class'>";
1107
-    echo $output_str;
1108
-    echo $fix_button_txt;
1109
-    echo "</ul>";
1055
+	global $wpdb, $plugin_prefix;
1056
+	$fix = isset($_POST['fix']) ? true : false;
1057
+
1058
+	//if($fix){echo 'true';}else{echo 'false';}
1059
+	$is_error_during_diagnose = false;
1060
+	$output_str = '';
1061
+
1062
+
1063
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1064
+		'Payment Manager' => 'geodir_payments_db_version',
1065
+		'GeoDirectory Framework' => 'gdf_db_version',
1066
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1067
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1068
+		'Claim Manager' => 'geodirclaim_db_version',
1069
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1070
+		'Location Manager' => 'geodirlocation_db_version',
1071
+		'Payment Manager' => 'geodir_payments_db_version',
1072
+		'Events Manager' => 'geodirevents_db_version',
1073
+	);
1074
+
1075
+	/**
1076
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1077
+	 *
1078
+	 * @since 1.0.0
1079
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1080
+	 */
1081
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1082
+
1083
+	if (!empty($ver_arr)) {
1084
+		foreach ($ver_arr as $key => $val) {
1085
+			if (delete_option($val)) {
1086
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1087
+			} else {
1088
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1089
+			}
1090
+
1091
+		}
1092
+
1093
+		if ($output_str) {
1094
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1095
+		}
1096
+
1097
+	}
1098
+
1099
+	if ($is_error_during_diagnose) {
1100
+		$info_div_class = "geodir_problem_info";
1101
+		$fix_button_txt = "";
1102
+	} else {
1103
+		$info_div_class = "geodir_noproblem_info";
1104
+		$fix_button_txt = '';
1105
+	}
1106
+	echo "<ul class='$info_div_class'>";
1107
+	echo $output_str;
1108
+	echo $fix_button_txt;
1109
+	echo "</ul>";
1110 1110
 
1111 1111
 }
1112 1112
 
@@ -1120,59 +1120,59 @@  discard block
 block discarded – undo
1120 1120
  */
1121 1121
 function geodir_diagnose_ratings()
1122 1122
 {
1123
-    global $wpdb;
1124
-    $fix = isset($_POST['fix']) ? true : false;
1125
-
1126
-    //if($fix){echo 'true';}else{echo 'false';}
1127
-    $is_error_during_diagnose = false;
1128
-    $output_str = '';
1129
-
1130
-    // check review locations
1131
-    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")) {
1132
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1133
-        $is_error_during_diagnose = true;
1134
-
1135
-        if ($fix) {
1136
-            if (geodir_fix_review_location()) {
1137
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1138
-            } else {
1139
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1140
-            }
1141
-        }
1142
-
1143
-    } else {
1144
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1145
-    }
1146
-
1147
-    // check review content
1148
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1149
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1150
-        $is_error_during_diagnose = true;
1151
-
1152
-        if ($fix) {
1153
-            if (geodir_fix_review_content()) {
1154
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1155
-            } else {
1156
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1157
-            }
1158
-        }
1159
-
1160
-    } else {
1161
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1162
-    }
1163
-
1164
-
1165
-    if ($is_error_during_diagnose) {
1166
-        $info_div_class = "geodir_problem_info";
1167
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1168
-    } else {
1169
-        $info_div_class = "geodir_noproblem_info";
1170
-        $fix_button_txt = '';
1171
-    }
1172
-    echo "<ul class='$info_div_class'>";
1173
-    echo $output_str;
1174
-    echo $fix_button_txt;
1175
-    echo "</ul>";
1123
+	global $wpdb;
1124
+	$fix = isset($_POST['fix']) ? true : false;
1125
+
1126
+	//if($fix){echo 'true';}else{echo 'false';}
1127
+	$is_error_during_diagnose = false;
1128
+	$output_str = '';
1129
+
1130
+	// check review locations
1131
+	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")) {
1132
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1133
+		$is_error_during_diagnose = true;
1134
+
1135
+		if ($fix) {
1136
+			if (geodir_fix_review_location()) {
1137
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1138
+			} else {
1139
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1140
+			}
1141
+		}
1142
+
1143
+	} else {
1144
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1145
+	}
1146
+
1147
+	// check review content
1148
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1149
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1150
+		$is_error_during_diagnose = true;
1151
+
1152
+		if ($fix) {
1153
+			if (geodir_fix_review_content()) {
1154
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1155
+			} else {
1156
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1157
+			}
1158
+		}
1159
+
1160
+	} else {
1161
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1162
+	}
1163
+
1164
+
1165
+	if ($is_error_during_diagnose) {
1166
+		$info_div_class = "geodir_problem_info";
1167
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1168
+	} else {
1169
+		$info_div_class = "geodir_noproblem_info";
1170
+		$fix_button_txt = '';
1171
+	}
1172
+	echo "<ul class='$info_div_class'>";
1173
+	echo $output_str;
1174
+	echo $fix_button_txt;
1175
+	echo "</ul>";
1176 1176
 
1177 1177
 }
1178 1178
 
@@ -1186,57 +1186,57 @@  discard block
 block discarded – undo
1186 1186
  */
1187 1187
 function geodir_diagnose_multisite_conversion()
1188 1188
 {
1189
-    global $wpdb;
1190
-    $fix = isset($_POST['fix']) ? true : false;
1191
-    //if($fix){echo 'true';}else{echo 'false';}
1192
-    $is_error_during_diagnose = false;
1193
-    $output_str = '';
1194
-
1195
-    $filter_arr = array();
1196
-    $filter_arr['output_str'] = $output_str;
1197
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1198
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1199
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1200
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1201
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1202
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1203
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1204
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1205
-    );
1206
-
1207
-    // allow other addons to hook in and add their checks
1208
-
1209
-    /**
1210
-     * Filter the array of tables.
1211
-     *
1212
-     * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows adons to add their DB tables to the checks.
1213
-     *
1214
-     * @since 1.0.0
1215
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1216
-     */
1217
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1218
-
1219
-    foreach ($table_arr as $table => $table_name) {
1220
-        // Diagnose table
1221
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1222
-    }
1223
-
1224
-
1225
-    $output_str = $filter_arr['output_str'];
1226
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1227
-
1228
-
1229
-    if ($is_error_during_diagnose) {
1230
-        $info_div_class = "geodir_problem_info";
1231
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1232
-    } else {
1233
-        $info_div_class = "geodir_noproblem_info";
1234
-        $fix_button_txt = '';
1235
-    }
1236
-    echo "<ul class='$info_div_class'>";
1237
-    echo $output_str;
1238
-    echo $fix_button_txt;
1239
-    echo "</ul>";
1189
+	global $wpdb;
1190
+	$fix = isset($_POST['fix']) ? true : false;
1191
+	//if($fix){echo 'true';}else{echo 'false';}
1192
+	$is_error_during_diagnose = false;
1193
+	$output_str = '';
1194
+
1195
+	$filter_arr = array();
1196
+	$filter_arr['output_str'] = $output_str;
1197
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1198
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1199
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1200
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1201
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1202
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1203
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1204
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1205
+	);
1206
+
1207
+	// allow other addons to hook in and add their checks
1208
+
1209
+	/**
1210
+	 * Filter the array of tables.
1211
+	 *
1212
+	 * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows adons to add their DB tables to the checks.
1213
+	 *
1214
+	 * @since 1.0.0
1215
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1216
+	 */
1217
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1218
+
1219
+	foreach ($table_arr as $table => $table_name) {
1220
+		// Diagnose table
1221
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1222
+	}
1223
+
1224
+
1225
+	$output_str = $filter_arr['output_str'];
1226
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1227
+
1228
+
1229
+	if ($is_error_during_diagnose) {
1230
+		$info_div_class = "geodir_problem_info";
1231
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1232
+	} else {
1233
+		$info_div_class = "geodir_noproblem_info";
1234
+		$fix_button_txt = '';
1235
+	}
1236
+	echo "<ul class='$info_div_class'>";
1237
+	echo $output_str;
1238
+	echo $fix_button_txt;
1239
+	echo "</ul>";
1240 1240
 }
1241 1241
 
1242 1242
 /**
@@ -1254,39 +1254,39 @@  discard block
 block discarded – undo
1254 1254
  */
1255 1255
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1256 1256
 {
1257
-    global $wpdb, $current_user;
1258
-
1259
-    if (!empty($old_id)) {
1260
-        wp_delete_post($old_id, true);
1261
-    }//delete post if already there
1262
-    else {
1263
-        $page_found = $wpdb->get_var(
1264
-            $wpdb->prepare(
1265
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1266
-                array($slug)
1267
-            )
1268
-        );
1269
-        wp_delete_post($page_found, true);
1270
-
1271
-    }
1272
-
1273
-    $page_data = array(
1274
-        'post_status' => 'publish',
1275
-        'post_type' => 'page',
1276
-        'post_author' => $current_user->ID,
1277
-        'post_name' => $slug,
1278
-        'post_title' => $page_title,
1279
-        'post_content' => '',
1280
-        'post_parent' => 0,
1281
-        'comment_status' => 'closed'
1282
-    );
1283
-    $page_id = wp_insert_post($page_data);
1284
-    update_option($option, $page_id);
1285
-    if ($page_id) {
1286
-        return true;
1287
-    } else {
1288
-        return false;
1289
-    }
1257
+	global $wpdb, $current_user;
1258
+
1259
+	if (!empty($old_id)) {
1260
+		wp_delete_post($old_id, true);
1261
+	}//delete post if already there
1262
+	else {
1263
+		$page_found = $wpdb->get_var(
1264
+			$wpdb->prepare(
1265
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1266
+				array($slug)
1267
+			)
1268
+		);
1269
+		wp_delete_post($page_found, true);
1270
+
1271
+	}
1272
+
1273
+	$page_data = array(
1274
+		'post_status' => 'publish',
1275
+		'post_type' => 'page',
1276
+		'post_author' => $current_user->ID,
1277
+		'post_name' => $slug,
1278
+		'post_title' => $page_title,
1279
+		'post_content' => '',
1280
+		'post_parent' => 0,
1281
+		'comment_status' => 'closed'
1282
+	);
1283
+	$page_id = wp_insert_post($page_data);
1284
+	update_option($option, $page_id);
1285
+	if ($page_id) {
1286
+		return true;
1287
+	} else {
1288
+		return false;
1289
+	}
1290 1290
 }
1291 1291
 
1292 1292
 /**
@@ -1298,212 +1298,212 @@  discard block
 block discarded – undo
1298 1298
  */
1299 1299
 function geodir_diagnose_default_pages()
1300 1300
 {
1301
-    global $wpdb;
1302
-    $is_error_during_diagnose = false;
1303
-    $output_str = '';
1304
-    $fix = isset($_POST['fix']) ? true : false;
1305
-
1306
-    //////////////////////////////////
1307
-    /* Diagnose GD Home Page Starts */
1308
-    //////////////////////////////////
1309
-    $option_value = get_option('geodir_home_page');
1310
-    $page = get_post($option_value);
1311
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1312
-
1313
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1314
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1315
-    else {
1316
-        $is_error_during_diagnose = true;
1317
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1318
-        if ($fix) {
1319
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1320
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1321
-            } else {
1322
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1323
-            }
1324
-        }
1325
-    }
1326
-
1327
-    ////////////////////////////////
1328
-    /* Diagnose GD Home Page Ends */
1329
-    ////////////////////////////////
1330
-
1331
-    //////////////////////////////////
1332
-    /* Diagnose Add Listing Page Starts */
1333
-    //////////////////////////////////
1334
-    $option_value = get_option('geodir_add_listing_page');
1335
-    $page = get_post($option_value);
1336
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1337
-
1338
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1339
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1340
-    else {
1341
-        $is_error_during_diagnose = true;
1342
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1343
-        if ($fix) {
1344
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1345
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1346
-            } else {
1347
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1348
-            }
1349
-        }
1350
-    }
1351
-
1352
-    ////////////////////////////////
1353
-    /* Diagnose Add Listing Page Ends */
1354
-    ////////////////////////////////
1355
-
1356
-
1357
-    //////////////////////////////////
1358
-    /* Diagnose Listing Preview Page Starts */
1359
-    //////////////////////////////////
1360
-    $option_value = get_option('geodir_preview_page');
1361
-    $page = get_post($option_value);
1362
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1363
-
1364
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1365
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1366
-    else {
1367
-        $is_error_during_diagnose = true;
1368
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1369
-        if ($fix) {
1370
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1371
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1372
-            } else {
1373
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1374
-            }
1375
-        }
1376
-    }
1377
-
1378
-    ////////////////////////////////
1379
-    /* Diagnose Listing Preview Page Ends */
1380
-    ////////////////////////////////
1381
-
1382
-    //////////////////////////////////
1383
-    /* Diagnose Listing Success Page Starts */
1384
-    //////////////////////////////////
1385
-    $option_value = get_option('geodir_success_page');
1386
-    $page = get_post($option_value);
1387
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1388
-
1389
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1390
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1391
-    else {
1392
-        $is_error_during_diagnose = true;
1393
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1394
-        if ($fix) {
1395
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1396
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1397
-            } else {
1398
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1399
-            }
1400
-        }
1401
-    }
1402
-
1403
-    ////////////////////////////////
1404
-    /* Diagnose Listing Sucess Page Ends */
1405
-    ////////////////////////////////
1406
-
1407
-    //////////////////////////////////
1408
-    /* Diagnose Info Page Starts */
1409
-    //////////////////////////////////
1410
-    $option_value = get_option('geodir_info_page');
1411
-    $page = get_post($option_value);
1412
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1413
-
1414
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1415
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1416
-    else {
1417
-        $is_error_during_diagnose = true;
1418
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1419
-        if ($fix) {
1420
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1421
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1422
-            } else {
1423
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1424
-            }
1425
-        }
1426
-    }
1427
-
1428
-    ////////////////////////////////
1429
-    /* Diagnose Info Page Ends */
1430
-    ////////////////////////////////
1431
-
1432
-    //////////////////////////////////
1433
-    /* Diagnose Login Page Starts */
1434
-    //////////////////////////////////
1435
-    $option_value = get_option('geodir_login_page');
1436
-    $page = get_post($option_value);
1437
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1438
-
1439
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1440
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1441
-    else {
1442
-        $is_error_during_diagnose = true;
1443
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1444
-        if ($fix) {
1445
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1446
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1447
-            } else {
1448
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1449
-            }
1450
-        }
1451
-    }
1452
-
1453
-    ////////////////////////////////
1454
-    /* Diagnose Info Page Ends */
1455
-    ////////////////////////////////
1456
-
1457
-    //////////////////////////////////
1458
-    /* Diagnose Location Page Starts */
1459
-    //////////////////////////////////
1460
-    $option_value = get_option('geodir_location_page');
1461
-    $page = get_post($option_value);
1462
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1463
-
1464
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1465
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1466
-    else {
1467
-        $is_error_during_diagnose = true;
1468
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1469
-        if ($fix) {
1470
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1471
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1472
-            } else {
1473
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1474
-            }
1475
-        }
1476
-    }
1477
-
1478
-    ////////////////////////////////
1479
-    /* Diagnose Location Page Ends */
1480
-    ////////////////////////////////
1481
-
1482
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1483
-    /**
1484
-     * This action is called at the end of the GD Tools page check function.
1485
-     *
1486
-     * @since 1.5.2
1487
-     */
1488
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1489
-
1490
-    $output_str = $page_chk_arr['output_str'];
1491
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1492
-
1493
-    if ($is_error_during_diagnose) {
1494
-        if ($fix) {
1495
-            flush_rewrite_rules();
1496
-        }
1497
-        $info_div_class = "geodir_problem_info";
1498
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1499
-    } else {
1500
-        $info_div_class = "geodir_noproblem_info";
1501
-        $fix_button_txt = '';
1502
-    }
1503
-    echo "<ul class='$info_div_class'>";
1504
-    echo $output_str;
1505
-    echo $fix_button_txt;
1506
-    echo "</ul>";
1301
+	global $wpdb;
1302
+	$is_error_during_diagnose = false;
1303
+	$output_str = '';
1304
+	$fix = isset($_POST['fix']) ? true : false;
1305
+
1306
+	//////////////////////////////////
1307
+	/* Diagnose GD Home Page Starts */
1308
+	//////////////////////////////////
1309
+	$option_value = get_option('geodir_home_page');
1310
+	$page = get_post($option_value);
1311
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1312
+
1313
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1314
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1315
+	else {
1316
+		$is_error_during_diagnose = true;
1317
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1318
+		if ($fix) {
1319
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1320
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1321
+			} else {
1322
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1323
+			}
1324
+		}
1325
+	}
1326
+
1327
+	////////////////////////////////
1328
+	/* Diagnose GD Home Page Ends */
1329
+	////////////////////////////////
1330
+
1331
+	//////////////////////////////////
1332
+	/* Diagnose Add Listing Page Starts */
1333
+	//////////////////////////////////
1334
+	$option_value = get_option('geodir_add_listing_page');
1335
+	$page = get_post($option_value);
1336
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1337
+
1338
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1339
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1340
+	else {
1341
+		$is_error_during_diagnose = true;
1342
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1343
+		if ($fix) {
1344
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1345
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1346
+			} else {
1347
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1348
+			}
1349
+		}
1350
+	}
1351
+
1352
+	////////////////////////////////
1353
+	/* Diagnose Add Listing Page Ends */
1354
+	////////////////////////////////
1355
+
1356
+
1357
+	//////////////////////////////////
1358
+	/* Diagnose Listing Preview Page Starts */
1359
+	//////////////////////////////////
1360
+	$option_value = get_option('geodir_preview_page');
1361
+	$page = get_post($option_value);
1362
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1363
+
1364
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1365
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1366
+	else {
1367
+		$is_error_during_diagnose = true;
1368
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1369
+		if ($fix) {
1370
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1371
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1372
+			} else {
1373
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1374
+			}
1375
+		}
1376
+	}
1377
+
1378
+	////////////////////////////////
1379
+	/* Diagnose Listing Preview Page Ends */
1380
+	////////////////////////////////
1381
+
1382
+	//////////////////////////////////
1383
+	/* Diagnose Listing Success Page Starts */
1384
+	//////////////////////////////////
1385
+	$option_value = get_option('geodir_success_page');
1386
+	$page = get_post($option_value);
1387
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1388
+
1389
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1390
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1391
+	else {
1392
+		$is_error_during_diagnose = true;
1393
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1394
+		if ($fix) {
1395
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1396
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1397
+			} else {
1398
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1399
+			}
1400
+		}
1401
+	}
1402
+
1403
+	////////////////////////////////
1404
+	/* Diagnose Listing Sucess Page Ends */
1405
+	////////////////////////////////
1406
+
1407
+	//////////////////////////////////
1408
+	/* Diagnose Info Page Starts */
1409
+	//////////////////////////////////
1410
+	$option_value = get_option('geodir_info_page');
1411
+	$page = get_post($option_value);
1412
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1413
+
1414
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1415
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1416
+	else {
1417
+		$is_error_during_diagnose = true;
1418
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1419
+		if ($fix) {
1420
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1421
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1422
+			} else {
1423
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1424
+			}
1425
+		}
1426
+	}
1427
+
1428
+	////////////////////////////////
1429
+	/* Diagnose Info Page Ends */
1430
+	////////////////////////////////
1431
+
1432
+	//////////////////////////////////
1433
+	/* Diagnose Login Page Starts */
1434
+	//////////////////////////////////
1435
+	$option_value = get_option('geodir_login_page');
1436
+	$page = get_post($option_value);
1437
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1438
+
1439
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1440
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1441
+	else {
1442
+		$is_error_during_diagnose = true;
1443
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1444
+		if ($fix) {
1445
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1446
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1447
+			} else {
1448
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1449
+			}
1450
+		}
1451
+	}
1452
+
1453
+	////////////////////////////////
1454
+	/* Diagnose Info Page Ends */
1455
+	////////////////////////////////
1456
+
1457
+	//////////////////////////////////
1458
+	/* Diagnose Location Page Starts */
1459
+	//////////////////////////////////
1460
+	$option_value = get_option('geodir_location_page');
1461
+	$page = get_post($option_value);
1462
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1463
+
1464
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1465
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1466
+	else {
1467
+		$is_error_during_diagnose = true;
1468
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1469
+		if ($fix) {
1470
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1471
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1472
+			} else {
1473
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1474
+			}
1475
+		}
1476
+	}
1477
+
1478
+	////////////////////////////////
1479
+	/* Diagnose Location Page Ends */
1480
+	////////////////////////////////
1481
+
1482
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1483
+	/**
1484
+	 * This action is called at the end of the GD Tools page check function.
1485
+	 *
1486
+	 * @since 1.5.2
1487
+	 */
1488
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1489
+
1490
+	$output_str = $page_chk_arr['output_str'];
1491
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1492
+
1493
+	if ($is_error_during_diagnose) {
1494
+		if ($fix) {
1495
+			flush_rewrite_rules();
1496
+		}
1497
+		$info_div_class = "geodir_problem_info";
1498
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1499
+	} else {
1500
+		$info_div_class = "geodir_noproblem_info";
1501
+		$fix_button_txt = '';
1502
+	}
1503
+	echo "<ul class='$info_div_class'>";
1504
+	echo $output_str;
1505
+	echo $fix_button_txt;
1506
+	echo "</ul>";
1507 1507
 
1508 1508
 }
1509 1509
 
@@ -1515,25 +1515,25 @@  discard block
 block discarded – undo
1515 1515
  * @global object $wpdb WordPress Database object.
1516 1516
  */
1517 1517
 function geodir_diagnose_load_db_language() {
1518
-    global $wpdb;
1518
+	global $wpdb;
1519 1519
 	
1520 1520
 	$is_error_during_diagnose = geodirectory_load_db_language();
1521 1521
 
1522
-    $output_str = '';
1522
+	$output_str = '';
1523 1523
 
1524
-    if ($is_error_during_diagnose) {
1525
-        $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>";
1524
+	if ($is_error_during_diagnose) {
1525
+		$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>";
1526 1526
 		$info_div_class = "geodir_problem_info";
1527
-    } else {
1528
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1527
+	} else {
1528
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1529 1529
 		$info_div_class = "geodir_noproblem_info";
1530
-        $fix_button_txt = '';
1531
-    }
1530
+		$fix_button_txt = '';
1531
+	}
1532 1532
     
1533 1533
 	echo "<ul class='$info_div_class'>";
1534
-    echo $output_str;
1535
-    echo $fix_button_txt;
1536
-    echo "</ul>";
1534
+	echo $output_str;
1535
+	echo $fix_button_txt;
1536
+	echo "</ul>";
1537 1537
 
1538 1538
 }
1539 1539
 
@@ -1564,23 +1564,23 @@  discard block
 block discarded – undo
1564 1564
  */
1565 1565
 function geodir_posts_clauses_request($clauses)
1566 1566
 {
1567
-    global $wpdb, $wp_query, $plugin_prefix;
1567
+	global $wpdb, $wp_query, $plugin_prefix;
1568 1568
 
1569
-    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'])) {
1570
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1569
+	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'])) {
1570
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1571 1571
 
1572
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1573
-        $clauses['join'] = $join;
1572
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1573
+		$clauses['join'] = $join;
1574 1574
 
1575
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1576
-        $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';
1577
-        $clauses['fields'] = $fields;
1575
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1576
+		$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';
1577
+		$clauses['fields'] = $fields;
1578 1578
 
1579
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1580
-        $orderby = 'gd_expire ' . $order;
1581
-        $clauses['orderby'] = $orderby;
1582
-    }
1583
-    return $clauses;
1579
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1580
+		$orderby = 'gd_expire ' . $order;
1581
+		$clauses['orderby'] = $orderby;
1582
+	}
1583
+	return $clauses;
1584 1584
 }
1585 1585
 
1586 1586
 
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
  */
1602 1602
 function gd_theme_switch_compat_check()
1603 1603
 {
1604
-    gd_set_theme_compat();
1604
+	gd_set_theme_compat();
1605 1605
 }
1606 1606
 
1607 1607
 /**
@@ -1614,27 +1614,27 @@  discard block
 block discarded – undo
1614 1614
  */
1615 1615
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1616 1616
 {
1617
-    if (function_exists('str_getcsv')) {
1618
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1619
-    } else {
1620
-        global $current_user;
1621
-        $upload_dir = wp_upload_dir();
1622
-
1623
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1624
-        $handle = fopen($file, 'w');
1625
-
1626
-        fwrite($handle, $input);
1627
-        fclose($handle);
1628
-
1629
-        $handle = fopen($file, 'rt');
1630
-        if (PHP_VERSION >= '5.3.0') {
1631
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1632
-        } else {
1633
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1634
-        }
1635
-        fclose($handle);
1636
-    }
1637
-    return $fgetcsv;
1617
+	if (function_exists('str_getcsv')) {
1618
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1619
+	} else {
1620
+		global $current_user;
1621
+		$upload_dir = wp_upload_dir();
1622
+
1623
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1624
+		$handle = fopen($file, 'w');
1625
+
1626
+		fwrite($handle, $input);
1627
+		fclose($handle);
1628
+
1629
+		$handle = fopen($file, 'rt');
1630
+		if (PHP_VERSION >= '5.3.0') {
1631
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1632
+		} else {
1633
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1634
+		}
1635
+		fclose($handle);
1636
+	}
1637
+	return $fgetcsv;
1638 1638
 }
1639 1639
 
1640 1640
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1649,375 +1649,375 @@  discard block
 block discarded – undo
1649 1649
  */
1650 1650
 function geodir_ajax_import_csv()
1651 1651
 {
1652
-    error_reporting(0); // hide error to get clean json response
1652
+	error_reporting(0); // hide error to get clean json response
1653 1653
 
1654
-    global $wpdb, $plugin_prefix, $current_user;
1655
-    $uploads = wp_upload_dir();
1656
-    ini_set('auto_detect_line_endings', true);
1654
+	global $wpdb, $plugin_prefix, $current_user;
1655
+	$uploads = wp_upload_dir();
1656
+	ini_set('auto_detect_line_endings', true);
1657 1657
 	
1658 1658
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1659 1659
 
1660
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1661
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1662
-    $filename = $uploadedFile;
1663
-
1664
-    $uploads = wp_upload_dir();
1665
-    $uploads_dir = $uploads['path'];
1666
-    $image_name_arr = explode('/', $filename);
1667
-    $filename = end($image_name_arr);
1668
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1669
-    $return = array();
1670
-    $return['file'] = $uploadedFile;
1671
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1672
-
1673
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1674
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1675
-
1676
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1677
-            $return['error'] = NULL;
1678
-
1679
-            $return['rows'] = 0;
1680
-
1681
-
1682
-
1683
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1684
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1685
-                        if(is_array($data) && !empty($data)) {
1686
-                            $file[] = '"' . implode('","', $data) . '"';
1687
-                        }
1688
-                    }
1689
-                    fclose($handle);
1690
-                    $file = $file;
1691
-                }
1692
-
1693
-
1694
-
1695
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1696
-
1697
-
1698
-            if (!$return['rows'] > 0) {
1699
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
1700
-            }
1701
-        }
1702
-    }
1703
-    if ($task == 'prepare' || !empty($return['error'])) {
1704
-        echo json_encode($return);
1705
-        exit;
1706
-    }
1707
-
1708
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1709
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1710
-    $count = $importlimit;
1711
-    $requested_limit = $importlimit;
1712
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1713
-
1714
-    if ($count < $totRecords) {
1715
-        $count = $tmpCnt + $count;
1716
-        if ($count > $totRecords) {
1717
-            $count = $totRecords;
1718
-        }
1719
-    } else {
1720
-        $count = $totRecords;
1721
-    }
1722
-
1723
-    $total_records = 0;
1724
-    $rowcount = 0;
1725
-    $address_invalid = 0;
1726
-    $blank_address = 0;
1727
-    $upload_files = 0;
1728
-    $invalid_post_type = 0;
1729
-    $invalid_title = 0;
1730
-    $customKeyarray = array();
1731
-    $gd_post_info = array();
1732
-    $post_location = array();
1733
-    $countpost = 0;
1734
-
1735
-    if (!empty($file)) {
1736
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1737
-        $customKeyarray = $columns;
1738
-
1739
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1740
-            $return['error'] = CSV_INVAILD_FILE;
1741
-            echo json_encode($return);
1742
-            exit;
1743
-        }
1744
-
1745
-        for ($i = 1; $i <= $importlimit; $i++) {
1746
-            $current_index = $tmpCnt + $i;
1747
-            if (isset($file[$current_index])) {
1748
-                $total_records++;
1749
-
1750
-                $buffer = geodir_str_getcsv($file[$current_index]);
1751
-                $post_title = addslashes($buffer[0]);
1752
-                $current_post_author = $buffer[1];
1753
-                $post_desc = addslashes($buffer[2]);
1754
-                $post_cat = array();
1755
-                $catids_arr = array();
1756
-                $post_cat = trim($buffer[3]); // comma seperated category name
1757
-
1758
-                if ($post_cat) {
1759
-                    $post_cat_arr = explode(',', $post_cat);
1760
-
1761
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
1762
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1763
-
1764
-                        if (!empty($buffer[5])) {
1765
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
1766
-
1767
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1768
-
1769
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
1770
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1771
-                                    $catids_arr[] = $cat->slug;
1772
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1773
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1774
-                                    $catids_arr[] = $cat->slug;
1775
-                                } else {
1776
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
1777
-                                    if ($ret && !is_wp_error($ret)) {
1778
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
1779
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1780
-                                            $catids_arr[] = $cat->slug;
1781
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1782
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1783
-                                            $catids_arr[] = $cat->slug;
1784
-                                        }
1785
-                                    }
1786
-                                }
1787
-                            }
1788
-                        }
1789
-                    }
1790
-                }
1791
-
1792
-                if (!$catids_arr) {
1793
-                    $catids_arr[] = 1;
1794
-                }
1795
-
1796
-                $post_tags = trim($buffer[4]); // comma seperated tags
1797
-
1798
-                $tag_arr = '';
1799
-                if ($post_tags) {
1800
-                    $tag_arr = explode(',', $post_tags);
1801
-                }
1802
-
1803
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1804
-
1805
-                $error = '';
1806
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1807
-                    $invalid_post_type++;
1808
-                    continue;
1809
-                }
1810
-
1811
-                if ($post_title != '') {
1812
-                    $menu_order = 0;
1813
-                    $image_folder_name = 'uplaod/';
1814
-
1815
-                    $image_names = array();
1816
-
1817
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
1818
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1819
-
1820
-                        if ($customKeyarray[$c] == 'IMAGE') {
1821
-                            $buffer[$c] = trim($buffer[$c]);
1822
-
1823
-                            if (!empty($buffer[$c])) {
1824
-                                $image_names[] = $buffer[$c];
1825
-                            }
1826
-                        }
1827
-
1828
-                        if ($customKeyarray[$c] == 'alive_days') {
1829
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
1830
-                                $submitdata = date('Y-m-d');
1831
-
1832
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1833
-                            } else {
1834
-                                $gd_post_info['expire_date'] = 'Never';
1835
-                            }
1836
-                        }
1837
-
1838
-                        if ($customKeyarray[$c] == 'post_city') {
1839
-                            $post_city = addslashes($buffer[$c]);
1840
-                        }
1841
-
1842
-                        if ($customKeyarray[$c] == 'post_region') {
1843
-                            $post_region = addslashes($buffer[$c]);
1844
-                        }
1845
-
1846
-                        if ($customKeyarray[$c] == 'post_country') {
1847
-                            $post_country = addslashes($buffer[$c]);
1848
-                        }
1849
-
1850
-                        if ($customKeyarray[$c] == 'post_latitude') {
1851
-                            $post_latitude = addslashes($buffer[$c]);
1852
-                        }
1853
-
1854
-                        if ($customKeyarray[$c] == 'post_longitude') {
1855
-                            $post_longitude = addslashes($buffer[$c]);
1856
-                        }
1660
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1661
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1662
+	$filename = $uploadedFile;
1663
+
1664
+	$uploads = wp_upload_dir();
1665
+	$uploads_dir = $uploads['path'];
1666
+	$image_name_arr = explode('/', $filename);
1667
+	$filename = end($image_name_arr);
1668
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1669
+	$return = array();
1670
+	$return['file'] = $uploadedFile;
1671
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1672
+
1673
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1674
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1675
+
1676
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1677
+			$return['error'] = NULL;
1678
+
1679
+			$return['rows'] = 0;
1680
+
1681
+
1682
+
1683
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1684
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1685
+						if(is_array($data) && !empty($data)) {
1686
+							$file[] = '"' . implode('","', $data) . '"';
1687
+						}
1688
+					}
1689
+					fclose($handle);
1690
+					$file = $file;
1691
+				}
1692
+
1693
+
1694
+
1695
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1696
+
1697
+
1698
+			if (!$return['rows'] > 0) {
1699
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
1700
+			}
1701
+		}
1702
+	}
1703
+	if ($task == 'prepare' || !empty($return['error'])) {
1704
+		echo json_encode($return);
1705
+		exit;
1706
+	}
1707
+
1708
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1709
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1710
+	$count = $importlimit;
1711
+	$requested_limit = $importlimit;
1712
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1713
+
1714
+	if ($count < $totRecords) {
1715
+		$count = $tmpCnt + $count;
1716
+		if ($count > $totRecords) {
1717
+			$count = $totRecords;
1718
+		}
1719
+	} else {
1720
+		$count = $totRecords;
1721
+	}
1722
+
1723
+	$total_records = 0;
1724
+	$rowcount = 0;
1725
+	$address_invalid = 0;
1726
+	$blank_address = 0;
1727
+	$upload_files = 0;
1728
+	$invalid_post_type = 0;
1729
+	$invalid_title = 0;
1730
+	$customKeyarray = array();
1731
+	$gd_post_info = array();
1732
+	$post_location = array();
1733
+	$countpost = 0;
1734
+
1735
+	if (!empty($file)) {
1736
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1737
+		$customKeyarray = $columns;
1738
+
1739
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1740
+			$return['error'] = CSV_INVAILD_FILE;
1741
+			echo json_encode($return);
1742
+			exit;
1743
+		}
1744
+
1745
+		for ($i = 1; $i <= $importlimit; $i++) {
1746
+			$current_index = $tmpCnt + $i;
1747
+			if (isset($file[$current_index])) {
1748
+				$total_records++;
1749
+
1750
+				$buffer = geodir_str_getcsv($file[$current_index]);
1751
+				$post_title = addslashes($buffer[0]);
1752
+				$current_post_author = $buffer[1];
1753
+				$post_desc = addslashes($buffer[2]);
1754
+				$post_cat = array();
1755
+				$catids_arr = array();
1756
+				$post_cat = trim($buffer[3]); // comma seperated category name
1757
+
1758
+				if ($post_cat) {
1759
+					$post_cat_arr = explode(',', $post_cat);
1760
+
1761
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
1762
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1763
+
1764
+						if (!empty($buffer[5])) {
1765
+							if (in_array($buffer[5], geodir_get_posttypes())) {
1766
+
1767
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1768
+
1769
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
1770
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1771
+									$catids_arr[] = $cat->slug;
1772
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1773
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1774
+									$catids_arr[] = $cat->slug;
1775
+								} else {
1776
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
1777
+									if ($ret && !is_wp_error($ret)) {
1778
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
1779
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1780
+											$catids_arr[] = $cat->slug;
1781
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1782
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1783
+											$catids_arr[] = $cat->slug;
1784
+										}
1785
+									}
1786
+								}
1787
+							}
1788
+						}
1789
+					}
1790
+				}
1791
+
1792
+				if (!$catids_arr) {
1793
+					$catids_arr[] = 1;
1794
+				}
1795
+
1796
+				$post_tags = trim($buffer[4]); // comma seperated tags
1797
+
1798
+				$tag_arr = '';
1799
+				if ($post_tags) {
1800
+					$tag_arr = explode(',', $post_tags);
1801
+				}
1802
+
1803
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1804
+
1805
+				$error = '';
1806
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1807
+					$invalid_post_type++;
1808
+					continue;
1809
+				}
1810
+
1811
+				if ($post_title != '') {
1812
+					$menu_order = 0;
1813
+					$image_folder_name = 'uplaod/';
1814
+
1815
+					$image_names = array();
1816
+
1817
+					for ($c = 5; $c < count($customKeyarray); $c++) {
1818
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1819
+
1820
+						if ($customKeyarray[$c] == 'IMAGE') {
1821
+							$buffer[$c] = trim($buffer[$c]);
1822
+
1823
+							if (!empty($buffer[$c])) {
1824
+								$image_names[] = $buffer[$c];
1825
+							}
1826
+						}
1827
+
1828
+						if ($customKeyarray[$c] == 'alive_days') {
1829
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
1830
+								$submitdata = date('Y-m-d');
1831
+
1832
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1833
+							} else {
1834
+								$gd_post_info['expire_date'] = 'Never';
1835
+							}
1836
+						}
1837
+
1838
+						if ($customKeyarray[$c] == 'post_city') {
1839
+							$post_city = addslashes($buffer[$c]);
1840
+						}
1841
+
1842
+						if ($customKeyarray[$c] == 'post_region') {
1843
+							$post_region = addslashes($buffer[$c]);
1844
+						}
1845
+
1846
+						if ($customKeyarray[$c] == 'post_country') {
1847
+							$post_country = addslashes($buffer[$c]);
1848
+						}
1849
+
1850
+						if ($customKeyarray[$c] == 'post_latitude') {
1851
+							$post_latitude = addslashes($buffer[$c]);
1852
+						}
1853
+
1854
+						if ($customKeyarray[$c] == 'post_longitude') {
1855
+							$post_longitude = addslashes($buffer[$c]);
1856
+						}
1857 1857
 						
1858 1858
 						// Post status
1859 1859
 						if ($customKeyarray[$c] == 'post_status') {
1860
-                            $post_status = sanitize_key( $buffer[$c] );
1861
-                        }
1862
-                    }
1863
-
1864
-                    /* ================ before array create ============== */
1865
-                    $location_result = geodir_get_default_location();
1866
-                    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'] == '')) {
1867
-                        $blank_address++;
1868
-                        continue;
1869
-                    } else if ($location_result->location_id == 0) {
1870
-                        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))) {
1871
-                            $address_invalid++;
1872
-                            continue;
1873
-                        }
1874
-                    }
1860
+							$post_status = sanitize_key( $buffer[$c] );
1861
+						}
1862
+					}
1863
+
1864
+					/* ================ before array create ============== */
1865
+					$location_result = geodir_get_default_location();
1866
+					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'] == '')) {
1867
+						$blank_address++;
1868
+						continue;
1869
+					} else if ($location_result->location_id == 0) {
1870
+						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))) {
1871
+							$address_invalid++;
1872
+							continue;
1873
+						}
1874
+					}
1875 1875
 					
1876 1876
 					// Default post status
1877 1877
 					$default_status = 'publish';
1878 1878
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
1879 1879
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
1880 1880
 
1881
-                    $my_post['post_title'] = $post_title;
1882
-                    $my_post['post_content'] = $post_desc;
1883
-                    $my_post['post_type'] = addslashes($buffer[5]);
1884
-                    $my_post['post_author'] = $current_post_author;
1885
-                    $my_post['post_status'] = $post_status;
1886
-                    $my_post['post_category'] = $catids_arr;
1887
-                    $my_post['post_tags'] = $tag_arr;
1888
-
1889
-                    $gd_post_info['post_tags'] = $tag_arr;
1890
-                    $gd_post_info['post_title'] = $post_title;
1891
-                    $gd_post_info['post_status'] = $post_status;
1892
-                    $gd_post_info['submit_time'] = time();
1893
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1894
-
1895
-                    $last_postid = wp_insert_post($my_post);
1896
-                    $countpost++;
1897
-
1898
-                    // Check if we need to save post location as new location
1899
-                    if ($location_result->location_id > 0) {
1900
-                        if (isset($post_city) && isset($post_region)) {
1901
-                            $request_info['post_location'] = array(
1902
-                                'city' => $post_city,
1903
-                                'region' => $post_region,
1904
-                                'country' => $post_country,
1905
-                                'geo_lat' => $post_latitude,
1906
-                                'geo_lng' => $post_longitude
1907
-                            );
1908
-
1909
-                            $post_location_info = $request_info['post_location'];
1910
-                            if ($location_id = geodir_add_new_location($post_location_info))
1911
-                                $post_location_id = $location_id;
1912
-                        } else {
1913
-                            $post_location_id = 0;
1914
-                        }
1915
-                    } else {
1916
-                        $post_location_id = 0;
1917
-                    }
1918
-
1919
-                    /* ------- get default package info ----- */
1920
-                    $payment_info = array();
1921
-                    $package_info = array();
1922
-
1923
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1924
-                    $package_id = '';
1925
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1926
-                        $package_id = $gd_post_info['package_id'];
1927
-                    }
1928
-
1929
-                    if (!empty($package_info)) {
1930
-                        $payment_info['package_id'] = $package_info['pid'];
1931
-
1932
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1933
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1934
-                        } else {
1935
-                            $payment_info['expire_date'] = 'Never';
1936
-                        }
1937
-
1938
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
1939
-                    }
1940
-
1941
-                    $gd_post_info['post_location_id'] = $post_location_id;
1942
-
1943
-                    $post_type = get_post_type($last_postid);
1944
-
1945
-                    $table = $plugin_prefix . $post_type . '_detail';
1946
-
1947
-                    geodir_save_post_info($last_postid, $gd_post_info);
1948
-
1949
-                    if (!empty($image_names)) {
1950
-                        $upload_files++;
1951
-                        $menu_order = 1;
1952
-
1953
-                        foreach ($image_names as $image_name) {
1954
-                            $img_name_arr = explode('.', $image_name);
1955
-
1956
-                            $uploads = wp_upload_dir();
1957
-                            $sub_dir = $uploads['subdir'];
1958
-
1959
-                            $arr_file_type = wp_check_filetype($image_name);
1960
-                            $uploaded_file_type = $arr_file_type['type'];
1961
-
1962
-                            $attachment = array();
1963
-                            $attachment['post_id'] = $last_postid;
1964
-                            $attachment['title'] = $img_name_arr[0];
1965
-                            $attachment['content'] = '';
1966
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
1967
-                            $attachment['mime_type'] = $uploaded_file_type;
1968
-                            $attachment['menu_order'] = $menu_order;
1969
-                            $attachment['is_featured'] = 0;
1970
-
1971
-                            $attachment_set = '';
1972
-
1973
-                            foreach ($attachment as $key => $val) {
1974
-                                if ($val != '')
1975
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1976
-                            }
1977
-                            $attachment_set = trim($attachment_set, ", ");
1978
-
1979
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1980
-
1981
-                            if ($menu_order == 1) {
1982
-                                $post_type = get_post_type($last_postid);
1983
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1984
-                            }
1985
-                            $menu_order++;
1986
-                        }
1987
-                    }
1988
-
1989
-                    $gd_post_info['package_id'] = $package_id;
1990
-
1991
-                    /** This action is documented in geodirectory-functions/post-functions.php */
1992
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1993
-
1994
-                    if (!empty($buffer[5])) {
1995
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
1996
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
1997
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
1998
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
1999
-
2000
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2001
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2002
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2003
-                        }
2004
-                    }
2005
-                } else {
2006
-                    $invalid_title++;
2007
-                }
2008
-            }
2009
-        }
2010
-    }
2011
-    $return['rowcount'] = $countpost;
2012
-    $return['invalidcount'] = $address_invalid;
2013
-    $return['blank_address'] = $blank_address;
2014
-    $return['upload_files'] = $upload_files;
2015
-    $return['invalid_post_type'] = $invalid_post_type;
2016
-    $return['invalid_title'] = $invalid_title;
2017
-    $return['total_records'] = $total_records;
2018
-
2019
-    echo json_encode($return);
2020
-    exit;
1881
+					$my_post['post_title'] = $post_title;
1882
+					$my_post['post_content'] = $post_desc;
1883
+					$my_post['post_type'] = addslashes($buffer[5]);
1884
+					$my_post['post_author'] = $current_post_author;
1885
+					$my_post['post_status'] = $post_status;
1886
+					$my_post['post_category'] = $catids_arr;
1887
+					$my_post['post_tags'] = $tag_arr;
1888
+
1889
+					$gd_post_info['post_tags'] = $tag_arr;
1890
+					$gd_post_info['post_title'] = $post_title;
1891
+					$gd_post_info['post_status'] = $post_status;
1892
+					$gd_post_info['submit_time'] = time();
1893
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1894
+
1895
+					$last_postid = wp_insert_post($my_post);
1896
+					$countpost++;
1897
+
1898
+					// Check if we need to save post location as new location
1899
+					if ($location_result->location_id > 0) {
1900
+						if (isset($post_city) && isset($post_region)) {
1901
+							$request_info['post_location'] = array(
1902
+								'city' => $post_city,
1903
+								'region' => $post_region,
1904
+								'country' => $post_country,
1905
+								'geo_lat' => $post_latitude,
1906
+								'geo_lng' => $post_longitude
1907
+							);
1908
+
1909
+							$post_location_info = $request_info['post_location'];
1910
+							if ($location_id = geodir_add_new_location($post_location_info))
1911
+								$post_location_id = $location_id;
1912
+						} else {
1913
+							$post_location_id = 0;
1914
+						}
1915
+					} else {
1916
+						$post_location_id = 0;
1917
+					}
1918
+
1919
+					/* ------- get default package info ----- */
1920
+					$payment_info = array();
1921
+					$package_info = array();
1922
+
1923
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1924
+					$package_id = '';
1925
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1926
+						$package_id = $gd_post_info['package_id'];
1927
+					}
1928
+
1929
+					if (!empty($package_info)) {
1930
+						$payment_info['package_id'] = $package_info['pid'];
1931
+
1932
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1933
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1934
+						} else {
1935
+							$payment_info['expire_date'] = 'Never';
1936
+						}
1937
+
1938
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
1939
+					}
1940
+
1941
+					$gd_post_info['post_location_id'] = $post_location_id;
1942
+
1943
+					$post_type = get_post_type($last_postid);
1944
+
1945
+					$table = $plugin_prefix . $post_type . '_detail';
1946
+
1947
+					geodir_save_post_info($last_postid, $gd_post_info);
1948
+
1949
+					if (!empty($image_names)) {
1950
+						$upload_files++;
1951
+						$menu_order = 1;
1952
+
1953
+						foreach ($image_names as $image_name) {
1954
+							$img_name_arr = explode('.', $image_name);
1955
+
1956
+							$uploads = wp_upload_dir();
1957
+							$sub_dir = $uploads['subdir'];
1958
+
1959
+							$arr_file_type = wp_check_filetype($image_name);
1960
+							$uploaded_file_type = $arr_file_type['type'];
1961
+
1962
+							$attachment = array();
1963
+							$attachment['post_id'] = $last_postid;
1964
+							$attachment['title'] = $img_name_arr[0];
1965
+							$attachment['content'] = '';
1966
+							$attachment['file'] = $sub_dir . '/' . $image_name;
1967
+							$attachment['mime_type'] = $uploaded_file_type;
1968
+							$attachment['menu_order'] = $menu_order;
1969
+							$attachment['is_featured'] = 0;
1970
+
1971
+							$attachment_set = '';
1972
+
1973
+							foreach ($attachment as $key => $val) {
1974
+								if ($val != '')
1975
+									$attachment_set .= $key . " = '" . $val . "', ";
1976
+							}
1977
+							$attachment_set = trim($attachment_set, ", ");
1978
+
1979
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1980
+
1981
+							if ($menu_order == 1) {
1982
+								$post_type = get_post_type($last_postid);
1983
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1984
+							}
1985
+							$menu_order++;
1986
+						}
1987
+					}
1988
+
1989
+					$gd_post_info['package_id'] = $package_id;
1990
+
1991
+					/** This action is documented in geodirectory-functions/post-functions.php */
1992
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1993
+
1994
+					if (!empty($buffer[5])) {
1995
+						if (in_array($buffer[5], geodir_get_posttypes())) {
1996
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
1997
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
1998
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
1999
+
2000
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2001
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2002
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2003
+						}
2004
+					}
2005
+				} else {
2006
+					$invalid_title++;
2007
+				}
2008
+			}
2009
+		}
2010
+	}
2011
+	$return['rowcount'] = $countpost;
2012
+	$return['invalidcount'] = $address_invalid;
2013
+	$return['blank_address'] = $blank_address;
2014
+	$return['upload_files'] = $upload_files;
2015
+	$return['invalid_post_type'] = $invalid_post_type;
2016
+	$return['invalid_title'] = $invalid_title;
2017
+	$return['total_records'] = $total_records;
2018
+
2019
+	echo json_encode($return);
2020
+	exit;
2021 2021
 }
2022 2022
 
2023 2023
 // Add the tab in left sidebar menu fro import & export page.
@@ -2037,9 +2037,9 @@  discard block
 block discarded – undo
2037 2037
  * @param $post object $post The post object of the post being saved.
2038 2038
  */
2039 2039
 function geodir_update_location_prefix($post_id,$post){
2040
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2041
-        update_option('geodir_location_prefix',$post->post_name);
2042
-    }
2040
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2041
+		update_option('geodir_location_prefix',$post->post_name);
2042
+	}
2043 2043
 
2044 2044
 }
2045 2045
 
@@ -2050,50 +2050,50 @@  discard block
 block discarded – undo
2050 2050
 function geodir_ga_callback(){
2051 2051
 
2052 2052
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2053
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2054
-    $code = "code=".$_REQUEST['code'];
2055
-    $grant_type = "&grant_type=authorization_code";
2056
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2057
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2058
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2053
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2054
+	$code = "code=".$_REQUEST['code'];
2055
+	$grant_type = "&grant_type=authorization_code";
2056
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2057
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2058
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2059 2059
 
2060
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2060
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2061 2061
 
2062
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2062
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2063 2063
 
2064
-    //print_r($response);
2064
+	//print_r($response);
2065 2065
 
2066
-    $error_msg =  __('Something went wrong','geodirectory');
2067
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2066
+	$error_msg =  __('Something went wrong','geodirectory');
2067
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2068 2068
 
2069
-        $parts = json_decode($response['body']);
2070
-        //print_r($parts);
2071
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2072
-        else{
2069
+		$parts = json_decode($response['body']);
2070
+		//print_r($parts);
2071
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2072
+		else{
2073 2073
 
2074
-            update_option('gd_ga_access_token', $parts->access_token);
2075
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2076
-            ?><script>window.close();</script><?php
2077
-        }
2074
+			update_option('gd_ga_access_token', $parts->access_token);
2075
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2076
+			?><script>window.close();</script><?php
2077
+		}
2078 2078
 
2079 2079
 
2080
-    }
2081
-    elseif(!empty($response['response']['code'])) {
2082
-        $parts = json_decode($response['body']);
2080
+	}
2081
+	elseif(!empty($response['response']['code'])) {
2082
+		$parts = json_decode($response['body']);
2083 2083
 
2084
-        if(isset($parts->error)){
2085
-            echo $parts->error.": ".$parts->error_description;exit;
2086
-        }else{
2087
-            echo $error_msg." - #2";exit;
2088
-        }
2084
+		if(isset($parts->error)){
2085
+			echo $parts->error.": ".$parts->error_description;exit;
2086
+		}else{
2087
+			echo $error_msg." - #2";exit;
2088
+		}
2089 2089
 
2090
-    }else{
2090
+	}else{
2091 2091
 
2092
-        echo $error_msg." - #3";exit;
2092
+		echo $error_msg." - #3";exit;
2093 2093
 
2094
-    }
2094
+	}
2095 2095
 }
2096
-    exit;
2096
+	exit;
2097 2097
 }
2098 2098
 
2099 2099
 add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
Please login to merge, or discard this patch.
geodirectory-functions/cat-meta-functions/Tax-meta-class.php 4 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -2054,6 +2054,11 @@  discard block
 block discarded – undo
2054 2054
         }
2055 2055
 
2056 2056
         //update meta
2057
+
2058
+        /**
2059
+         * @param string $term_id
2060
+         * @param string $key
2061
+         */
2057 2062
         public function update_tax_meta($term_id, $key, $value, $post_type = '')
2058 2063
         {
2059 2064
 
@@ -2095,6 +2100,12 @@  discard block
 block discarded – undo
2095 2100
 
2096 2101
 //get term meta field
2097 2102
 if (!function_exists('get_tax_meta')) {
2103
+
2104
+    /**
2105
+     * @param string $key
2106
+     *
2107
+     * @return string
2108
+     */
2098 2109
     function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2099 2110
     {
2100 2111
 
@@ -2139,6 +2150,10 @@  discard block
 block discarded – undo
2139 2150
 
2140 2151
 //update meta
2141 2152
 if (!function_exists('update_tax_meta')) {
2153
+
2154
+    /**
2155
+     * @param string $key
2156
+     */
2142 2157
     function update_tax_meta($term_id, $key, $value, $post_type = '')
2143 2158
     {
2144 2159
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
         {
804 804
 
805 805
             if (!is_array($meta))
806
-                $meta = (array)$meta;
806
+                $meta = (array) $meta;
807 807
 
808 808
             $this->show_field_begin($field, $meta);
809 809
             echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
         {
828 828
 
829 829
             if (!is_array($meta))
830
-                $meta = (array)$meta;
830
+                $meta = (array) $meta;
831 831
 
832 832
             $this->show_field_begin($field, $meta);
833 833
             foreach ($field['options'] as $key => $value) {
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
             global $post;
891 891
 
892 892
             if (!is_array($meta))
893
-                $meta = (array)$meta;
893
+                $meta = (array) $meta;
894 894
 
895 895
             $this->show_field_begin($field, $meta);
896 896
             echo "{$field['desc']}<br />";
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
         {
1014 1014
 
1015 1015
             if (!is_array($meta))
1016
-                $meta = (array)$meta;
1016
+                $meta = (array) $meta;
1017 1017
 
1018 1018
             $this->show_field_begin($field, $meta);
1019 1019
 
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
         {
1074 1074
             global $post;
1075 1075
 
1076
-            if (!is_array($meta)) $meta = (array)$meta;
1076
+            if (!is_array($meta)) $meta = (array) $meta;
1077 1077
             $this->show_field_begin($field, $meta);
1078 1078
             $options = $field['options'];
1079 1079
             $posts = get_posts($options['args']);
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
         {
1112 1112
             global $post;
1113 1113
 
1114
-            if (!is_array($meta)) $meta = (array)$meta;
1114
+            if (!is_array($meta)) $meta = (array) $meta;
1115 1115
             $this->show_field_begin($field, $meta);
1116 1116
             $options = $field['options'];
1117 1117
             $terms = get_terms($options['taxonomy'], $options['args']);
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
                 if (!is_wp_error($id)) {
1371 1371
 
1372 1372
                     wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1373
-                    add_post_meta($term_id, $name, $id, false);    // save file's url in meta fields
1373
+                    add_post_meta($term_id, $name, $id, false); // save file's url in meta fields
1374 1374
 
1375 1375
                 } // End if
1376 1376
 
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
                 if (!is_wp_error($id)) {
1416 1416
 
1417 1417
                     wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1418
-                    return $id;    // return file's url in meta fields
1418
+                    return $id; // return file's url in meta fields
1419 1419
                 } // End if
1420 1420
             } // End foreach
1421 1421
         }
@@ -1430,9 +1430,9 @@  discard block
 block discarded – undo
1430 1430
         {
1431 1431
 
1432 1432
             // Default values for meta box
1433
-            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box);
1433
+            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array) $this->_meta_box);
1434 1434
 
1435
-            if(is_array($this->_fields)) {
1435
+            if (is_array($this->_fields)) {
1436 1436
                 // Default values for fields
1437 1437
                 foreach ($this->_fields as &$field) {
1438 1438
                     $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image'));
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
          */
1453 1453
         public function has_field($type)
1454 1454
         {
1455
-            if(is_array($this->_fields)) {
1455
+            if (is_array($this->_fields)) {
1456 1456
                 foreach ($this->_fields as $field) {
1457 1457
                     if ($type == $field['type'])
1458 1458
                         return true;
@@ -2020,12 +2020,12 @@  discard block
 block discarded – undo
2020 2020
                 $post_type = $taxObject->object_type[0];
2021 2021
             }
2022 2022
 
2023
-            if($post_type=='post'){$post_type='';}
2024
-            if($post_type){$post_type = $post_type.'_';}
2023
+            if ($post_type == 'post') {$post_type = ''; }
2024
+            if ($post_type) {$post_type = $post_type . '_'; }
2025 2025
 
2026 2026
             $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2027 2027
 
2028
-            $m = get_option('tax_meta_' . $post_type  . $t_id);
2028
+            $m = get_option('tax_meta_' . $post_type . $t_id);
2029 2029
             if (isset($m[$key])) {
2030 2030
                 return $m[$key];
2031 2031
             } else {
@@ -2042,15 +2042,15 @@  discard block
 block discarded – undo
2042 2042
                 $post_type = $taxObject->object_type[0];
2043 2043
             }
2044 2044
 
2045
-            if($post_type=='post'){$post_type='';}
2046
-            if($post_type){$post_type = $post_type.'_';}
2045
+            if ($post_type == 'post') {$post_type = ''; }
2046
+            if ($post_type) {$post_type = $post_type . '_'; }
2047 2047
 
2048
-            $m = get_option('tax_meta_' . $post_type  . $term_id);
2048
+            $m = get_option('tax_meta_' . $post_type . $term_id);
2049 2049
 
2050 2050
             if (isset($m[$key])) {
2051 2051
                 unset($m[$key]);
2052 2052
             }
2053
-            update_option('tax_meta_' . $post_type  . $term_id, $m);
2053
+            update_option('tax_meta_' . $post_type . $term_id, $m);
2054 2054
         }
2055 2055
 
2056 2056
         //update meta
@@ -2062,13 +2062,13 @@  discard block
 block discarded – undo
2062 2062
                 $post_type = $taxObject->object_type[0];
2063 2063
             }
2064 2064
 
2065
-            if($post_type=='post'){$post_type='';}
2066
-            if($post_type){$post_type = $post_type.'_';}
2065
+            if ($post_type == 'post') {$post_type = ''; }
2066
+            if ($post_type) {$post_type = $post_type . '_'; }
2067 2067
 
2068
-            $m = get_option('tax_meta_' . $post_type  . $term_id);
2068
+            $m = get_option('tax_meta_' . $post_type . $term_id);
2069 2069
 
2070 2070
             $m[$key] = $value;
2071
-            update_option('tax_meta_' . $post_type  . $term_id, $m);
2071
+            update_option('tax_meta_' . $post_type . $term_id, $m);
2072 2072
 
2073 2073
             /**
2074 2074
              * Called after the tax meta is updated.
@@ -2103,12 +2103,12 @@  discard block
 block discarded – undo
2103 2103
             $post_type = $taxObject->object_type[0];
2104 2104
         }
2105 2105
 
2106
-        if($post_type=='post'){$post_type='';}
2107
-        if($post_type){$post_type = $post_type.'_';}
2106
+        if ($post_type == 'post') {$post_type = ''; }
2107
+        if ($post_type) {$post_type = $post_type . '_'; }
2108 2108
 
2109 2109
         $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2110 2110
 
2111
-        $m = get_option('tax_meta_' . $post_type  . $t_id);
2111
+        $m = get_option('tax_meta_' . $post_type . $t_id);
2112 2112
         if (isset($m[$key])) {
2113 2113
             return $m[$key];
2114 2114
         } else {
@@ -2125,15 +2125,15 @@  discard block
 block discarded – undo
2125 2125
         $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2126 2126
         $post_type = $taxObject->object_type[0];
2127 2127
 
2128
-        if($post_type=='post'){$post_type='';}
2129
-        if($post_type){$post_type = $post_type.'_';}
2128
+        if ($post_type == 'post') {$post_type = ''; }
2129
+        if ($post_type) {$post_type = $post_type . '_'; }
2130 2130
 
2131 2131
         $m = get_option('tax_meta_' . $post_type . $term_id);
2132 2132
 
2133 2133
         if (isset($m[$key])) {
2134 2134
             unset($m[$key]);
2135 2135
         }
2136
-        update_option('tax_meta_' . $post_type  . $term_id, $m);
2136
+        update_option('tax_meta_' . $post_type . $term_id, $m);
2137 2137
     }
2138 2138
 }
2139 2139
 
@@ -2147,10 +2147,10 @@  discard block
 block discarded – undo
2147 2147
             $post_type = $taxObject->object_type[0];
2148 2148
         }
2149 2149
 
2150
-        if($post_type=='post'){$post_type='';}
2151
-        if($post_type){$post_type = $post_type.'_';}
2150
+        if ($post_type == 'post') {$post_type = ''; }
2151
+        if ($post_type) {$post_type = $post_type . '_'; }
2152 2152
 
2153
-        $m = get_option('tax_meta_' . $post_type  . $term_id);
2153
+        $m = get_option('tax_meta_' . $post_type . $term_id);
2154 2154
 
2155 2155
         $m[$key] = $value;
2156 2156
         update_option('tax_meta_' . $post_type . $term_id, $m);
Please login to merge, or discard this patch.
Indentation   +2028 added lines, -2028 removed lines patch added patch discarded remove patch
@@ -28,260 +28,260 @@  discard block
 block discarded – undo
28 28
 
29 29
 if (!class_exists('Tax_Meta_Class')) :
30 30
 
31
-    /**
32
-     * All Types Meta Box class.
33
-     *
34
-     * @package All Types Meta Box
35
-     * @since 1.0
36
-     *
37
-     * @todo Nothing.
38
-     */
39
-
40
-
41
-    class Tax_Meta_Class
42
-    {
43
-
44
-        /**
45
-         * Holds meta box object
46
-         *
47
-         * @var object
48
-         * @access protected
49
-         */
50
-        protected $_meta_box;
51
-
52
-        /**
53
-         * Holds meta box fields.
54
-         *
55
-         * @var array
56
-         * @access protected
57
-         */
58
-        protected $_prefix;
59
-
60
-        /**
61
-         * Holds Prefix for meta box fields.
62
-         *
63
-         * @var array
64
-         * @access protected
65
-         */
66
-        protected $_fields;
67
-
68
-        /**
69
-         * Use local images.
70
-         *
71
-         * @var bool
72
-         * @access protected
73
-         */
74
-        protected $_Local_images;
75
-
76
-        /**
77
-         * What form is this? edit or new term.
78
-         *
79
-         * @var string
80
-         * @access protected
81
-         * $since 1.0
82
-         */
83
-        protected $_form_type;
84
-        /**
85
-         * SelfPath to allow themes as well as plugins.
86
-         *
87
-         * @var string
88
-         * @access protected
89
-         * $since 1.0
90
-         */
91
-        protected $SelfPath;
92
-
93
-        /**
94
-         * Constructor
95
-         *
96
-         * @since 1.0
97
-         * @access public
98
-         *
99
-         * @param array $meta_box
100
-         */
101
-        public function __construct($meta_box)
102
-        {
103
-
104
-            // If we are not in admin area exit.
105
-            if (!is_admin())
106
-                return;
107
-
108
-            // Assign meta box values to local variables and add it's missed values.
109
-            $this->_meta_box = $meta_box;
110
-            $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : '';
111
-            $this->_fields = &$this->_meta_box['fields'];
112
-            $this->_Local_images = (isset($meta_box['local_images'])) ? true : false;
113
-            $this->add_missed_values();
114
-            if (isset($meta_box['use_with_theme']))
115
-                if ($meta_box['use_with_theme'] === true) {
116
-                    $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
117
-                } elseif ($meta_box['use_with_theme'] === false) {
118
-                    $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119
-                } else {
120
-                    $this->SelfPath = $meta_box['use_with_theme'];
121
-                }
122
-            else {
123
-                $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
124
-            }
125
-
126
-
127
-            // Add Actions
128
-            add_action('admin_init', array(&$this, 'add'));
129
-
130
-            // Check for special fields and add needed actions for them.
131
-            $this->check_field_upload();
132
-            $this->check_field_color();
133
-            $this->check_field_date();
134
-            $this->check_field_time();
135
-
136
-            // Load common js, css files
137
-            // Must enqueue for all pages as we need js for the media upload, too.
138
-            add_action('admin_print_styles', array(&$this, 'load_scripts_styles'));
139
-
140
-        }
141
-
142
-        /**
143
-         * Load all Javascript and CSS
144
-         *
145
-         * @since 1.0
146
-         * @access public
147
-         */
148
-        public function load_scripts_styles()
149
-        {
150
-
151
-            // Get Plugin Path
152
-            $plugin_path = $this->SelfPath;
153
-            //only load styles and js when needed
154
-            /* 
31
+	/**
32
+	 * All Types Meta Box class.
33
+	 *
34
+	 * @package All Types Meta Box
35
+	 * @since 1.0
36
+	 *
37
+	 * @todo Nothing.
38
+	 */
39
+
40
+
41
+	class Tax_Meta_Class
42
+	{
43
+
44
+		/**
45
+		 * Holds meta box object
46
+		 *
47
+		 * @var object
48
+		 * @access protected
49
+		 */
50
+		protected $_meta_box;
51
+
52
+		/**
53
+		 * Holds meta box fields.
54
+		 *
55
+		 * @var array
56
+		 * @access protected
57
+		 */
58
+		protected $_prefix;
59
+
60
+		/**
61
+		 * Holds Prefix for meta box fields.
62
+		 *
63
+		 * @var array
64
+		 * @access protected
65
+		 */
66
+		protected $_fields;
67
+
68
+		/**
69
+		 * Use local images.
70
+		 *
71
+		 * @var bool
72
+		 * @access protected
73
+		 */
74
+		protected $_Local_images;
75
+
76
+		/**
77
+		 * What form is this? edit or new term.
78
+		 *
79
+		 * @var string
80
+		 * @access protected
81
+		 * $since 1.0
82
+		 */
83
+		protected $_form_type;
84
+		/**
85
+		 * SelfPath to allow themes as well as plugins.
86
+		 *
87
+		 * @var string
88
+		 * @access protected
89
+		 * $since 1.0
90
+		 */
91
+		protected $SelfPath;
92
+
93
+		/**
94
+		 * Constructor
95
+		 *
96
+		 * @since 1.0
97
+		 * @access public
98
+		 *
99
+		 * @param array $meta_box
100
+		 */
101
+		public function __construct($meta_box)
102
+		{
103
+
104
+			// If we are not in admin area exit.
105
+			if (!is_admin())
106
+				return;
107
+
108
+			// Assign meta box values to local variables and add it's missed values.
109
+			$this->_meta_box = $meta_box;
110
+			$this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : '';
111
+			$this->_fields = &$this->_meta_box['fields'];
112
+			$this->_Local_images = (isset($meta_box['local_images'])) ? true : false;
113
+			$this->add_missed_values();
114
+			if (isset($meta_box['use_with_theme']))
115
+				if ($meta_box['use_with_theme'] === true) {
116
+					$this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
117
+				} elseif ($meta_box['use_with_theme'] === false) {
118
+					$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119
+				} else {
120
+					$this->SelfPath = $meta_box['use_with_theme'];
121
+				}
122
+			else {
123
+				$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
124
+			}
125
+
126
+
127
+			// Add Actions
128
+			add_action('admin_init', array(&$this, 'add'));
129
+
130
+			// Check for special fields and add needed actions for them.
131
+			$this->check_field_upload();
132
+			$this->check_field_color();
133
+			$this->check_field_date();
134
+			$this->check_field_time();
135
+
136
+			// Load common js, css files
137
+			// Must enqueue for all pages as we need js for the media upload, too.
138
+			add_action('admin_print_styles', array(&$this, 'load_scripts_styles'));
139
+
140
+		}
141
+
142
+		/**
143
+		 * Load all Javascript and CSS
144
+		 *
145
+		 * @since 1.0
146
+		 * @access public
147
+		 */
148
+		public function load_scripts_styles()
149
+		{
150
+
151
+			// Get Plugin Path
152
+			$plugin_path = $this->SelfPath;
153
+			//only load styles and js when needed
154
+			/* 
155 155
 		 * since 1.0
156 156
 		 */
157
-            $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : '';
158
-
159
-            if (!empty($this->_meta_box['pages'])) {
160
-                if (in_array($taxnow, $this->_meta_box['pages'])) {
161
-                    // Enqueue Meta Box Style
162
-                    //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );
163
-                    // Enqueue Meta Box Scripts
164
-                    //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
165
-
166
-                }
167
-            }
168
-
169
-        }
170
-
171
-        /**
172
-         * Check the Field Upload, Add needed Actions
173
-         *
174
-         * @since 1.0
175
-         * @access public
176
-         */
177
-        public function enqueue_tax_meta_scripts()
178
-        {
179
-            // Make upload feature work event when custom post type doesn't support 'editor'
180
-            wp_enqueue_script('media-upload');
181
-            wp_enqueue_script('thickbox');
182
-            add_thickbox();
183
-            wp_enqueue_script('jquery-ui-core');
184
-            wp_enqueue_script('jquery-ui-sortable');
185
-
186
-
187
-        }
188
-
189
-        public function check_field_upload()
190
-        {
191
-
192
-            // Check if the field is an image or file. If not, return.
193
-            if (!$this->has_field('image') && !$this->has_field('file'))
194
-                return;
195
-
196
-
197
-            add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100);
198
-
199
-            // Add data encoding type for file uploading.	
200
-            add_action('post_edit_form_tag', array(&$this, 'add_enctype'));
201
-
202
-
203
-            // Add filters for media upload.
204
-            add_filter('media_upload_gallery', array(&$this, 'insert_images'));
205
-            add_filter('media_upload_library', array(&$this, 'insert_images'));
206
-            add_filter('media_upload_image', array(&$this, 'insert_images'));
207
-
208
-            // Delete all attachments when delete custom post type.
209
-            add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file'));
210
-            add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images'));
211
-            // Delete file via Ajax
212
-            add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image'));
213
-        }
214
-
215
-        /**
216
-         * Add data encoding type for file uploading
217
-         *
218
-         * @since 1.0
219
-         * @access public
220
-         */
221
-        public function add_enctype()
222
-        {
223
-            echo ' enctype="multipart/form-data"';
224
-        }
225
-
226
-        /**
227
-         * Process images added to meta field.
228
-         *
229
-         * Modified from Faster Image Insert plugin.
230
-         *
231
-         * @return void
232
-         * @author Cory Crowley
233
-         */
234
-        public function insert_images()
235
-        {
236
-
237
-            // If post variables are empty, return.
238
-            if (!isset($_POST['at-insert']) || empty($_POST['attachments']))
239
-                return;
240
-
241
-            // Security Check
242
-            check_admin_referer('media-form');
243
-
244
-            // Create Security Nonce
245
-            $nonce = wp_create_nonce('at_ajax_delete');
246
-
247
-            // Get Post Id and Field Id
248
-            $term_id = $_POST['post_id'];
249
-            $id = $_POST['field_id'];
250
-
251
-            // Modify the insertion string
252
-            $html = '';
253
-            foreach ($_POST['attachments'] as $attachment_id => $attachment) {
254
-
255
-                // Strip Slashes
256
-                $attachment = stripslashes_deep($attachment);
257
-
258
-                // If not selected or url is empty, continue in loop.
259
-                if (empty($attachment['selected']) || empty($attachment['url']))
260
-                    continue;
261
-
262
-                $li = "<li id='item_{$attachment_id}'>";
263
-                $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
264
-                //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>";
265
-                $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>";
266
-                $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
267
-                $li .= "</li>";
268
-                $html .= $li;
269
-
270
-            } // End For Each
271
-
272
-            return media_send_to_editor($html);
273
-
274
-        }
275
-
276
-        /**
277
-         * Delete attachments associated with the post.
278
-         *
279
-         * @since 1.0
280
-         * @access public
281
-         *
282
-         * @param int|string $term_id The term ID.
283
-         */
284
-        /*public function delete_attachments( $term_id ) {
157
+			$taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : '';
158
+
159
+			if (!empty($this->_meta_box['pages'])) {
160
+				if (in_array($taxnow, $this->_meta_box['pages'])) {
161
+					// Enqueue Meta Box Style
162
+					//wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );
163
+					// Enqueue Meta Box Scripts
164
+					//wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
165
+
166
+				}
167
+			}
168
+
169
+		}
170
+
171
+		/**
172
+		 * Check the Field Upload, Add needed Actions
173
+		 *
174
+		 * @since 1.0
175
+		 * @access public
176
+		 */
177
+		public function enqueue_tax_meta_scripts()
178
+		{
179
+			// Make upload feature work event when custom post type doesn't support 'editor'
180
+			wp_enqueue_script('media-upload');
181
+			wp_enqueue_script('thickbox');
182
+			add_thickbox();
183
+			wp_enqueue_script('jquery-ui-core');
184
+			wp_enqueue_script('jquery-ui-sortable');
185
+
186
+
187
+		}
188
+
189
+		public function check_field_upload()
190
+		{
191
+
192
+			// Check if the field is an image or file. If not, return.
193
+			if (!$this->has_field('image') && !$this->has_field('file'))
194
+				return;
195
+
196
+
197
+			add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100);
198
+
199
+			// Add data encoding type for file uploading.	
200
+			add_action('post_edit_form_tag', array(&$this, 'add_enctype'));
201
+
202
+
203
+			// Add filters for media upload.
204
+			add_filter('media_upload_gallery', array(&$this, 'insert_images'));
205
+			add_filter('media_upload_library', array(&$this, 'insert_images'));
206
+			add_filter('media_upload_image', array(&$this, 'insert_images'));
207
+
208
+			// Delete all attachments when delete custom post type.
209
+			add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file'));
210
+			add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images'));
211
+			// Delete file via Ajax
212
+			add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image'));
213
+		}
214
+
215
+		/**
216
+		 * Add data encoding type for file uploading
217
+		 *
218
+		 * @since 1.0
219
+		 * @access public
220
+		 */
221
+		public function add_enctype()
222
+		{
223
+			echo ' enctype="multipart/form-data"';
224
+		}
225
+
226
+		/**
227
+		 * Process images added to meta field.
228
+		 *
229
+		 * Modified from Faster Image Insert plugin.
230
+		 *
231
+		 * @return void
232
+		 * @author Cory Crowley
233
+		 */
234
+		public function insert_images()
235
+		{
236
+
237
+			// If post variables are empty, return.
238
+			if (!isset($_POST['at-insert']) || empty($_POST['attachments']))
239
+				return;
240
+
241
+			// Security Check
242
+			check_admin_referer('media-form');
243
+
244
+			// Create Security Nonce
245
+			$nonce = wp_create_nonce('at_ajax_delete');
246
+
247
+			// Get Post Id and Field Id
248
+			$term_id = $_POST['post_id'];
249
+			$id = $_POST['field_id'];
250
+
251
+			// Modify the insertion string
252
+			$html = '';
253
+			foreach ($_POST['attachments'] as $attachment_id => $attachment) {
254
+
255
+				// Strip Slashes
256
+				$attachment = stripslashes_deep($attachment);
257
+
258
+				// If not selected or url is empty, continue in loop.
259
+				if (empty($attachment['selected']) || empty($attachment['url']))
260
+					continue;
261
+
262
+				$li = "<li id='item_{$attachment_id}'>";
263
+				$li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
264
+				//$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>";
265
+				$li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>";
266
+				$li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
267
+				$li .= "</li>";
268
+				$html .= $li;
269
+
270
+			} // End For Each
271
+
272
+			return media_send_to_editor($html);
273
+
274
+		}
275
+
276
+		/**
277
+		 * Delete attachments associated with the post.
278
+		 *
279
+		 * @since 1.0
280
+		 * @access public
281
+		 *
282
+		 * @param int|string $term_id The term ID.
283
+		 */
284
+		/*public function delete_attachments( $term_id ) {
285 285
 		
286 286
 		// Get Attachments
287 287
 		$attachments = get_posts( array( 'numberposts' => -1, 'post_type' => 'attachment', 'post_parent' => $term_id ) );
@@ -295,349 +295,349 @@  discard block
 block discarded – undo
295 295
 		
296 296
 	}*/
297 297
 
298
-        /**
299
-         * Ajax callback for deleting files.
300
-         *
301
-         * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H )
302
-         *
303
-         * @since 1.0
304
-         * @access public
305
-         */
306
-        public function delete_file()
307
-        {
308
-
309
-
310
-            // If data is not set, die.
311
-            if (!isset($_POST['data']))
312
-                die();
313
-
314
-            list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']);
315
-
316
-            if (!wp_verify_nonce($nonce, 'at_ajax_delete'))
317
-                die('1');
318
-
319
-            $this->delete_tax_meta($term_id, $key, $attach_id);
320
-
321
-            die('0');
322
-
323
-        }
324
-
325
-        /**
326
-         * Ajax callback for deleting files.
327
-         * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq)
328
-         * @since 1.0
329
-         * @access public
330
-         */
331
-        public function wp_ajax_delete_image()
332
-        {
333
-            $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0;
334
-            $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0;
335
-            $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0;
336
-            $ok = false;
337
-            if (strpos($field_id, '[') === false) {
338
-                check_admin_referer("at-delete-mupload_" . urldecode($field_id));
339
-                if ($term_id > 0)
340
-                    $this->delete_tax_meta($term_id, $field_id);
341
-                //$ok = wp_delete_attachment( $attachment_id );
342
-                $ok = 1;
343
-            } else {
344
-                $f = explode('[', urldecode($field_id));
345
-                $f_fiexed = array();
346
-                foreach ($f as $k => $v) {
347
-                    $f[$k] = str_replace(']', '', $v);
348
-                }
349
-                $saved = $this->get_tax_meta($term_id, $f[0], true);
350
-                if (isset($saved[$f[1]][$f[2]])) {
351
-                    unset($saved[$f[1]][$f[2]]);
352
-                    if ($term_id > 0)
353
-                        update_post_meta($term_id, $f[0], $saved);
354
-                    //$ok = wp_delete_attachment( $attachment_id );
355
-                    $ok = 1;
356
-                }
357
-            }
358
-
359
-
360
-            if ($ok) {
361
-                echo json_encode(array('status' => 'success'));
362
-                die();
363
-            } else {
364
-                echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory')));
365
-                die();
366
-            }
367
-        }
368
-
369
-        /**
370
-         * Ajax callback for reordering Images.
371
-         *
372
-         * @since 1.0
373
-         * @access public
374
-         */
375
-        public function reorder_images()
376
-        {
377
-
378
-            if (!isset($_POST['data']))
379
-                die();
380
-
381
-            list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']);
382
-
383
-            if (!wp_verify_nonce($nonce, 'at_ajax_reorder'))
384
-                die('1');
385
-
386
-            parse_str($order, $items);
387
-            $items = $items['item'];
388
-            $order = 1;
389
-            foreach ($items as $item) {
390
-                wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order));
391
-                $order++;
392
-            }
393
-
394
-            die('0');
395
-
396
-        }
397
-
398
-        /**
399
-         * Check Field Color
400
-         *
401
-         * @since 1.0
402
-         * @access public
403
-         */
404
-        public function check_field_color()
405
-        {
406
-
407
-            if ($this->has_field('color') && $this->is_edit_page()) {
408
-                // Enqueu built-in script and style for color picker.
409
-                wp_enqueue_style('farbtastic');
410
-                wp_enqueue_script('farbtastic');
411
-            }
412
-
413
-        }
414
-
415
-        /**
416
-         * Check Field Date
417
-         *
418
-         * @since 1.0
419
-         * @access public
420
-         */
421
-        public function check_field_date()
422
-        {
423
-
424
-            if ($this->has_field('date') && $this->is_edit_page()) {
425
-                // Enqueu JQuery UI, use proper version.
426
-                wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css');
427
-                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'));
428
-            }
429
-
430
-        }
431
-
432
-        /**
433
-         * Check Field Time
434
-         *
435
-         * @since 1.0
436
-         * @access public
437
-         */
438
-        public function check_field_time()
439
-        {
440
-
441
-            if ($this->has_field('time') && $this->is_edit_page()) {
442
-
443
-                // Enqueu JQuery UI, use proper version.
444
-                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true);
445
-                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true);
446
-                wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true);
447
-
448
-            }
449
-
450
-        }
451
-
452
-        /**
453
-         * Add Meta Box for multiple post types.
454
-         *
455
-         * @since 1.0
456
-         * @access public
457
-         */
458
-        public function add()
459
-        {
460
-
461
-            // Loop through array
462
-            if (!empty($this->_meta_box['pages'])) {
463
-                foreach ($this->_meta_box['pages'] as $page) {
464
-                    //add fields to edit form
465
-                    add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form'));
466
-                    //add fields to add new form
467
-                    add_action($page . '_add_form_fields', array(&$this, 'show_new_form'));
468
-                    // this saves the edit fields
469
-                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2);
470
-                    // this saves the add fields
471
-                    add_action('created_' . $page, array(&$this, 'save'), 10, 2);
472
-                }
473
-            }
474
-
475
-        }
476
-
477
-        /**
478
-         * Callback function to show fields on add new taxonomy term form.
479
-         *
480
-         * @since 1.0
481
-         * @access public
482
-         */
483
-        public function show_new_form($term_id)
484
-        {
485
-            $this->_form_type = 'new';
486
-            $this->show($term_id);
487
-        }
488
-
489
-        /**
490
-         * Callback function to show fields on term edit form.
491
-         *
492
-         * @since 1.0
493
-         * @access public
494
-         */
495
-        public function show_edit_form($term_id)
496
-        {
497
-            $this->_form_type = 'edit';
498
-            $this->show($term_id);
499
-        }
500
-
501
-
502
-        /**
503
-         * Callback function to show fields in meta box.
504
-         *
505
-         * @since 1.0
506
-         * @access public
507
-         */
508
-        public function show($term_id)
509
-        {
510
-
511
-            wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce');
512
-
513
-            foreach ($this->_fields as $field) {
514
-                $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']);
515
-                $meta = ($meta !== '') ? $meta : $field['std'];
516
-                if ('image' != $field['type'] && $field['type'] != 'repeater')
517
-                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
518
-
519
-                if ($field['validate_func']) {
520
-                    echo '<tr class="form-field form-required ' . $field['style'] . '">';
521
-                } else {
522
-                    echo '<tr class="form-field ' . $field['style'] . '">';
523
-                }
524
-
525
-                // Call Separated methods for displaying each type of field.
526
-                call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta);
527
-                echo '</tr>';
528
-            }
529
-            echo '</table>';
530
-        }
531
-
532
-        /**
533
-         * Show Repeater Fields.
534
-         *
535
-         * @param string $field
536
-         * @param string $meta
537
-         * @since 1.0
538
-         * @access public
539
-         */
540
-        public function show_field_repeater($field, $meta)
541
-        {
542
-            // Get Plugin Path
543
-            $plugin_path = $this->SelfPath;
544
-            $this->show_field_begin($field, $meta);
545
-            echo "<div class='at-repeat' id='{$field['id']}'>";
546
-
547
-            $c = 0;
548
-
549
-            if (count($meta) > 0 && is_array($meta)) {
550
-                foreach ($meta as $me) {
551
-                    //for labling toggles
552
-                    $mmm = $me[$field['fields'][0]['id']];
553
-                    echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">';
554
-                    if ($field['inline']) {
555
-                        echo '<tr class="at-inline" VALIGN="top">';
556
-                    }
557
-                    foreach ($field['fields'] as $f) {
558
-                        //reset var $id for repeater
559
-                        $id = '';
560
-                        $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
561
-                        $m = $me[$f['id']];
562
-                        $m = ($m !== '') ? $m : $f['std'];
563
-                        if ('image' != $f['type'] && $f['type'] != 'repeater')
564
-                            $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
565
-                        //set new id for field in array format
566
-                        $f['id'] = $id;
567
-                        if (!$field['inline']) {
568
-                            echo '<tr>';
569
-                        }
570
-                        call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m);
571
-                        if (!$field['inline']) {
572
-                            echo '</tr>';
573
-                        }
574
-                    }
575
-                    if ($field['inline']) {
576
-                        echo '</tr>';
577
-                    }
578
-                    echo '</table>
298
+		/**
299
+		 * Ajax callback for deleting files.
300
+		 *
301
+		 * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H )
302
+		 *
303
+		 * @since 1.0
304
+		 * @access public
305
+		 */
306
+		public function delete_file()
307
+		{
308
+
309
+
310
+			// If data is not set, die.
311
+			if (!isset($_POST['data']))
312
+				die();
313
+
314
+			list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']);
315
+
316
+			if (!wp_verify_nonce($nonce, 'at_ajax_delete'))
317
+				die('1');
318
+
319
+			$this->delete_tax_meta($term_id, $key, $attach_id);
320
+
321
+			die('0');
322
+
323
+		}
324
+
325
+		/**
326
+		 * Ajax callback for deleting files.
327
+		 * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq)
328
+		 * @since 1.0
329
+		 * @access public
330
+		 */
331
+		public function wp_ajax_delete_image()
332
+		{
333
+			$term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0;
334
+			$field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0;
335
+			$attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0;
336
+			$ok = false;
337
+			if (strpos($field_id, '[') === false) {
338
+				check_admin_referer("at-delete-mupload_" . urldecode($field_id));
339
+				if ($term_id > 0)
340
+					$this->delete_tax_meta($term_id, $field_id);
341
+				//$ok = wp_delete_attachment( $attachment_id );
342
+				$ok = 1;
343
+			} else {
344
+				$f = explode('[', urldecode($field_id));
345
+				$f_fiexed = array();
346
+				foreach ($f as $k => $v) {
347
+					$f[$k] = str_replace(']', '', $v);
348
+				}
349
+				$saved = $this->get_tax_meta($term_id, $f[0], true);
350
+				if (isset($saved[$f[1]][$f[2]])) {
351
+					unset($saved[$f[1]][$f[2]]);
352
+					if ($term_id > 0)
353
+						update_post_meta($term_id, $f[0], $saved);
354
+					//$ok = wp_delete_attachment( $attachment_id );
355
+					$ok = 1;
356
+				}
357
+			}
358
+
359
+
360
+			if ($ok) {
361
+				echo json_encode(array('status' => 'success'));
362
+				die();
363
+			} else {
364
+				echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory')));
365
+				die();
366
+			}
367
+		}
368
+
369
+		/**
370
+		 * Ajax callback for reordering Images.
371
+		 *
372
+		 * @since 1.0
373
+		 * @access public
374
+		 */
375
+		public function reorder_images()
376
+		{
377
+
378
+			if (!isset($_POST['data']))
379
+				die();
380
+
381
+			list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']);
382
+
383
+			if (!wp_verify_nonce($nonce, 'at_ajax_reorder'))
384
+				die('1');
385
+
386
+			parse_str($order, $items);
387
+			$items = $items['item'];
388
+			$order = 1;
389
+			foreach ($items as $item) {
390
+				wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order));
391
+				$order++;
392
+			}
393
+
394
+			die('0');
395
+
396
+		}
397
+
398
+		/**
399
+		 * Check Field Color
400
+		 *
401
+		 * @since 1.0
402
+		 * @access public
403
+		 */
404
+		public function check_field_color()
405
+		{
406
+
407
+			if ($this->has_field('color') && $this->is_edit_page()) {
408
+				// Enqueu built-in script and style for color picker.
409
+				wp_enqueue_style('farbtastic');
410
+				wp_enqueue_script('farbtastic');
411
+			}
412
+
413
+		}
414
+
415
+		/**
416
+		 * Check Field Date
417
+		 *
418
+		 * @since 1.0
419
+		 * @access public
420
+		 */
421
+		public function check_field_date()
422
+		{
423
+
424
+			if ($this->has_field('date') && $this->is_edit_page()) {
425
+				// Enqueu JQuery UI, use proper version.
426
+				wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css');
427
+				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'));
428
+			}
429
+
430
+		}
431
+
432
+		/**
433
+		 * Check Field Time
434
+		 *
435
+		 * @since 1.0
436
+		 * @access public
437
+		 */
438
+		public function check_field_time()
439
+		{
440
+
441
+			if ($this->has_field('time') && $this->is_edit_page()) {
442
+
443
+				// Enqueu JQuery UI, use proper version.
444
+				wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true);
445
+				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true);
446
+				wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true);
447
+
448
+			}
449
+
450
+		}
451
+
452
+		/**
453
+		 * Add Meta Box for multiple post types.
454
+		 *
455
+		 * @since 1.0
456
+		 * @access public
457
+		 */
458
+		public function add()
459
+		{
460
+
461
+			// Loop through array
462
+			if (!empty($this->_meta_box['pages'])) {
463
+				foreach ($this->_meta_box['pages'] as $page) {
464
+					//add fields to edit form
465
+					add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form'));
466
+					//add fields to add new form
467
+					add_action($page . '_add_form_fields', array(&$this, 'show_new_form'));
468
+					// this saves the edit fields
469
+					add_action('edited_' . $page, array(&$this, 'save'), 10, 2);
470
+					// this saves the add fields
471
+					add_action('created_' . $page, array(&$this, 'save'), 10, 2);
472
+				}
473
+			}
474
+
475
+		}
476
+
477
+		/**
478
+		 * Callback function to show fields on add new taxonomy term form.
479
+		 *
480
+		 * @since 1.0
481
+		 * @access public
482
+		 */
483
+		public function show_new_form($term_id)
484
+		{
485
+			$this->_form_type = 'new';
486
+			$this->show($term_id);
487
+		}
488
+
489
+		/**
490
+		 * Callback function to show fields on term edit form.
491
+		 *
492
+		 * @since 1.0
493
+		 * @access public
494
+		 */
495
+		public function show_edit_form($term_id)
496
+		{
497
+			$this->_form_type = 'edit';
498
+			$this->show($term_id);
499
+		}
500
+
501
+
502
+		/**
503
+		 * Callback function to show fields in meta box.
504
+		 *
505
+		 * @since 1.0
506
+		 * @access public
507
+		 */
508
+		public function show($term_id)
509
+		{
510
+
511
+			wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce');
512
+
513
+			foreach ($this->_fields as $field) {
514
+				$meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']);
515
+				$meta = ($meta !== '') ? $meta : $field['std'];
516
+				if ('image' != $field['type'] && $field['type'] != 'repeater')
517
+					$meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
518
+
519
+				if ($field['validate_func']) {
520
+					echo '<tr class="form-field form-required ' . $field['style'] . '">';
521
+				} else {
522
+					echo '<tr class="form-field ' . $field['style'] . '">';
523
+				}
524
+
525
+				// Call Separated methods for displaying each type of field.
526
+				call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta);
527
+				echo '</tr>';
528
+			}
529
+			echo '</table>';
530
+		}
531
+
532
+		/**
533
+		 * Show Repeater Fields.
534
+		 *
535
+		 * @param string $field
536
+		 * @param string $meta
537
+		 * @since 1.0
538
+		 * @access public
539
+		 */
540
+		public function show_field_repeater($field, $meta)
541
+		{
542
+			// Get Plugin Path
543
+			$plugin_path = $this->SelfPath;
544
+			$this->show_field_begin($field, $meta);
545
+			echo "<div class='at-repeat' id='{$field['id']}'>";
546
+
547
+			$c = 0;
548
+
549
+			if (count($meta) > 0 && is_array($meta)) {
550
+				foreach ($meta as $me) {
551
+					//for labling toggles
552
+					$mmm = $me[$field['fields'][0]['id']];
553
+					echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">';
554
+					if ($field['inline']) {
555
+						echo '<tr class="at-inline" VALIGN="top">';
556
+					}
557
+					foreach ($field['fields'] as $f) {
558
+						//reset var $id for repeater
559
+						$id = '';
560
+						$id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
561
+						$m = $me[$f['id']];
562
+						$m = ($m !== '') ? $m : $f['std'];
563
+						if ('image' != $f['type'] && $f['type'] != 'repeater')
564
+							$m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
565
+						//set new id for field in array format
566
+						$f['id'] = $id;
567
+						if (!$field['inline']) {
568
+							echo '<tr>';
569
+						}
570
+						call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m);
571
+						if (!$field['inline']) {
572
+							echo '</tr>';
573
+						}
574
+					}
575
+					if ($field['inline']) {
576
+						echo '</tr>';
577
+					}
578
+					echo '</table>
579 579
 				<span class="at-re-toggle"><img src="';
580
-                    if ($this->_Local_images) {
581
-                        echo $plugin_path . '/images/edit.png';
582
-                    } else {
583
-                        echo 'http://i.imgur.com/ka0E2.png';
584
-                    }
585
-                    echo '" alt="Edit" title="Edit"/></span> 
580
+					if ($this->_Local_images) {
581
+						echo $plugin_path . '/images/edit.png';
582
+					} else {
583
+						echo 'http://i.imgur.com/ka0E2.png';
584
+					}
585
+					echo '" alt="Edit" title="Edit"/></span> 
586 586
 				<img src="';
587
-                    if ($this->_Local_images) {
588
-                        echo $plugin_path . '/images/remove.png';
589
-                    } else {
590
-                        echo 'http://i.imgur.com/g8Duj.png';
591
-                    }
592
-                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
593
-                    $c = $c + 1;
594
-
595
-                }
596
-                $this->show_field_end($field, $meta);
597
-            }
598
-
599
-            echo '<img src="';
600
-            if ($this->_Local_images) {
601
-                echo $plugin_path . '/images/add.png';
602
-            } else {
603
-                echo 'http://i.imgur.com/w5Tuc.png';
604
-            }
605
-            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>';
606
-
607
-            //create all fields once more for js function and catch with object buffer
608
-            ob_start();
609
-            echo '<div class="at-repater-block"><table class="repeater-table">';
610
-            if ($field['inline']) {
611
-                echo '<tr class="at-inline" VALIGN="top">';
612
-            }
613
-            foreach ($field['fields'] as $f) {
614
-                //reset var $id for repeater
615
-                $id = '';
616
-                $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']';
617
-                $f['id'] = $id;
618
-                if (!$field['inline']) {
619
-                    echo '<tr>';
620
-                }
621
-                call_user_func(array(&$this, 'show_field_' . $f['type']), $f, '');
622
-                if (!$field['inline']) {
623
-                    echo '</tr>';
624
-                }
625
-            }
626
-            if ($field['inline']) {
627
-                echo '</tr>';
628
-            }
629
-            echo '</table><img src="';
630
-            if ($this->_Local_images) {
631
-                echo $plugin_path . '/images/remove.png';
632
-            } else {
633
-                echo 'http://i.imgur.com/g8Duj.png';
634
-            }
635
-            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
636
-            $counter = 'countadd_' . $field['id'];
637
-            $js_code = ob_get_clean();
638
-            $js_code = str_replace("'", "\"", $js_code);
639
-            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code);
640
-            echo '<script>
587
+					if ($this->_Local_images) {
588
+						echo $plugin_path . '/images/remove.png';
589
+					} else {
590
+						echo 'http://i.imgur.com/g8Duj.png';
591
+					}
592
+					echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
593
+					$c = $c + 1;
594
+
595
+				}
596
+				$this->show_field_end($field, $meta);
597
+			}
598
+
599
+			echo '<img src="';
600
+			if ($this->_Local_images) {
601
+				echo $plugin_path . '/images/add.png';
602
+			} else {
603
+				echo 'http://i.imgur.com/w5Tuc.png';
604
+			}
605
+			echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>';
606
+
607
+			//create all fields once more for js function and catch with object buffer
608
+			ob_start();
609
+			echo '<div class="at-repater-block"><table class="repeater-table">';
610
+			if ($field['inline']) {
611
+				echo '<tr class="at-inline" VALIGN="top">';
612
+			}
613
+			foreach ($field['fields'] as $f) {
614
+				//reset var $id for repeater
615
+				$id = '';
616
+				$id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']';
617
+				$f['id'] = $id;
618
+				if (!$field['inline']) {
619
+					echo '<tr>';
620
+				}
621
+				call_user_func(array(&$this, 'show_field_' . $f['type']), $f, '');
622
+				if (!$field['inline']) {
623
+					echo '</tr>';
624
+				}
625
+			}
626
+			if ($field['inline']) {
627
+				echo '</tr>';
628
+			}
629
+			echo '</table><img src="';
630
+			if ($this->_Local_images) {
631
+				echo $plugin_path . '/images/remove.png';
632
+			} else {
633
+				echo 'http://i.imgur.com/g8Duj.png';
634
+			}
635
+			echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
636
+			$counter = 'countadd_' . $field['id'];
637
+			$js_code = ob_get_clean();
638
+			$js_code = str_replace("'", "\"", $js_code);
639
+			$js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code);
640
+			echo '<script>
641 641
 				jQuery(document).ready(function() {
642 642
 					var ' . $counter . ' = ' . $c . ';
643 643
 					jQuery("#add-' . $field['id'] . '").live(\'click\', function() {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         			});
651 651
     			});
652 652
     		</script>';
653
-            echo '<br/><style>
653
+			echo '<br/><style>
654 654
 .at-inline{line-height: 1 !important;}
655 655
 .at-inline .at-field{border: 0px !important;}
656 656
 .at-inline .at-label{margin: 0 0 1px !important;}
@@ -658,532 +658,532 @@  discard block
 block discarded – undo
658 658
 .at-inline .at-textarea{width: 100px; height: 75px;}
659 659
 .at-repater-block{background-color: #FFFFFF;border: 1px solid;margin: 2px;}
660 660
 </style>';
661
-            $this->show_field_end($field, $meta);
662
-        }
663
-
664
-        /**
665
-         * Begin Field.
666
-         *
667
-         * @param string $field
668
-         * @param string $meta
669
-         * @since 1.0
670
-         * @access public
671
-         */
672
-        public function show_field_begin($field, $meta)
673
-        {
674
-            if (isset($field['group'])) {
675
-                if ($field['group'] == "start") {
676
-                    echo "<td class='at-field'>";
677
-                }
678
-            } else {
679
-                if ($this->_form_type == 'edit') {
680
-                    echo '<th valign="top" scope="row">';
681
-                } else {
682
-                    if ($field['validate_func']) {
683
-                        echo '<td><div class="form-field form-required">';
684
-                    } else {
685
-                        echo '<td><div class="form-field">';
686
-                    }
687
-                }
688
-            }
689
-            if ($field['name'] != '' || $field['name'] != FALSE) {
690
-                //echo "<div class='at-label'>";
691
-                echo "<label for='{$field['id']}'>{$field['name']}</label>";
692
-                //echo "</div>";
693
-            }
694
-            if ($this->_form_type == 'edit') {
695
-                echo '</th><td>';
696
-            }
697
-        }
698
-
699
-        /**
700
-         * End Field.
701
-         *
702
-         * @param string $field
703
-         * @param string $meta
704
-         * @since 1.0
705
-         * @access public
706
-         */
707
-        public function show_field_end($field, $meta = NULL, $group = false)
708
-        {
709
-            if (isset($field['group'])) {
710
-                if ($group == 'end') {
711
-                    if ($field['desc'] != '') {
712
-                        echo "<p class='desc-field'>{$field['desc']}</p></td>";
713
-                    } else {
714
-                        echo "</td>";
715
-                    }
716
-                } else {
717
-                    if ($field['desc'] != '') {
718
-                        echo "<p class='desc-field'>{$field['desc']}</p><br/>";
719
-                    } else {
720
-                        echo '<br/>';
721
-                    }
722
-                }
723
-            } else {
724
-                if ($field['desc'] != '') {
725
-                    echo "<p class='desc-field'>{$field['desc']}</p>";
726
-                }
727
-                if ($this->_form_type == 'edit') {
728
-                    echo '<td>';
729
-                } else {
730
-                    echo '<td></div>';
731
-                }
732
-            }
733
-        }
734
-
735
-        /**
736
-         * Show Field Text.
737
-         *
738
-         * @param string $field
739
-         * @param string $meta
740
-         * @since 1.0
741
-         * @access public
742
-         */
743
-        public function show_field_text($field, $meta)
744
-        {
745
-            $this->show_field_begin($field, $meta);
746
-            echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />";
747
-            $this->show_field_end($field, $meta);
748
-        }
749
-
750
-        /**
751
-         * Show Field hidden.
752
-         *
753
-         * @param string $field
754
-         * @param string|mixed $meta
755
-         * @since 0.1.3
756
-         * @access public
757
-         */
758
-        public function show_field_hidden($field, $meta)
759
-        {
760
-            //$this->show_field_begin( $field, $meta );
761
-            echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>";
762
-            //$this->show_field_end( $field, $meta );
763
-        }
764
-
765
-        /**
766
-         * Show Field Paragraph.
767
-         *
768
-         * @param string $field
769
-         * @since 0.1.3
770
-         * @access public
771
-         */
772
-        public function show_field_paragraph($field)
773
-        {
774
-            //$this->show_field_begin( $field, $meta );
775
-            echo '<p>' . $field['value'] . '</p>';
776
-            //$this->show_field_end( $field, $meta );
777
-        }
778
-
779
-        /**
780
-         * Show Field Textarea.
781
-         *
782
-         * @param string $field
783
-         * @param string $meta
784
-         * @since 1.0
785
-         * @access public
786
-         */
787
-        public function show_field_textarea($field, $meta)
788
-        {
789
-            $this->show_field_begin($field, $meta);
790
-            echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
791
-            $this->show_field_end($field, $meta);
792
-        }
793
-
794
-        /**
795
-         * Show Field Select.
796
-         *
797
-         * @param string $field
798
-         * @param string $meta
799
-         * @since 1.0
800
-         * @access public
801
-         */
802
-        public function show_field_select($field, $meta)
803
-        {
804
-
805
-            if (!is_array($meta))
806
-                $meta = (array)$meta;
807
-
808
-            $this->show_field_begin($field, $meta);
809
-            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
810
-            foreach ($field['options'] as $key => $value) {
811
-                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>";
812
-            }
813
-            echo "</select>";
814
-            $this->show_field_end($field, $meta);
815
-
816
-        }
817
-
818
-        /**
819
-         * Show Radio Field.
820
-         *
821
-         * @param string $field
822
-         * @param string $meta
823
-         * @since 1.0
824
-         * @access public
825
-         */
826
-        public function show_field_radio($field, $meta)
827
-        {
828
-
829
-            if (!is_array($meta))
830
-                $meta = (array)$meta;
831
-
832
-            $this->show_field_begin($field, $meta);
833
-            foreach ($field['options'] as $key => $value) {
834
-                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>";
835
-            }
836
-            $this->show_field_end($field, $meta);
837
-        }
838
-
839
-        /**
840
-         * Show Checkbox Field.
841
-         *
842
-         * @param string $field
843
-         * @param string $meta
844
-         * @since 1.0
845
-         * @access public
846
-         */
847
-        public function show_field_checkbox($field, $meta)
848
-        {
849
-
850
-            $this->show_field_begin($field, $meta);
851
-            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}";
852
-            $this->show_field_end($field, $meta);
853
-        }
854
-
855
-        /**
856
-         * Show Wysiwig Field.
857
-         *
858
-         * @param string $field
859
-         * @param string $meta
860
-         * @since 1.0
861
-         * @access public
862
-         */
863
-        public function show_field_wysiwyg($field, $meta)
864
-        {
865
-            $this->show_field_begin($field, $meta);
866
-            // Add TinyMCE script for WP version < 3.3
867
-            global $wp_version;
868
-
869
-            if (version_compare($wp_version, '3.2.1') < 1) {
870
-                echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
871
-            } else {
872
-                // Use new wp_editor() since WP 3.3
873
-                wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg'));
874
-            }
875
-            $this->show_field_end($field, $meta);
876
-        }
877
-
878
-        /**
879
-         * Show File Field.
880
-         *
881
-         * @global object $post The current post object.
882
-         * @param string $field
883
-         * @param string $meta
884
-         * @since 1.0
885
-         * @access public
886
-         */
887
-        public function show_field_file($field, $meta)
888
-        {
889
-
890
-            global $post;
891
-
892
-            if (!is_array($meta))
893
-                $meta = (array)$meta;
894
-
895
-            $this->show_field_begin($field, $meta);
896
-            echo "{$field['desc']}<br />";
897
-
898
-            if (!empty($meta)) {
899
-                $nonce = wp_create_nonce('at_ajax_delete');
900
-                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>';
901
-                echo '<ol class="at-upload">';
902
-                foreach ($meta as $att) {
903
-                    // if (wp_attachment_is_image($att)) continue; // what's image uploader for?
904
-                    echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>";
905
-                }
906
-                echo '</ol>';
907
-            }
908
-
909
-            // show form upload
910
-
911
-            echo "<div class='at-file-upload-label'>";
912
-            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>";
913
-            echo "</div>";
914
-            echo "<div class='new-files'>";
915
-            echo "<div class='file-input'>";
916
-            echo "<input type='file' name='{$field['id']}[]' />";
917
-            echo "</div><!-- End .file-input -->";
918
-            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>";
919
-            echo "</div><!-- End .new-files -->";
920
-            echo "</td>";
921
-            $this->show_field_end($field, $meta);
922
-        }
923
-
924
-        /**
925
-         * Show Image Field.
926
-         *
927
-         * @param array $field
928
-         * @param array $meta
929
-         * @since 1.0
930
-         * @access public
931
-         */
932
-        public function show_field_image($field, $meta)
933
-        {
934
-            $this->show_field_begin($field, $meta);
935
-            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
936
-            if (is_array($meta)) {
937
-                if (isset($meta[0]) && is_array($meta[0]))
938
-                    $meta = $meta[0];
939
-            }
940
-
941
-            $uploads = wp_upload_dir();
942
-            if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') {
943
-
944
-                $file_info = pathinfo($meta['src']);
945
-
946
-                //print_r($meta);
947
-                //print_r($uploads);
948
-                //print_r($file_info);
949
-
950
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
951
-                    $sub_dir = $file_info['dirname'];
952
-
953
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs	
954
-                $uploads_baseurl = $uploads['baseurl'];
955
-                $uploads_path = $uploads['path'];
956
-
957
-                $file_name = $file_info['basename'];
958
-
959
-                $sub_dir = str_replace($uploads_baseurl, '', $sub_dir);
960
-
961
-                $uploads_url = $uploads_baseurl . $sub_dir;
962
-
963
-                $meta['src'] = $uploads_url . '/' . $file_name;
964
-
965
-
966
-                $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>";
967
-                $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />";
968
-                $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />";
969
-                $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />";
970
-            } else {
971
-                $html .= "<span class='mupload_img_holder'></span>";
972
-                $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />";
973
-                $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />";
974
-                $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />";
975
-            }
976
-            echo $html;
977
-            $this->show_field_end($field, $meta);
978
-        }
979
-
980
-        /**
981
-         * Show Color Field.
982
-         *
983
-         * @param string $field
984
-         * @param string $meta
985
-         * @since 1.0
986
-         * @access public
987
-         */
988
-        public function show_field_color($field, $meta)
989
-        {
990
-
991
-            if (empty($meta))
992
-                $meta = '#';
993
-
994
-            $this->show_field_begin($field, $meta);
995
-
996
-            echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />";
997
-            //	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>";
998
-            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>";
999
-            echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>";
1000
-            $this->show_field_end($field, $meta);
1001
-
1002
-        }
1003
-
1004
-        /**
1005
-         * Show Checkbox List Field
1006
-         *
1007
-         * @param string $field
1008
-         * @param string $meta
1009
-         * @since 1.0
1010
-         * @access public
1011
-         */
1012
-        public function show_field_checkbox_list($field, $meta)
1013
-        {
1014
-
1015
-            if (!is_array($meta))
1016
-                $meta = (array)$meta;
1017
-
1018
-            $this->show_field_begin($field, $meta);
1019
-
1020
-            $html = array();
1021
-
1022
-            foreach ($field['options'] as $key => $value) {
1023
-                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}";
1024
-            }
1025
-
1026
-            echo implode('<br />', $html);
1027
-
1028
-            $this->show_field_end($field, $meta);
1029
-
1030
-        }
1031
-
1032
-        /**
1033
-         * Show Date Field.
1034
-         *
1035
-         * @param string $field
1036
-         * @param string $meta
1037
-         * @since 1.0
1038
-         * @access public
1039
-         */
1040
-        public function show_field_date($field, $meta)
1041
-        {
1042
-            $this->show_field_begin($field, $meta);
1043
-            echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1044
-            $this->show_field_end($field, $meta);
1045
-        }
1046
-
1047
-        /**
1048
-         * Show time field.
1049
-         *
1050
-         * @param string $field
1051
-         * @param string $meta
1052
-         * @since 1.0
1053
-         * @access public
1054
-         */
1055
-        public function show_field_time($field, $meta)
1056
-        {
1057
-            $this->show_field_begin($field, $meta);
1058
-            echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1059
-            $this->show_field_end($field, $meta);
1060
-        }
1061
-
1062
-        /**
1063
-         * Show Posts field.
1064
-         * used creating a posts/pages/custom types checkboxlist or a select dropdown
1065
-         *
1066
-         * @global object $post The current post object.
1067
-         * @param string $field
1068
-         * @param string $meta
1069
-         * @since 1.0
1070
-         * @access public
1071
-         */
1072
-        public function show_field_posts($field, $meta)
1073
-        {
1074
-            global $post;
1075
-
1076
-            if (!is_array($meta)) $meta = (array)$meta;
1077
-            $this->show_field_begin($field, $meta);
1078
-            $options = $field['options'];
1079
-            $posts = get_posts($options['args']);
1080
-
1081
-            // checkbox_list
1082
-            if ('checkbox_list' == $options['type']) {
1083
-                foreach ($posts as $p) {
1084
-                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>";
1085
-                }
1086
-            } // select
1087
-            else {
1088
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1089
-                foreach ($posts as $p) {
1090
-                    echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>";
1091
-                }
1092
-                echo "</select>";
1093
-            }
1094
-
1095
-            $this->show_field_end($field, $meta);
1096
-        }
1097
-
1098
-        /**
1099
-         * Show Taxonomy field.
1100
-         * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown
1101
-         *
1102
-         * @global object $post The current post object.
1103
-         * @param string $field
1104
-         * @param string $meta
1105
-         * @since 1.0
1106
-         * @access public
1107
-         *
1108
-         * @uses get_terms()
1109
-         */
1110
-        public function show_field_taxonomy($field, $meta)
1111
-        {
1112
-            global $post;
1113
-
1114
-            if (!is_array($meta)) $meta = (array)$meta;
1115
-            $this->show_field_begin($field, $meta);
1116
-            $options = $field['options'];
1117
-            $terms = get_terms($options['taxonomy'], $options['args']);
1118
-
1119
-            // checkbox_list
1120
-            if ('checkbox_list' == $options['type']) {
1121
-                foreach ($terms as $term) {
1122
-                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>";
1123
-                }
1124
-            } // select
1125
-            else {
1126
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1127
-                foreach ($terms as $term) {
1128
-                    echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>";
1129
-                }
1130
-                echo "</select>";
1131
-            }
1132
-
1133
-            $this->show_field_end($field, $meta);
1134
-        }
1135
-
1136
-        /**
1137
-         * Save Data from Metabox
1138
-         *
1139
-         * @param string $term_id The term ID.
1140
-         * @since 1.0
1141
-         * @access public
1142
-         * @return string
1143
-         */
1144
-        public function save($term_id)
1145
-        {
1146
-
1147
-            $taxnow = '';
1148
-            if (isset($_POST['taxonomy']))
1149
-                $taxnow = $_POST['taxonomy'];
1150
-
1151
-            if (!isset($term_id)                                                        // Check Revision
1152
-                || (!in_array($taxnow, $this->_meta_box['pages']))                            // Check if current taxonomy type is supported.
1153
-                || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce'))        // Check nonce - Security
1154
-                || (!current_user_can('manage_categories'))
1155
-            )                                // Check permission
1156
-            {
1157
-                return $term_id;
1158
-            }
1159
-
1160
-
1161
-            foreach ($this->_fields as $field) {
1162
-
1163
-                $name = $field['id'];
1164
-                $type = $field['type'];
1165
-                $old = $this->get_tax_meta($term_id, $name, !$field['multiple']);
1166
-                $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : '');
1167
-
1168
-                // Validate meta value
1169
-                if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) {
1170
-                    $new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new);
1171
-                }
1172
-
1173
-
1174
-                if ($name == 'ct_cat_icon') {
1175
-
1176
-                    $upload_dir = wp_upload_dir();
1177
-
1178
-                    $image_name_arr = explode('/', $new['src']);
1179
-                    //$old_filename = end($image_name_arr);
1180
-                    //$img_name_arr = explode('.',$old_filename);
1181
-
1182
-                    //$old_filename = $upload_dir['path'].'/'.$old_filename;
1183
-
1184
-                    $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png';
1185
-
1186
-                    /*rename($old_filename, $new_filename);
661
+			$this->show_field_end($field, $meta);
662
+		}
663
+
664
+		/**
665
+		 * Begin Field.
666
+		 *
667
+		 * @param string $field
668
+		 * @param string $meta
669
+		 * @since 1.0
670
+		 * @access public
671
+		 */
672
+		public function show_field_begin($field, $meta)
673
+		{
674
+			if (isset($field['group'])) {
675
+				if ($field['group'] == "start") {
676
+					echo "<td class='at-field'>";
677
+				}
678
+			} else {
679
+				if ($this->_form_type == 'edit') {
680
+					echo '<th valign="top" scope="row">';
681
+				} else {
682
+					if ($field['validate_func']) {
683
+						echo '<td><div class="form-field form-required">';
684
+					} else {
685
+						echo '<td><div class="form-field">';
686
+					}
687
+				}
688
+			}
689
+			if ($field['name'] != '' || $field['name'] != FALSE) {
690
+				//echo "<div class='at-label'>";
691
+				echo "<label for='{$field['id']}'>{$field['name']}</label>";
692
+				//echo "</div>";
693
+			}
694
+			if ($this->_form_type == 'edit') {
695
+				echo '</th><td>';
696
+			}
697
+		}
698
+
699
+		/**
700
+		 * End Field.
701
+		 *
702
+		 * @param string $field
703
+		 * @param string $meta
704
+		 * @since 1.0
705
+		 * @access public
706
+		 */
707
+		public function show_field_end($field, $meta = NULL, $group = false)
708
+		{
709
+			if (isset($field['group'])) {
710
+				if ($group == 'end') {
711
+					if ($field['desc'] != '') {
712
+						echo "<p class='desc-field'>{$field['desc']}</p></td>";
713
+					} else {
714
+						echo "</td>";
715
+					}
716
+				} else {
717
+					if ($field['desc'] != '') {
718
+						echo "<p class='desc-field'>{$field['desc']}</p><br/>";
719
+					} else {
720
+						echo '<br/>';
721
+					}
722
+				}
723
+			} else {
724
+				if ($field['desc'] != '') {
725
+					echo "<p class='desc-field'>{$field['desc']}</p>";
726
+				}
727
+				if ($this->_form_type == 'edit') {
728
+					echo '<td>';
729
+				} else {
730
+					echo '<td></div>';
731
+				}
732
+			}
733
+		}
734
+
735
+		/**
736
+		 * Show Field Text.
737
+		 *
738
+		 * @param string $field
739
+		 * @param string $meta
740
+		 * @since 1.0
741
+		 * @access public
742
+		 */
743
+		public function show_field_text($field, $meta)
744
+		{
745
+			$this->show_field_begin($field, $meta);
746
+			echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />";
747
+			$this->show_field_end($field, $meta);
748
+		}
749
+
750
+		/**
751
+		 * Show Field hidden.
752
+		 *
753
+		 * @param string $field
754
+		 * @param string|mixed $meta
755
+		 * @since 0.1.3
756
+		 * @access public
757
+		 */
758
+		public function show_field_hidden($field, $meta)
759
+		{
760
+			//$this->show_field_begin( $field, $meta );
761
+			echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>";
762
+			//$this->show_field_end( $field, $meta );
763
+		}
764
+
765
+		/**
766
+		 * Show Field Paragraph.
767
+		 *
768
+		 * @param string $field
769
+		 * @since 0.1.3
770
+		 * @access public
771
+		 */
772
+		public function show_field_paragraph($field)
773
+		{
774
+			//$this->show_field_begin( $field, $meta );
775
+			echo '<p>' . $field['value'] . '</p>';
776
+			//$this->show_field_end( $field, $meta );
777
+		}
778
+
779
+		/**
780
+		 * Show Field Textarea.
781
+		 *
782
+		 * @param string $field
783
+		 * @param string $meta
784
+		 * @since 1.0
785
+		 * @access public
786
+		 */
787
+		public function show_field_textarea($field, $meta)
788
+		{
789
+			$this->show_field_begin($field, $meta);
790
+			echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
791
+			$this->show_field_end($field, $meta);
792
+		}
793
+
794
+		/**
795
+		 * Show Field Select.
796
+		 *
797
+		 * @param string $field
798
+		 * @param string $meta
799
+		 * @since 1.0
800
+		 * @access public
801
+		 */
802
+		public function show_field_select($field, $meta)
803
+		{
804
+
805
+			if (!is_array($meta))
806
+				$meta = (array)$meta;
807
+
808
+			$this->show_field_begin($field, $meta);
809
+			echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
810
+			foreach ($field['options'] as $key => $value) {
811
+				echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>";
812
+			}
813
+			echo "</select>";
814
+			$this->show_field_end($field, $meta);
815
+
816
+		}
817
+
818
+		/**
819
+		 * Show Radio Field.
820
+		 *
821
+		 * @param string $field
822
+		 * @param string $meta
823
+		 * @since 1.0
824
+		 * @access public
825
+		 */
826
+		public function show_field_radio($field, $meta)
827
+		{
828
+
829
+			if (!is_array($meta))
830
+				$meta = (array)$meta;
831
+
832
+			$this->show_field_begin($field, $meta);
833
+			foreach ($field['options'] as $key => $value) {
834
+				echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>";
835
+			}
836
+			$this->show_field_end($field, $meta);
837
+		}
838
+
839
+		/**
840
+		 * Show Checkbox Field.
841
+		 *
842
+		 * @param string $field
843
+		 * @param string $meta
844
+		 * @since 1.0
845
+		 * @access public
846
+		 */
847
+		public function show_field_checkbox($field, $meta)
848
+		{
849
+
850
+			$this->show_field_begin($field, $meta);
851
+			echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}";
852
+			$this->show_field_end($field, $meta);
853
+		}
854
+
855
+		/**
856
+		 * Show Wysiwig Field.
857
+		 *
858
+		 * @param string $field
859
+		 * @param string $meta
860
+		 * @since 1.0
861
+		 * @access public
862
+		 */
863
+		public function show_field_wysiwyg($field, $meta)
864
+		{
865
+			$this->show_field_begin($field, $meta);
866
+			// Add TinyMCE script for WP version < 3.3
867
+			global $wp_version;
868
+
869
+			if (version_compare($wp_version, '3.2.1') < 1) {
870
+				echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
871
+			} else {
872
+				// Use new wp_editor() since WP 3.3
873
+				wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg'));
874
+			}
875
+			$this->show_field_end($field, $meta);
876
+		}
877
+
878
+		/**
879
+		 * Show File Field.
880
+		 *
881
+		 * @global object $post The current post object.
882
+		 * @param string $field
883
+		 * @param string $meta
884
+		 * @since 1.0
885
+		 * @access public
886
+		 */
887
+		public function show_field_file($field, $meta)
888
+		{
889
+
890
+			global $post;
891
+
892
+			if (!is_array($meta))
893
+				$meta = (array)$meta;
894
+
895
+			$this->show_field_begin($field, $meta);
896
+			echo "{$field['desc']}<br />";
897
+
898
+			if (!empty($meta)) {
899
+				$nonce = wp_create_nonce('at_ajax_delete');
900
+				echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>';
901
+				echo '<ol class="at-upload">';
902
+				foreach ($meta as $att) {
903
+					// if (wp_attachment_is_image($att)) continue; // what's image uploader for?
904
+					echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>";
905
+				}
906
+				echo '</ol>';
907
+			}
908
+
909
+			// show form upload
910
+
911
+			echo "<div class='at-file-upload-label'>";
912
+			echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>";
913
+			echo "</div>";
914
+			echo "<div class='new-files'>";
915
+			echo "<div class='file-input'>";
916
+			echo "<input type='file' name='{$field['id']}[]' />";
917
+			echo "</div><!-- End .file-input -->";
918
+			echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>";
919
+			echo "</div><!-- End .new-files -->";
920
+			echo "</td>";
921
+			$this->show_field_end($field, $meta);
922
+		}
923
+
924
+		/**
925
+		 * Show Image Field.
926
+		 *
927
+		 * @param array $field
928
+		 * @param array $meta
929
+		 * @since 1.0
930
+		 * @access public
931
+		 */
932
+		public function show_field_image($field, $meta)
933
+		{
934
+			$this->show_field_begin($field, $meta);
935
+			$html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
936
+			if (is_array($meta)) {
937
+				if (isset($meta[0]) && is_array($meta[0]))
938
+					$meta = $meta[0];
939
+			}
940
+
941
+			$uploads = wp_upload_dir();
942
+			if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') {
943
+
944
+				$file_info = pathinfo($meta['src']);
945
+
946
+				//print_r($meta);
947
+				//print_r($uploads);
948
+				//print_r($file_info);
949
+
950
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
951
+					$sub_dir = $file_info['dirname'];
952
+
953
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs	
954
+				$uploads_baseurl = $uploads['baseurl'];
955
+				$uploads_path = $uploads['path'];
956
+
957
+				$file_name = $file_info['basename'];
958
+
959
+				$sub_dir = str_replace($uploads_baseurl, '', $sub_dir);
960
+
961
+				$uploads_url = $uploads_baseurl . $sub_dir;
962
+
963
+				$meta['src'] = $uploads_url . '/' . $file_name;
964
+
965
+
966
+				$html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>";
967
+				$html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />";
968
+				$html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />";
969
+				$html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />";
970
+			} else {
971
+				$html .= "<span class='mupload_img_holder'></span>";
972
+				$html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />";
973
+				$html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />";
974
+				$html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />";
975
+			}
976
+			echo $html;
977
+			$this->show_field_end($field, $meta);
978
+		}
979
+
980
+		/**
981
+		 * Show Color Field.
982
+		 *
983
+		 * @param string $field
984
+		 * @param string $meta
985
+		 * @since 1.0
986
+		 * @access public
987
+		 */
988
+		public function show_field_color($field, $meta)
989
+		{
990
+
991
+			if (empty($meta))
992
+				$meta = '#';
993
+
994
+			$this->show_field_begin($field, $meta);
995
+
996
+			echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />";
997
+			//	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>";
998
+			echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>";
999
+			echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>";
1000
+			$this->show_field_end($field, $meta);
1001
+
1002
+		}
1003
+
1004
+		/**
1005
+		 * Show Checkbox List Field
1006
+		 *
1007
+		 * @param string $field
1008
+		 * @param string $meta
1009
+		 * @since 1.0
1010
+		 * @access public
1011
+		 */
1012
+		public function show_field_checkbox_list($field, $meta)
1013
+		{
1014
+
1015
+			if (!is_array($meta))
1016
+				$meta = (array)$meta;
1017
+
1018
+			$this->show_field_begin($field, $meta);
1019
+
1020
+			$html = array();
1021
+
1022
+			foreach ($field['options'] as $key => $value) {
1023
+				$html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}";
1024
+			}
1025
+
1026
+			echo implode('<br />', $html);
1027
+
1028
+			$this->show_field_end($field, $meta);
1029
+
1030
+		}
1031
+
1032
+		/**
1033
+		 * Show Date Field.
1034
+		 *
1035
+		 * @param string $field
1036
+		 * @param string $meta
1037
+		 * @since 1.0
1038
+		 * @access public
1039
+		 */
1040
+		public function show_field_date($field, $meta)
1041
+		{
1042
+			$this->show_field_begin($field, $meta);
1043
+			echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1044
+			$this->show_field_end($field, $meta);
1045
+		}
1046
+
1047
+		/**
1048
+		 * Show time field.
1049
+		 *
1050
+		 * @param string $field
1051
+		 * @param string $meta
1052
+		 * @since 1.0
1053
+		 * @access public
1054
+		 */
1055
+		public function show_field_time($field, $meta)
1056
+		{
1057
+			$this->show_field_begin($field, $meta);
1058
+			echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1059
+			$this->show_field_end($field, $meta);
1060
+		}
1061
+
1062
+		/**
1063
+		 * Show Posts field.
1064
+		 * used creating a posts/pages/custom types checkboxlist or a select dropdown
1065
+		 *
1066
+		 * @global object $post The current post object.
1067
+		 * @param string $field
1068
+		 * @param string $meta
1069
+		 * @since 1.0
1070
+		 * @access public
1071
+		 */
1072
+		public function show_field_posts($field, $meta)
1073
+		{
1074
+			global $post;
1075
+
1076
+			if (!is_array($meta)) $meta = (array)$meta;
1077
+			$this->show_field_begin($field, $meta);
1078
+			$options = $field['options'];
1079
+			$posts = get_posts($options['args']);
1080
+
1081
+			// checkbox_list
1082
+			if ('checkbox_list' == $options['type']) {
1083
+				foreach ($posts as $p) {
1084
+					echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>";
1085
+				}
1086
+			} // select
1087
+			else {
1088
+				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1089
+				foreach ($posts as $p) {
1090
+					echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>";
1091
+				}
1092
+				echo "</select>";
1093
+			}
1094
+
1095
+			$this->show_field_end($field, $meta);
1096
+		}
1097
+
1098
+		/**
1099
+		 * Show Taxonomy field.
1100
+		 * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown
1101
+		 *
1102
+		 * @global object $post The current post object.
1103
+		 * @param string $field
1104
+		 * @param string $meta
1105
+		 * @since 1.0
1106
+		 * @access public
1107
+		 *
1108
+		 * @uses get_terms()
1109
+		 */
1110
+		public function show_field_taxonomy($field, $meta)
1111
+		{
1112
+			global $post;
1113
+
1114
+			if (!is_array($meta)) $meta = (array)$meta;
1115
+			$this->show_field_begin($field, $meta);
1116
+			$options = $field['options'];
1117
+			$terms = get_terms($options['taxonomy'], $options['args']);
1118
+
1119
+			// checkbox_list
1120
+			if ('checkbox_list' == $options['type']) {
1121
+				foreach ($terms as $term) {
1122
+					echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>";
1123
+				}
1124
+			} // select
1125
+			else {
1126
+				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1127
+				foreach ($terms as $term) {
1128
+					echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>";
1129
+				}
1130
+				echo "</select>";
1131
+			}
1132
+
1133
+			$this->show_field_end($field, $meta);
1134
+		}
1135
+
1136
+		/**
1137
+		 * Save Data from Metabox
1138
+		 *
1139
+		 * @param string $term_id The term ID.
1140
+		 * @since 1.0
1141
+		 * @access public
1142
+		 * @return string
1143
+		 */
1144
+		public function save($term_id)
1145
+		{
1146
+
1147
+			$taxnow = '';
1148
+			if (isset($_POST['taxonomy']))
1149
+				$taxnow = $_POST['taxonomy'];
1150
+
1151
+			if (!isset($term_id)                                                        // Check Revision
1152
+				|| (!in_array($taxnow, $this->_meta_box['pages']))                            // Check if current taxonomy type is supported.
1153
+				|| (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce'))        // Check nonce - Security
1154
+				|| (!current_user_can('manage_categories'))
1155
+			)                                // Check permission
1156
+			{
1157
+				return $term_id;
1158
+			}
1159
+
1160
+
1161
+			foreach ($this->_fields as $field) {
1162
+
1163
+				$name = $field['id'];
1164
+				$type = $field['type'];
1165
+				$old = $this->get_tax_meta($term_id, $name, !$field['multiple']);
1166
+				$new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : '');
1167
+
1168
+				// Validate meta value
1169
+				if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) {
1170
+					$new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new);
1171
+				}
1172
+
1173
+
1174
+				if ($name == 'ct_cat_icon') {
1175
+
1176
+					$upload_dir = wp_upload_dir();
1177
+
1178
+					$image_name_arr = explode('/', $new['src']);
1179
+					//$old_filename = end($image_name_arr);
1180
+					//$img_name_arr = explode('.',$old_filename);
1181
+
1182
+					//$old_filename = $upload_dir['path'].'/'.$old_filename;
1183
+
1184
+					$new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png';
1185
+
1186
+					/*rename($old_filename, $new_filename);
1187 1187
 				
1188 1188
 				//subdir
1189 1189
 				$new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png';
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 				update_attached_file( $new['id'], $new['src'] );*/
1192 1192
 
1193 1193
 
1194
-                    /*	
1194
+					/*	
1195 1195
 		
1196 1196
 		$new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png';
1197 1197
 		
@@ -1216,67 +1216,67 @@  discard block
 block discarded – undo
1216 1216
 		$attach_id = wp_insert_attachment( $attachment, $filename);*/
1217 1217
 
1218 1218
 
1219
-                }
1220
-
1221
-
1222
-                //skip on Paragraph field
1223
-                if ($type != "paragraph") {
1224
-
1225
-                    // Call defined method to save meta value, if there's no methods, call common one.
1226
-                    $save_func = 'save_field_' . $type;
1227
-                    if (method_exists($this, $save_func)) {
1228
-                        call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new);
1229
-                    } else {
1230
-                        $this->save_field($term_id, $field, $old, $new);
1231
-                    }
1232
-                }
1233
-
1234
-            } // End foreach
1235
-
1236
-        }
1237
-
1238
-        /**
1239
-         * Common function for saving fields.
1240
-         *
1241
-         * @param string $term_id The term ID.
1242
-         * @param string $field
1243
-         * @param string $old
1244
-         * @param string|mixed $new
1245
-         * @since 1.0
1246
-         * @access public
1247
-         */
1248
-        public function save_field($term_id, $field, $old, $new)
1249
-        {
1250
-            $name = $field['id'];
1251
-            $this->delete_tax_meta($term_id, $name);
1252
-            if ($new === '' || $new === array())
1253
-                return;
1254
-
1255
-            $this->update_tax_meta($term_id, $name, $new);
1256
-        }
1257
-
1258
-        /**
1259
-         * function for saving image field.
1260
-         *
1261
-         * @param string $term_id The term ID.
1262
-         * @param string $field
1263
-         * @param string $old
1264
-         * @param string|mixed $new
1265
-         * @since 1.0
1266
-         * @access public
1267
-         */
1268
-        public function save_field_image($term_id, $field, $old, $new)
1269
-        {
1270
-            $name = $field['id'];
1271
-
1272
-            $this->delete_tax_meta($term_id, $name);
1273
-            if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '')
1274
-                return;
1275
-
1276
-            $this->update_tax_meta($term_id, $name, $new);
1277
-        }
1278
-
1279
-        /*
1219
+				}
1220
+
1221
+
1222
+				//skip on Paragraph field
1223
+				if ($type != "paragraph") {
1224
+
1225
+					// Call defined method to save meta value, if there's no methods, call common one.
1226
+					$save_func = 'save_field_' . $type;
1227
+					if (method_exists($this, $save_func)) {
1228
+						call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new);
1229
+					} else {
1230
+						$this->save_field($term_id, $field, $old, $new);
1231
+					}
1232
+				}
1233
+
1234
+			} // End foreach
1235
+
1236
+		}
1237
+
1238
+		/**
1239
+		 * Common function for saving fields.
1240
+		 *
1241
+		 * @param string $term_id The term ID.
1242
+		 * @param string $field
1243
+		 * @param string $old
1244
+		 * @param string|mixed $new
1245
+		 * @since 1.0
1246
+		 * @access public
1247
+		 */
1248
+		public function save_field($term_id, $field, $old, $new)
1249
+		{
1250
+			$name = $field['id'];
1251
+			$this->delete_tax_meta($term_id, $name);
1252
+			if ($new === '' || $new === array())
1253
+				return;
1254
+
1255
+			$this->update_tax_meta($term_id, $name, $new);
1256
+		}
1257
+
1258
+		/**
1259
+		 * function for saving image field.
1260
+		 *
1261
+		 * @param string $term_id The term ID.
1262
+		 * @param string $field
1263
+		 * @param string $old
1264
+		 * @param string|mixed $new
1265
+		 * @since 1.0
1266
+		 * @access public
1267
+		 */
1268
+		public function save_field_image($term_id, $field, $old, $new)
1269
+		{
1270
+			$name = $field['id'];
1271
+
1272
+			$this->delete_tax_meta($term_id, $name);
1273
+			if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '')
1274
+				return;
1275
+
1276
+			$this->update_tax_meta($term_id, $name, $new);
1277
+		}
1278
+
1279
+		/*
1280 1280
 	 * Save Wysiwyg Field.
1281 1281
 	 *
1282 1282
 	 * @param string $term_id The term ID. 
@@ -1286,806 +1286,806 @@  discard block
 block discarded – undo
1286 1286
 	 * @since 1.0
1287 1287
 	 * @access public 
1288 1288
 	 */
1289
-        public function save_field_wysiwyg($term_id, $field, $old, $new)
1290
-        {
1291
-            $this->save_field($term_id, $field, $old, $new);
1292
-        }
1293
-
1294
-        /**
1295
-         * Save repeater Fields.
1296
-         *
1297
-         * @param string $term_id The term ID.
1298
-         * @param string $field
1299
-         * @param string|mixed $old
1300
-         * @param string|mixed $new
1301
-         * @since 1.0
1302
-         * @access public
1303
-         */
1304
-        public function save_field_repeater($term_id, $field, $old, $new)
1305
-        {
1306
-            if (is_array($new) && count($new) > 0) {
1307
-                foreach ($new as $n) {
1308
-                    foreach ($field['fields'] as $f) {
1309
-                        $type = $f['type'];
1310
-                        switch ($type) {
1311
-                            case 'wysiwyg':
1312
-                                $n[$f['id']] = wpautop($n[$f['id']]);
1313
-                                break;
1314
-                            case 'file':
1315
-                                $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]);
1316
-                                break;
1317
-                            default:
1318
-                                break;
1319
-                        }
1320
-                    }
1321
-                    if (!$this->is_array_empty($n))
1322
-                        $temp[] = $n;
1323
-                }
1324
-                if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) {
1325
-                    $this->update_tax_meta($term_id, $field['id'], $temp);
1326
-                } else {
1327
-                    //	remove old meta if exists
1328
-                    delete_post_meta($term_id, $field['id']);
1329
-                }
1330
-            } else {
1331
-                //	remove old meta if exists
1332
-                delete_post_meta($term_id, $field['id']);
1333
-            }
1334
-        }
1335
-
1336
-        /**
1337
-         * Save File Field.
1338
-         *
1339
-         * @param string $term_id The term ID.
1340
-         * @param string $field
1341
-         * @param string $old
1342
-         * @param string $new
1343
-         * @since 1.0
1344
-         * @access public
1345
-         */
1346
-        public function save_field_file($term_id, $field, $old, $new)
1347
-        {
1348
-
1349
-            $name = $field['id'];
1350
-            if (empty($_FILES[$name]))
1351
-                return;
1352
-            $this->fix_file_array($_FILES[$name]);
1353
-            foreach ($_FILES[$name] as $position => $fileitem) {
1354
-
1355
-                $file = wp_handle_upload($fileitem, array('test_form' => false));
1356
-                if (empty($file['file']))
1357
-                    continue;
1358
-                $filename = $file['file'];
1359
-
1360
-                $attachment = array(
1361
-                    'post_mime_type' => $file['type'],
1362
-                    'guid' => $file['url'],
1363
-                    'post_parent' => $term_id,
1364
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1365
-                    'post_content' => ''
1366
-                );
1367
-
1368
-                $id = wp_insert_attachment($attachment, $filename, $term_id);
1369
-
1370
-                if (!is_wp_error($id)) {
1371
-
1372
-                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1373
-                    add_post_meta($term_id, $name, $id, false);    // save file's url in meta fields
1374
-
1375
-                } // End if
1376
-
1377
-            } // End foreach
1378
-
1379
-        }
1380
-
1381
-        /**
1382
-         * Save repeater File Field.
1383
-         * @param string $term_id The term ID.
1384
-         * @param string $field
1385
-         * @param string $old
1386
-         * @param string $new
1387
-         * @since 1.0
1388
-         * @access public
1389
-         * @return int|void
1390
-         */
1391
-        public function save_field_file_repeater($term_id, $field, $old, $new)
1392
-        {
1393
-
1394
-            $name = $field['id'];
1395
-            if (empty($_FILES[$name]))
1396
-                return;
1397
-            $this->fix_file_array($_FILES[$name]);
1398
-            foreach ($_FILES[$name] as $position => $fileitem) {
1399
-
1400
-                $file = wp_handle_upload($fileitem, array('test_form' => false));
1401
-                if (empty($file['file']))
1402
-                    continue;
1403
-                $filename = $file['file'];
1404
-
1405
-                $attachment = array(
1406
-                    'post_mime_type' => $file['type'],
1407
-                    'guid' => $file['url'],
1408
-                    'post_parent' => $term_id,
1409
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1410
-                    'post_content' => ''
1411
-                );
1412
-
1413
-                $id = wp_insert_attachment($attachment, $filename);
1414
-
1415
-                if (!is_wp_error($id)) {
1416
-
1417
-                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1418
-                    return $id;    // return file's url in meta fields
1419
-                } // End if
1420
-            } // End foreach
1421
-        }
1422
-
1423
-        /**
1424
-         * Add missed values for meta box.
1425
-         *
1426
-         * @since 1.0
1427
-         * @access public
1428
-         */
1429
-        public function add_missed_values()
1430
-        {
1431
-
1432
-            // Default values for meta box
1433
-            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box);
1434
-
1435
-            if(is_array($this->_fields)) {
1436
-                // Default values for fields
1437
-                foreach ($this->_fields as &$field) {
1438
-                    $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image'));
1439
-                    $std = $multiple ? array() : '';
1440
-                    $format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : '');
1441
-                    $field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field);
1442
-                } // End foreach
1443
-            }
1444
-        }
1445
-
1446
-        /**
1447
-         * Check if field with $type exists.
1448
-         *
1449
-         * @param string $type
1450
-         * @since 1.0
1451
-         * @access public
1452
-         */
1453
-        public function has_field($type)
1454
-        {
1455
-            if(is_array($this->_fields)) {
1456
-                foreach ($this->_fields as $field) {
1457
-                    if ($type == $field['type'])
1458
-                        return true;
1459
-                }
1460
-            }
1461
-            return false;
1462
-        }
1463
-
1464
-        /**
1465
-         * Check if current page is edit page.
1466
-         *
1467
-         * @since 1.0
1468
-         * @access public
1469
-         */
1470
-        public function is_edit_page()
1471
-        {
1472
-            global $pagenow;
1473
-            return ($pagenow == 'edit-tags.php');
1474
-        }
1475
-
1476
-        /**
1477
-         * Fixes the odd indexing of multiple file uploads.
1478
-         *
1479
-         * Goes from the format:
1480
-         * $_FILES['field']['key']['index']
1481
-         * to
1482
-         * The More standard and appropriate:
1483
-         * $_FILES['field']['index']['key']
1484
-         *
1485
-         * @param string $files
1486
-         * @since 1.0
1487
-         * @access public
1488
-         */
1489
-        public function fix_file_array(&$files)
1490
-        {
1491
-
1492
-            $output = array();
1493
-
1494
-            foreach ($files as $key => $list) {
1495
-                foreach ($list as $index => $value) {
1496
-                    $output[$index][$key] = $value;
1497
-                }
1498
-            }
1499
-
1500
-            return $files = $output;
1501
-
1502
-        }
1503
-
1504
-        /**
1505
-         * Get proper JQuery UI version.
1506
-         *
1507
-         * Used in order to not conflict with WP Admin Scripts.
1508
-         *
1509
-         * @since 1.0
1510
-         * @access public
1511
-         */
1512
-        public function get_jqueryui_ver()
1513
-        {
1514
-
1515
-            global $wp_version;
1516
-
1517
-            if (version_compare($wp_version, '3.1', '>=')) {
1518
-                return '1.8.10';
1519
-            }
1520
-
1521
-            return '1.7.3';
1522
-
1523
-        }
1524
-
1525
-        /**
1526
-         *  Add Field to meta box (generic function)
1527
-         * @author Ohad Raz
1528
-         * @since 1.0
1529
-         * @access public
1530
-         * @param $id string  field id, i.e. the meta key
1531
-         * @param $args mixed|array
1532
-         */
1533
-        public function addField($id, $args)
1534
-        {
1535
-            $new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => '');
1536
-            $new_field = array_merge($new_field, $args);
1537
-            $this->_fields[] = $new_field;
1538
-        }
1539
-
1540
-
1541
-        /**
1542
-         *  Add Text Field to meta box
1543
-         * @author Ohad Raz
1544
-         * @since 1.0
1545
-         * @access public
1546
-         * @param $id string  field id, i.e. the meta key
1547
-         * @param $args mixed|array
1548
-         *    'name' => // field name/label string optional
1549
-         *    'desc' => // field description, string optional
1550
-         *    'std' => // default value, string optional
1551
-         *    'style' =>    // custom style for field, string optional
1552
-         *    'validate_func' => // validate function, string optional
1553
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1554
-         */
1555
-        public function addText($id, $args, $repeater = false)
1556
-        {
1557
-            $new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1558
-            $new_field = array_merge($new_field, $args);
1559
-            if (false === $repeater) {
1560
-                $this->_fields[] = $new_field;
1561
-            } else {
1562
-                return $new_field;
1563
-            }
1564
-        }
1565
-
1566
-        /**
1567
-         *  Add Hidden Field to meta box
1568
-         * @author Ohad Raz
1569
-         * @since 0.1.3
1570
-         * @access public
1571
-         * @param $id string  field id, i.e. the meta key
1572
-         * @param $args mixed|array
1573
-         *    'name' => // field name/label string optional
1574
-         *    'desc' => // field description, string optional
1575
-         *    'std' => // default value, string optional
1576
-         *    'style' =>    // custom style for field, string optional
1577
-         *    'validate_func' => // validate function, string optional
1578
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1579
-         */
1580
-        public function addHidden($id, $args, $repeater = false)
1581
-        {
1582
-            $new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1583
-            $new_field = array_merge($new_field, $args);
1584
-            if (false === $repeater) {
1585
-                $this->_fields[] = $new_field;
1586
-            } else {
1587
-                return $new_field;
1588
-            }
1589
-        }
1590
-
1591
-        /**
1592
-         *  Add Paragraph to meta box
1593
-         * @author Ohad Raz
1594
-         * @since 0.1.3
1595
-         * @access public
1596
-         * @param $id string  field id, i.e. the meta key
1597
-         * @param $value  paragraph html
1598
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1599
-         */
1600
-        public function addParagraph($id, $args, $repeater = false)
1601
-        {
1602
-            $new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => '');
1603
-            $new_field = array_merge($new_field, $args);
1604
-            if (false === $repeater) {
1605
-                $this->_fields[] = $new_field;
1606
-            } else {
1607
-                return $new_field;
1608
-            }
1609
-        }
1610
-
1611
-        /**
1612
-         *  Add Checkbox Field to meta box
1613
-         * @author Ohad Raz
1614
-         * @since 1.0
1615
-         * @access public
1616
-         * @param $id string  field id, i.e. the meta key
1617
-         * @param $args mixed|array
1618
-         *    'name' => // field name/label string optional
1619
-         *    'desc' => // field description, string optional
1620
-         *    'std' => // default value, string optional
1621
-         *    'validate_func' => // validate function, string optional
1622
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1623
-         */
1624
-        public function addCheckbox($id, $args, $repeater = false)
1625
-        {
1626
-            $new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory'));
1627
-            $new_field = array_merge($new_field, $args);
1628
-            if (false === $repeater) {
1629
-                $this->_fields[] = $new_field;
1630
-            } else {
1631
-                return $new_field;
1632
-            }
1633
-        }
1634
-
1635
-        /**
1636
-         *  Add CheckboxList Field to meta box
1637
-         * @author Ohad Raz
1638
-         * @since 1.0
1639
-         * @access public
1640
-         * @param $id string  field id, i.e. the meta key
1641
-         * @param $options (array)  array of key => value pairs for select options
1642
-         * @param $args mixed|array
1643
-         *    'name' => // field name/label string optional
1644
-         *    'desc' => // field description, string optional
1645
-         *    'std' => // default value, string optional
1646
-         *    'validate_func' => // validate function, string optional
1647
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1648
-         *
1649
-         * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false);
1650
-         *   which means the last param as false to get the values in an array
1651
-         */
1652
-        public function addCheckboxList($id, $options, $args, $repeater = false)
1653
-        {
1654
-            $new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory'));
1655
-            $new_field = array_merge($new_field, $args);
1656
-            if (false === $repeater) {
1657
-                $this->_fields[] = $new_field;
1658
-            } else {
1659
-                return $new_field;
1660
-            }
1661
-        }
1662
-
1663
-        /**
1664
-         *  Add Textarea Field to meta box
1665
-         * @author Ohad Raz
1666
-         * @since 1.0
1667
-         * @access public
1668
-         * @param $id string  field id, i.e. the meta key
1669
-         * @param $args mixed|array
1670
-         *    'name' => // field name/label string optional
1671
-         *    'desc' => // field description, string optional
1672
-         *    'std' => // default value, string optional
1673
-         *    'style' =>    // custom style for field, string optional
1674
-         *    'validate_func' => // validate function, string optional
1675
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1676
-         */
1677
-        public function addTextarea($id, $args, $repeater = false)
1678
-        {
1679
-            $new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory'));
1680
-            $new_field = array_merge($new_field, $args);
1681
-            if (false === $repeater) {
1682
-                $this->_fields[] = $new_field;
1683
-            } else {
1684
-                return $new_field;
1685
-            }
1686
-        }
1687
-
1688
-        /**
1689
-         *  Add Select Field to meta box
1690
-         * @author Ohad Raz
1691
-         * @since 1.0
1692
-         * @access public
1693
-         * @param $id string field id, i.e. the meta key
1694
-         * @param $options (array)  array of key => value pairs for select options
1695
-         * @param $args mixed|array
1696
-         *    'name' => // field name/label string optional
1697
-         *    'desc' => // field description, string optional
1698
-         *    'std' => // default value, (array) optional
1699
-         *    'multiple' => // select multiple values, optional. Default is false.
1700
-         *    'validate_func' => // validate function, string optional
1701
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1702
-         */
1703
-        public function addSelect($id, $options, $args, $repeater = false)
1704
-        {
1705
-            $new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options);
1706
-            $new_field = array_merge($new_field, $args);
1707
-            if (false === $repeater) {
1708
-                $this->_fields[] = $new_field;
1709
-            } else {
1710
-                return $new_field;
1711
-            }
1712
-        }
1713
-
1714
-
1715
-        /**
1716
-         *  Add Radio Field to meta box
1717
-         * @author Ohad Raz
1718
-         * @since 1.0
1719
-         * @access public
1720
-         * @param $id string field id, i.e. the meta key
1721
-         * @param $options (array)  array of key => value pairs for radio options
1722
-         * @param $args mixed|array
1723
-         *    'name' => // field name/label string optional
1724
-         *    'desc' => // field description, string optional
1725
-         *    'std' => // default value, string optional
1726
-         *    'validate_func' => // validate function, string optional
1727
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1728
-         */
1729
-        public function addRadio($id, $options, $args, $repeater = false)
1730
-        {
1731
-            $new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options);
1732
-            $new_field = array_merge($new_field, $args);
1733
-            if (false === $repeater) {
1734
-                $this->_fields[] = $new_field;
1735
-            } else {
1736
-                return $new_field;
1737
-            }
1738
-        }
1739
-
1740
-        /**
1741
-         *  Add Date Field to meta box
1742
-         * @author Ohad Raz
1743
-         * @since 1.0
1744
-         * @access public
1745
-         * @param $id string  field id, i.e. the meta key
1746
-         * @param $args mixed|array
1747
-         *    'name' => // field name/label string optional
1748
-         *    'desc' => // field description, string optional
1749
-         *    'std' => // default value, string optional
1750
-         *    'validate_func' => // validate function, string optional
1751
-         *    'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'"  See more formats here: http://goo.gl/Wcwxn
1752
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1753
-         */
1754
-        public function addDate($id, $args, $repeater = false)
1755
-        {
1756
-            $new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory'));
1757
-            $new_field = array_merge($new_field, $args);
1758
-            if (false === $repeater) {
1759
-                $this->_fields[] = $new_field;
1760
-            } else {
1761
-                return $new_field;
1762
-            }
1763
-        }
1764
-
1765
-        /**
1766
-         *  Add Time Field to meta box
1767
-         * @author Ohad Raz
1768
-         * @since 1.0
1769
-         * @access public
1770
-         * @param $id string- field id, i.e. the meta key
1771
-         * @param $args mixed|array
1772
-         *    'name' => // field name/label string optional
1773
-         *    'desc' => // field description, string optional
1774
-         *    'std' => // default value, string optional
1775
-         *    'validate_func' => // validate function, string optional
1776
-         *    'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX
1777
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1778
-         */
1779
-        public function addTime($id, $args, $repeater = false)
1780
-        {
1781
-            $new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory'));
1782
-            $new_field = array_merge($new_field, $args);
1783
-            if (false === $repeater) {
1784
-                $this->_fields[] = $new_field;
1785
-            } else {
1786
-                return $new_field;
1787
-            }
1788
-        }
1789
-
1790
-        /**
1791
-         *  Add Color Field to meta box
1792
-         * @author Ohad Raz
1793
-         * @since 1.0
1794
-         * @access public
1795
-         * @param $id string  field id, i.e. the meta key
1796
-         * @param $args mixed|array
1797
-         *    'name' => // field name/label string optional
1798
-         *    'desc' => // field description, string optional
1799
-         *    'std' => // default value, string optional
1800
-         *    'validate_func' => // validate function, string optional
1801
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1802
-         */
1803
-        public function addColor($id, $args, $repeater = false)
1804
-        {
1805
-            $new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory'));
1806
-            $new_field = array_merge($new_field, $args);
1807
-            if (false === $repeater) {
1808
-                $this->_fields[] = $new_field;
1809
-            } else {
1810
-                return $new_field;
1811
-            }
1812
-        }
1813
-
1814
-        /**
1815
-         *  Add Image Field to meta box
1816
-         * @author Ohad Raz
1817
-         * @since 1.0
1818
-         * @access public
1819
-         * @param $id string  field id, i.e. the meta key
1820
-         * @param $args mixed|array
1821
-         *    'name' => // field name/label string optional
1822
-         *    'desc' => // field description, string optional
1823
-         *    'validate_func' => // validate function, string optional
1824
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1825
-         */
1826
-        public function addImage($id, $args, $repeater = false)
1827
-        {
1828
-            $new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory'));
1829
-            $new_field = array_merge($new_field, $args);
1830
-
1831
-            if (false === $repeater) {
1832
-                $this->_fields[] = $new_field;
1833
-            } else {
1834
-                return $new_field;
1835
-            }
1836
-        }
1837
-
1838
-        /**
1839
-         *  Add File Field to meta box
1840
-         * @author Ohad Raz
1841
-         * @since 1.0
1842
-         * @access public
1843
-         * @param $id string  field id, i.e. the meta key
1844
-         * @param $args mixed|array
1845
-         *    'name' => // field name/label string optional
1846
-         *    'desc' => // field description, string optional
1847
-         *    'validate_func' => // validate function, string optional
1848
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1849
-         */
1850
-        public function addFile($id, $args, $repeater = false)
1851
-        {
1852
-            $new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory'));
1853
-            $new_field = array_merge($new_field, $args);
1854
-            if (false === $repeater) {
1855
-                $this->_fields[] = $new_field;
1856
-            } else {
1857
-                return $new_field;
1858
-            }
1859
-        }
1860
-
1861
-        /**
1862
-         *  Add WYSIWYG Field to meta box
1863
-         * @author Ohad Raz
1864
-         * @since 1.0
1865
-         * @access public
1866
-         * @param $id string  field id, i.e. the meta key
1867
-         * @param $args mixed|array
1868
-         *    'name' => // field name/label string optional
1869
-         *    'desc' => // field description, string optional
1870
-         *    'std' => // default value, string optional
1871
-         *    'style' =>    // custom style for field, string optional Default 'width: 300px; height: 400px'
1872
-         *    'validate_func' => // validate function, string optional
1873
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1874
-         */
1875
-        public function addWysiwyg($id, $args, $repeater = false)
1876
-        {
1877
-            $new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory'));
1878
-            $new_field = array_merge($new_field, $args);
1879
-            if (false === $repeater) {
1880
-                $this->_fields[] = $new_field;
1881
-            } else {
1882
-                return $new_field;
1883
-            }
1884
-        }
1885
-
1886
-        /**
1887
-         *  Add Taxonomy Field to meta box
1888
-         * @author Ohad Raz
1889
-         * @since 1.0
1890
-         * @access public
1891
-         * @param $id string  field id, i.e. the meta key
1892
-         * @param $options mixed|array options of taxonomy field
1893
-         *    'taxonomy' =>    // taxonomy name can be category,post_tag or any custom taxonomy default is category
1894
-         * 'type' =>  // how to show taxonomy? 'select' (default) or 'checkbox_list'
1895
-         * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false)
1896
-         * @param $args mixed|array
1897
-         *    'name' => // field name/label string optional
1898
-         *    'desc' => // field description, string optional
1899
-         *    'std' => // default value, string optional
1900
-         *    'validate_func' => // validate function, string optional
1901
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1902
-         */
1903
-        public function addTaxonomy($id, $options, $args, $repeater = false)
1904
-        {
1905
-            $q = array('hide_empty' => 0);
1906
-            $tax = 'category';
1907
-            $type = 'select';
1908
-            $temp = array($tax, $type, $q);
1909
-            $options = array_merge($temp, $options);
1910
-            $new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options);
1911
-            $new_field = array_merge($new_field, $args);
1912
-            if (false === $repeater) {
1913
-                $this->_fields[] = $new_field;
1914
-            } else {
1915
-                return $new_field;
1916
-            }
1917
-        }
1918
-
1919
-        /**
1920
-         *  Add posts Field to meta box
1921
-         * @author Ohad Raz
1922
-         * @since 1.0
1923
-         * @access public
1924
-         * @param $id string  field id, i.e. the meta key
1925
-         * @param $options mixed|array options of taxonomy field
1926
-         *    'post_type' =>    // post type name, 'post' (default) 'page' or any custom post type
1927
-         * 'type' =>  // how to show posts? 'select' (default) or 'checkbox_list'
1928
-         * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1)
1929
-         * @param $args mixed|array
1930
-         *    'name' => // field name/label string optional
1931
-         *    'desc' => // field description, string optional
1932
-         *    'std' => // default value, string optional
1933
-         *    'validate_func' => // validate function, string optional
1934
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1935
-         */
1936
-        public function addPosts($id, $options, $args, $repeater = false)
1937
-        {
1938
-            $q = array('posts_per_page' => -1);
1939
-            $temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q);
1940
-            $options = array_merge($temp, $options);
1941
-            $new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options);
1942
-            $new_field = array_merge($new_field, $args);
1943
-            if (false === $repeater) {
1944
-                $this->_fields[] = $new_field;
1945
-            } else {
1946
-                return $new_field;
1947
-            }
1948
-        }
1949
-
1950
-        /**
1951
-         *  Add repeater Field Block to meta box
1952
-         * @author Ohad Raz
1953
-         * @since 1.0
1954
-         * @access public
1955
-         * @param $id string  field id, i.e. the meta key
1956
-         * @param $args mixed|array
1957
-         *    'name' => // field name/label string optional
1958
-         *    'desc' => // field description, string optional
1959
-         *    'std' => // default value, string optional
1960
-         *    'style' =>    // custom style for field, string optional
1961
-         *    'validate_func' => // validate function, string optional
1962
-         *    'fields' => //fields to repeater
1963
-         */
1964
-        public function addRepeaterBlock($id, $args)
1965
-        {
1966
-            $new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false);
1967
-            $new_field = array_merge($new_field, $args);
1968
-            $this->_fields[] = $new_field;
1969
-        }
1970
-
1971
-
1972
-        /**
1973
-         * Finish Declaration of Meta Box
1974
-         * @author Ohad Raz
1975
-         * @since 1.0
1976
-         * @access public
1977
-         */
1978
-        public function Finish()
1979
-        {
1980
-            $this->add_missed_values();
1981
-            $this->check_field_upload();
1982
-            $this->check_field_color();
1983
-            $this->check_field_date();
1984
-            $this->check_field_time();
1985
-        }
1986
-
1987
-        /**
1988
-         * Helper function to check for empty arrays
1989
-         * @author Ohad Raz
1990
-         * @since 1.0
1991
-         * @access public
1992
-         * @param $args mixed|array
1993
-         */
1994
-        public function is_array_empty($array)
1995
-        {
1996
-            if (!is_array($array))
1997
-                return true;
1998
-
1999
-            foreach ($array as $a) {
2000
-                if (is_array($a)) {
2001
-                    foreach ($a as $sub_a) {
2002
-                        if (!empty($sub_a) && $sub_a != '')
2003
-                            return false;
2004
-                    }
2005
-                } else {
2006
-                    if (!empty($a) && $a != '')
2007
-                        return false;
2008
-                }
2009
-            }
2010
-            return true;
2011
-        }
2012
-
2013
-
2014
-        //get term meta field
2015
-        public function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2016
-        {
2017
-
2018
-            if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2019
-                $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2020
-                $post_type = $taxObject->object_type[0];
2021
-            }
2022
-
2023
-            if($post_type=='post'){$post_type='';}
2024
-            if($post_type){$post_type = $post_type.'_';}
2025
-
2026
-            $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2027
-
2028
-            $m = get_option('tax_meta_' . $post_type  . $t_id);
2029
-            if (isset($m[$key])) {
2030
-                return $m[$key];
2031
-            } else {
2032
-                return '';
2033
-            }
2034
-        }
2035
-
2036
-        //delete meta
2037
-        public function delete_tax_meta($term_id, $key, $post_type = '')
2038
-        {
2039
-
2040
-            if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2041
-                $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2042
-                $post_type = $taxObject->object_type[0];
2043
-            }
2044
-
2045
-            if($post_type=='post'){$post_type='';}
2046
-            if($post_type){$post_type = $post_type.'_';}
2047
-
2048
-            $m = get_option('tax_meta_' . $post_type  . $term_id);
2049
-
2050
-            if (isset($m[$key])) {
2051
-                unset($m[$key]);
2052
-            }
2053
-            update_option('tax_meta_' . $post_type  . $term_id, $m);
2054
-        }
2055
-
2056
-        //update meta
2057
-        public function update_tax_meta($term_id, $key, $value, $post_type = '')
2058
-        {
2059
-
2060
-            if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2061
-                $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2062
-                $post_type = $taxObject->object_type[0];
2063
-            }
2064
-
2065
-            if($post_type=='post'){$post_type='';}
2066
-            if($post_type){$post_type = $post_type.'_';}
2067
-
2068
-            $m = get_option('tax_meta_' . $post_type  . $term_id);
2069
-
2070
-            $m[$key] = $value;
2071
-            update_option('tax_meta_' . $post_type  . $term_id, $m);
2072
-
2073
-            /**
2074
-             * Called after the tax meta is updated.
2075
-             *
2076
-             * Used to update things after a GD category is saved.
2077
-             *
2078
-             * @since 1.0.0
2079
-             * @param bool $false False.
2080
-             * @param bool $true True.
2081
-             * @param int $term_id The term id being updated.
2082
-             * @param string $post_type The post type of the cat being updated.
2083
-             */
2084
-            do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2085
-        }
2086
-
2087
-
2088
-    } // End Class
1289
+		public function save_field_wysiwyg($term_id, $field, $old, $new)
1290
+		{
1291
+			$this->save_field($term_id, $field, $old, $new);
1292
+		}
1293
+
1294
+		/**
1295
+		 * Save repeater Fields.
1296
+		 *
1297
+		 * @param string $term_id The term ID.
1298
+		 * @param string $field
1299
+		 * @param string|mixed $old
1300
+		 * @param string|mixed $new
1301
+		 * @since 1.0
1302
+		 * @access public
1303
+		 */
1304
+		public function save_field_repeater($term_id, $field, $old, $new)
1305
+		{
1306
+			if (is_array($new) && count($new) > 0) {
1307
+				foreach ($new as $n) {
1308
+					foreach ($field['fields'] as $f) {
1309
+						$type = $f['type'];
1310
+						switch ($type) {
1311
+							case 'wysiwyg':
1312
+								$n[$f['id']] = wpautop($n[$f['id']]);
1313
+								break;
1314
+							case 'file':
1315
+								$n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]);
1316
+								break;
1317
+							default:
1318
+								break;
1319
+						}
1320
+					}
1321
+					if (!$this->is_array_empty($n))
1322
+						$temp[] = $n;
1323
+				}
1324
+				if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) {
1325
+					$this->update_tax_meta($term_id, $field['id'], $temp);
1326
+				} else {
1327
+					//	remove old meta if exists
1328
+					delete_post_meta($term_id, $field['id']);
1329
+				}
1330
+			} else {
1331
+				//	remove old meta if exists
1332
+				delete_post_meta($term_id, $field['id']);
1333
+			}
1334
+		}
1335
+
1336
+		/**
1337
+		 * Save File Field.
1338
+		 *
1339
+		 * @param string $term_id The term ID.
1340
+		 * @param string $field
1341
+		 * @param string $old
1342
+		 * @param string $new
1343
+		 * @since 1.0
1344
+		 * @access public
1345
+		 */
1346
+		public function save_field_file($term_id, $field, $old, $new)
1347
+		{
1348
+
1349
+			$name = $field['id'];
1350
+			if (empty($_FILES[$name]))
1351
+				return;
1352
+			$this->fix_file_array($_FILES[$name]);
1353
+			foreach ($_FILES[$name] as $position => $fileitem) {
1354
+
1355
+				$file = wp_handle_upload($fileitem, array('test_form' => false));
1356
+				if (empty($file['file']))
1357
+					continue;
1358
+				$filename = $file['file'];
1359
+
1360
+				$attachment = array(
1361
+					'post_mime_type' => $file['type'],
1362
+					'guid' => $file['url'],
1363
+					'post_parent' => $term_id,
1364
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1365
+					'post_content' => ''
1366
+				);
1367
+
1368
+				$id = wp_insert_attachment($attachment, $filename, $term_id);
1369
+
1370
+				if (!is_wp_error($id)) {
1371
+
1372
+					wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1373
+					add_post_meta($term_id, $name, $id, false);    // save file's url in meta fields
1374
+
1375
+				} // End if
1376
+
1377
+			} // End foreach
1378
+
1379
+		}
1380
+
1381
+		/**
1382
+		 * Save repeater File Field.
1383
+		 * @param string $term_id The term ID.
1384
+		 * @param string $field
1385
+		 * @param string $old
1386
+		 * @param string $new
1387
+		 * @since 1.0
1388
+		 * @access public
1389
+		 * @return int|void
1390
+		 */
1391
+		public function save_field_file_repeater($term_id, $field, $old, $new)
1392
+		{
1393
+
1394
+			$name = $field['id'];
1395
+			if (empty($_FILES[$name]))
1396
+				return;
1397
+			$this->fix_file_array($_FILES[$name]);
1398
+			foreach ($_FILES[$name] as $position => $fileitem) {
1399
+
1400
+				$file = wp_handle_upload($fileitem, array('test_form' => false));
1401
+				if (empty($file['file']))
1402
+					continue;
1403
+				$filename = $file['file'];
1404
+
1405
+				$attachment = array(
1406
+					'post_mime_type' => $file['type'],
1407
+					'guid' => $file['url'],
1408
+					'post_parent' => $term_id,
1409
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1410
+					'post_content' => ''
1411
+				);
1412
+
1413
+				$id = wp_insert_attachment($attachment, $filename);
1414
+
1415
+				if (!is_wp_error($id)) {
1416
+
1417
+					wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1418
+					return $id;    // return file's url in meta fields
1419
+				} // End if
1420
+			} // End foreach
1421
+		}
1422
+
1423
+		/**
1424
+		 * Add missed values for meta box.
1425
+		 *
1426
+		 * @since 1.0
1427
+		 * @access public
1428
+		 */
1429
+		public function add_missed_values()
1430
+		{
1431
+
1432
+			// Default values for meta box
1433
+			$this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box);
1434
+
1435
+			if(is_array($this->_fields)) {
1436
+				// Default values for fields
1437
+				foreach ($this->_fields as &$field) {
1438
+					$multiple = in_array($field['type'], array('checkbox_list', 'file', 'image'));
1439
+					$std = $multiple ? array() : '';
1440
+					$format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : '');
1441
+					$field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field);
1442
+				} // End foreach
1443
+			}
1444
+		}
1445
+
1446
+		/**
1447
+		 * Check if field with $type exists.
1448
+		 *
1449
+		 * @param string $type
1450
+		 * @since 1.0
1451
+		 * @access public
1452
+		 */
1453
+		public function has_field($type)
1454
+		{
1455
+			if(is_array($this->_fields)) {
1456
+				foreach ($this->_fields as $field) {
1457
+					if ($type == $field['type'])
1458
+						return true;
1459
+				}
1460
+			}
1461
+			return false;
1462
+		}
1463
+
1464
+		/**
1465
+		 * Check if current page is edit page.
1466
+		 *
1467
+		 * @since 1.0
1468
+		 * @access public
1469
+		 */
1470
+		public function is_edit_page()
1471
+		{
1472
+			global $pagenow;
1473
+			return ($pagenow == 'edit-tags.php');
1474
+		}
1475
+
1476
+		/**
1477
+		 * Fixes the odd indexing of multiple file uploads.
1478
+		 *
1479
+		 * Goes from the format:
1480
+		 * $_FILES['field']['key']['index']
1481
+		 * to
1482
+		 * The More standard and appropriate:
1483
+		 * $_FILES['field']['index']['key']
1484
+		 *
1485
+		 * @param string $files
1486
+		 * @since 1.0
1487
+		 * @access public
1488
+		 */
1489
+		public function fix_file_array(&$files)
1490
+		{
1491
+
1492
+			$output = array();
1493
+
1494
+			foreach ($files as $key => $list) {
1495
+				foreach ($list as $index => $value) {
1496
+					$output[$index][$key] = $value;
1497
+				}
1498
+			}
1499
+
1500
+			return $files = $output;
1501
+
1502
+		}
1503
+
1504
+		/**
1505
+		 * Get proper JQuery UI version.
1506
+		 *
1507
+		 * Used in order to not conflict with WP Admin Scripts.
1508
+		 *
1509
+		 * @since 1.0
1510
+		 * @access public
1511
+		 */
1512
+		public function get_jqueryui_ver()
1513
+		{
1514
+
1515
+			global $wp_version;
1516
+
1517
+			if (version_compare($wp_version, '3.1', '>=')) {
1518
+				return '1.8.10';
1519
+			}
1520
+
1521
+			return '1.7.3';
1522
+
1523
+		}
1524
+
1525
+		/**
1526
+		 *  Add Field to meta box (generic function)
1527
+		 * @author Ohad Raz
1528
+		 * @since 1.0
1529
+		 * @access public
1530
+		 * @param $id string  field id, i.e. the meta key
1531
+		 * @param $args mixed|array
1532
+		 */
1533
+		public function addField($id, $args)
1534
+		{
1535
+			$new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => '');
1536
+			$new_field = array_merge($new_field, $args);
1537
+			$this->_fields[] = $new_field;
1538
+		}
1539
+
1540
+
1541
+		/**
1542
+		 *  Add Text Field to meta box
1543
+		 * @author Ohad Raz
1544
+		 * @since 1.0
1545
+		 * @access public
1546
+		 * @param $id string  field id, i.e. the meta key
1547
+		 * @param $args mixed|array
1548
+		 *    'name' => // field name/label string optional
1549
+		 *    'desc' => // field description, string optional
1550
+		 *    'std' => // default value, string optional
1551
+		 *    'style' =>    // custom style for field, string optional
1552
+		 *    'validate_func' => // validate function, string optional
1553
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1554
+		 */
1555
+		public function addText($id, $args, $repeater = false)
1556
+		{
1557
+			$new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1558
+			$new_field = array_merge($new_field, $args);
1559
+			if (false === $repeater) {
1560
+				$this->_fields[] = $new_field;
1561
+			} else {
1562
+				return $new_field;
1563
+			}
1564
+		}
1565
+
1566
+		/**
1567
+		 *  Add Hidden Field to meta box
1568
+		 * @author Ohad Raz
1569
+		 * @since 0.1.3
1570
+		 * @access public
1571
+		 * @param $id string  field id, i.e. the meta key
1572
+		 * @param $args mixed|array
1573
+		 *    'name' => // field name/label string optional
1574
+		 *    'desc' => // field description, string optional
1575
+		 *    'std' => // default value, string optional
1576
+		 *    'style' =>    // custom style for field, string optional
1577
+		 *    'validate_func' => // validate function, string optional
1578
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1579
+		 */
1580
+		public function addHidden($id, $args, $repeater = false)
1581
+		{
1582
+			$new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1583
+			$new_field = array_merge($new_field, $args);
1584
+			if (false === $repeater) {
1585
+				$this->_fields[] = $new_field;
1586
+			} else {
1587
+				return $new_field;
1588
+			}
1589
+		}
1590
+
1591
+		/**
1592
+		 *  Add Paragraph to meta box
1593
+		 * @author Ohad Raz
1594
+		 * @since 0.1.3
1595
+		 * @access public
1596
+		 * @param $id string  field id, i.e. the meta key
1597
+		 * @param $value  paragraph html
1598
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1599
+		 */
1600
+		public function addParagraph($id, $args, $repeater = false)
1601
+		{
1602
+			$new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => '');
1603
+			$new_field = array_merge($new_field, $args);
1604
+			if (false === $repeater) {
1605
+				$this->_fields[] = $new_field;
1606
+			} else {
1607
+				return $new_field;
1608
+			}
1609
+		}
1610
+
1611
+		/**
1612
+		 *  Add Checkbox Field to meta box
1613
+		 * @author Ohad Raz
1614
+		 * @since 1.0
1615
+		 * @access public
1616
+		 * @param $id string  field id, i.e. the meta key
1617
+		 * @param $args mixed|array
1618
+		 *    'name' => // field name/label string optional
1619
+		 *    'desc' => // field description, string optional
1620
+		 *    'std' => // default value, string optional
1621
+		 *    'validate_func' => // validate function, string optional
1622
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1623
+		 */
1624
+		public function addCheckbox($id, $args, $repeater = false)
1625
+		{
1626
+			$new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory'));
1627
+			$new_field = array_merge($new_field, $args);
1628
+			if (false === $repeater) {
1629
+				$this->_fields[] = $new_field;
1630
+			} else {
1631
+				return $new_field;
1632
+			}
1633
+		}
1634
+
1635
+		/**
1636
+		 *  Add CheckboxList Field to meta box
1637
+		 * @author Ohad Raz
1638
+		 * @since 1.0
1639
+		 * @access public
1640
+		 * @param $id string  field id, i.e. the meta key
1641
+		 * @param $options (array)  array of key => value pairs for select options
1642
+		 * @param $args mixed|array
1643
+		 *    'name' => // field name/label string optional
1644
+		 *    'desc' => // field description, string optional
1645
+		 *    'std' => // default value, string optional
1646
+		 *    'validate_func' => // validate function, string optional
1647
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1648
+		 *
1649
+		 * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false);
1650
+		 *   which means the last param as false to get the values in an array
1651
+		 */
1652
+		public function addCheckboxList($id, $options, $args, $repeater = false)
1653
+		{
1654
+			$new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory'));
1655
+			$new_field = array_merge($new_field, $args);
1656
+			if (false === $repeater) {
1657
+				$this->_fields[] = $new_field;
1658
+			} else {
1659
+				return $new_field;
1660
+			}
1661
+		}
1662
+
1663
+		/**
1664
+		 *  Add Textarea Field to meta box
1665
+		 * @author Ohad Raz
1666
+		 * @since 1.0
1667
+		 * @access public
1668
+		 * @param $id string  field id, i.e. the meta key
1669
+		 * @param $args mixed|array
1670
+		 *    'name' => // field name/label string optional
1671
+		 *    'desc' => // field description, string optional
1672
+		 *    'std' => // default value, string optional
1673
+		 *    'style' =>    // custom style for field, string optional
1674
+		 *    'validate_func' => // validate function, string optional
1675
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1676
+		 */
1677
+		public function addTextarea($id, $args, $repeater = false)
1678
+		{
1679
+			$new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory'));
1680
+			$new_field = array_merge($new_field, $args);
1681
+			if (false === $repeater) {
1682
+				$this->_fields[] = $new_field;
1683
+			} else {
1684
+				return $new_field;
1685
+			}
1686
+		}
1687
+
1688
+		/**
1689
+		 *  Add Select Field to meta box
1690
+		 * @author Ohad Raz
1691
+		 * @since 1.0
1692
+		 * @access public
1693
+		 * @param $id string field id, i.e. the meta key
1694
+		 * @param $options (array)  array of key => value pairs for select options
1695
+		 * @param $args mixed|array
1696
+		 *    'name' => // field name/label string optional
1697
+		 *    'desc' => // field description, string optional
1698
+		 *    'std' => // default value, (array) optional
1699
+		 *    'multiple' => // select multiple values, optional. Default is false.
1700
+		 *    'validate_func' => // validate function, string optional
1701
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1702
+		 */
1703
+		public function addSelect($id, $options, $args, $repeater = false)
1704
+		{
1705
+			$new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options);
1706
+			$new_field = array_merge($new_field, $args);
1707
+			if (false === $repeater) {
1708
+				$this->_fields[] = $new_field;
1709
+			} else {
1710
+				return $new_field;
1711
+			}
1712
+		}
1713
+
1714
+
1715
+		/**
1716
+		 *  Add Radio Field to meta box
1717
+		 * @author Ohad Raz
1718
+		 * @since 1.0
1719
+		 * @access public
1720
+		 * @param $id string field id, i.e. the meta key
1721
+		 * @param $options (array)  array of key => value pairs for radio options
1722
+		 * @param $args mixed|array
1723
+		 *    'name' => // field name/label string optional
1724
+		 *    'desc' => // field description, string optional
1725
+		 *    'std' => // default value, string optional
1726
+		 *    'validate_func' => // validate function, string optional
1727
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1728
+		 */
1729
+		public function addRadio($id, $options, $args, $repeater = false)
1730
+		{
1731
+			$new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options);
1732
+			$new_field = array_merge($new_field, $args);
1733
+			if (false === $repeater) {
1734
+				$this->_fields[] = $new_field;
1735
+			} else {
1736
+				return $new_field;
1737
+			}
1738
+		}
1739
+
1740
+		/**
1741
+		 *  Add Date Field to meta box
1742
+		 * @author Ohad Raz
1743
+		 * @since 1.0
1744
+		 * @access public
1745
+		 * @param $id string  field id, i.e. the meta key
1746
+		 * @param $args mixed|array
1747
+		 *    'name' => // field name/label string optional
1748
+		 *    'desc' => // field description, string optional
1749
+		 *    'std' => // default value, string optional
1750
+		 *    'validate_func' => // validate function, string optional
1751
+		 *    'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'"  See more formats here: http://goo.gl/Wcwxn
1752
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1753
+		 */
1754
+		public function addDate($id, $args, $repeater = false)
1755
+		{
1756
+			$new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory'));
1757
+			$new_field = array_merge($new_field, $args);
1758
+			if (false === $repeater) {
1759
+				$this->_fields[] = $new_field;
1760
+			} else {
1761
+				return $new_field;
1762
+			}
1763
+		}
1764
+
1765
+		/**
1766
+		 *  Add Time Field to meta box
1767
+		 * @author Ohad Raz
1768
+		 * @since 1.0
1769
+		 * @access public
1770
+		 * @param $id string- field id, i.e. the meta key
1771
+		 * @param $args mixed|array
1772
+		 *    'name' => // field name/label string optional
1773
+		 *    'desc' => // field description, string optional
1774
+		 *    'std' => // default value, string optional
1775
+		 *    'validate_func' => // validate function, string optional
1776
+		 *    'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX
1777
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1778
+		 */
1779
+		public function addTime($id, $args, $repeater = false)
1780
+		{
1781
+			$new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory'));
1782
+			$new_field = array_merge($new_field, $args);
1783
+			if (false === $repeater) {
1784
+				$this->_fields[] = $new_field;
1785
+			} else {
1786
+				return $new_field;
1787
+			}
1788
+		}
1789
+
1790
+		/**
1791
+		 *  Add Color Field to meta box
1792
+		 * @author Ohad Raz
1793
+		 * @since 1.0
1794
+		 * @access public
1795
+		 * @param $id string  field id, i.e. the meta key
1796
+		 * @param $args mixed|array
1797
+		 *    'name' => // field name/label string optional
1798
+		 *    'desc' => // field description, string optional
1799
+		 *    'std' => // default value, string optional
1800
+		 *    'validate_func' => // validate function, string optional
1801
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1802
+		 */
1803
+		public function addColor($id, $args, $repeater = false)
1804
+		{
1805
+			$new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory'));
1806
+			$new_field = array_merge($new_field, $args);
1807
+			if (false === $repeater) {
1808
+				$this->_fields[] = $new_field;
1809
+			} else {
1810
+				return $new_field;
1811
+			}
1812
+		}
1813
+
1814
+		/**
1815
+		 *  Add Image Field to meta box
1816
+		 * @author Ohad Raz
1817
+		 * @since 1.0
1818
+		 * @access public
1819
+		 * @param $id string  field id, i.e. the meta key
1820
+		 * @param $args mixed|array
1821
+		 *    'name' => // field name/label string optional
1822
+		 *    'desc' => // field description, string optional
1823
+		 *    'validate_func' => // validate function, string optional
1824
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1825
+		 */
1826
+		public function addImage($id, $args, $repeater = false)
1827
+		{
1828
+			$new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory'));
1829
+			$new_field = array_merge($new_field, $args);
1830
+
1831
+			if (false === $repeater) {
1832
+				$this->_fields[] = $new_field;
1833
+			} else {
1834
+				return $new_field;
1835
+			}
1836
+		}
1837
+
1838
+		/**
1839
+		 *  Add File Field to meta box
1840
+		 * @author Ohad Raz
1841
+		 * @since 1.0
1842
+		 * @access public
1843
+		 * @param $id string  field id, i.e. the meta key
1844
+		 * @param $args mixed|array
1845
+		 *    'name' => // field name/label string optional
1846
+		 *    'desc' => // field description, string optional
1847
+		 *    'validate_func' => // validate function, string optional
1848
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1849
+		 */
1850
+		public function addFile($id, $args, $repeater = false)
1851
+		{
1852
+			$new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory'));
1853
+			$new_field = array_merge($new_field, $args);
1854
+			if (false === $repeater) {
1855
+				$this->_fields[] = $new_field;
1856
+			} else {
1857
+				return $new_field;
1858
+			}
1859
+		}
1860
+
1861
+		/**
1862
+		 *  Add WYSIWYG Field to meta box
1863
+		 * @author Ohad Raz
1864
+		 * @since 1.0
1865
+		 * @access public
1866
+		 * @param $id string  field id, i.e. the meta key
1867
+		 * @param $args mixed|array
1868
+		 *    'name' => // field name/label string optional
1869
+		 *    'desc' => // field description, string optional
1870
+		 *    'std' => // default value, string optional
1871
+		 *    'style' =>    // custom style for field, string optional Default 'width: 300px; height: 400px'
1872
+		 *    'validate_func' => // validate function, string optional
1873
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1874
+		 */
1875
+		public function addWysiwyg($id, $args, $repeater = false)
1876
+		{
1877
+			$new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory'));
1878
+			$new_field = array_merge($new_field, $args);
1879
+			if (false === $repeater) {
1880
+				$this->_fields[] = $new_field;
1881
+			} else {
1882
+				return $new_field;
1883
+			}
1884
+		}
1885
+
1886
+		/**
1887
+		 *  Add Taxonomy Field to meta box
1888
+		 * @author Ohad Raz
1889
+		 * @since 1.0
1890
+		 * @access public
1891
+		 * @param $id string  field id, i.e. the meta key
1892
+		 * @param $options mixed|array options of taxonomy field
1893
+		 *    'taxonomy' =>    // taxonomy name can be category,post_tag or any custom taxonomy default is category
1894
+		 * 'type' =>  // how to show taxonomy? 'select' (default) or 'checkbox_list'
1895
+		 * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false)
1896
+		 * @param $args mixed|array
1897
+		 *    'name' => // field name/label string optional
1898
+		 *    'desc' => // field description, string optional
1899
+		 *    'std' => // default value, string optional
1900
+		 *    'validate_func' => // validate function, string optional
1901
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1902
+		 */
1903
+		public function addTaxonomy($id, $options, $args, $repeater = false)
1904
+		{
1905
+			$q = array('hide_empty' => 0);
1906
+			$tax = 'category';
1907
+			$type = 'select';
1908
+			$temp = array($tax, $type, $q);
1909
+			$options = array_merge($temp, $options);
1910
+			$new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options);
1911
+			$new_field = array_merge($new_field, $args);
1912
+			if (false === $repeater) {
1913
+				$this->_fields[] = $new_field;
1914
+			} else {
1915
+				return $new_field;
1916
+			}
1917
+		}
1918
+
1919
+		/**
1920
+		 *  Add posts Field to meta box
1921
+		 * @author Ohad Raz
1922
+		 * @since 1.0
1923
+		 * @access public
1924
+		 * @param $id string  field id, i.e. the meta key
1925
+		 * @param $options mixed|array options of taxonomy field
1926
+		 *    'post_type' =>    // post type name, 'post' (default) 'page' or any custom post type
1927
+		 * 'type' =>  // how to show posts? 'select' (default) or 'checkbox_list'
1928
+		 * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1)
1929
+		 * @param $args mixed|array
1930
+		 *    'name' => // field name/label string optional
1931
+		 *    'desc' => // field description, string optional
1932
+		 *    'std' => // default value, string optional
1933
+		 *    'validate_func' => // validate function, string optional
1934
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1935
+		 */
1936
+		public function addPosts($id, $options, $args, $repeater = false)
1937
+		{
1938
+			$q = array('posts_per_page' => -1);
1939
+			$temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q);
1940
+			$options = array_merge($temp, $options);
1941
+			$new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options);
1942
+			$new_field = array_merge($new_field, $args);
1943
+			if (false === $repeater) {
1944
+				$this->_fields[] = $new_field;
1945
+			} else {
1946
+				return $new_field;
1947
+			}
1948
+		}
1949
+
1950
+		/**
1951
+		 *  Add repeater Field Block to meta box
1952
+		 * @author Ohad Raz
1953
+		 * @since 1.0
1954
+		 * @access public
1955
+		 * @param $id string  field id, i.e. the meta key
1956
+		 * @param $args mixed|array
1957
+		 *    'name' => // field name/label string optional
1958
+		 *    'desc' => // field description, string optional
1959
+		 *    'std' => // default value, string optional
1960
+		 *    'style' =>    // custom style for field, string optional
1961
+		 *    'validate_func' => // validate function, string optional
1962
+		 *    'fields' => //fields to repeater
1963
+		 */
1964
+		public function addRepeaterBlock($id, $args)
1965
+		{
1966
+			$new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false);
1967
+			$new_field = array_merge($new_field, $args);
1968
+			$this->_fields[] = $new_field;
1969
+		}
1970
+
1971
+
1972
+		/**
1973
+		 * Finish Declaration of Meta Box
1974
+		 * @author Ohad Raz
1975
+		 * @since 1.0
1976
+		 * @access public
1977
+		 */
1978
+		public function Finish()
1979
+		{
1980
+			$this->add_missed_values();
1981
+			$this->check_field_upload();
1982
+			$this->check_field_color();
1983
+			$this->check_field_date();
1984
+			$this->check_field_time();
1985
+		}
1986
+
1987
+		/**
1988
+		 * Helper function to check for empty arrays
1989
+		 * @author Ohad Raz
1990
+		 * @since 1.0
1991
+		 * @access public
1992
+		 * @param $args mixed|array
1993
+		 */
1994
+		public function is_array_empty($array)
1995
+		{
1996
+			if (!is_array($array))
1997
+				return true;
1998
+
1999
+			foreach ($array as $a) {
2000
+				if (is_array($a)) {
2001
+					foreach ($a as $sub_a) {
2002
+						if (!empty($sub_a) && $sub_a != '')
2003
+							return false;
2004
+					}
2005
+				} else {
2006
+					if (!empty($a) && $a != '')
2007
+						return false;
2008
+				}
2009
+			}
2010
+			return true;
2011
+		}
2012
+
2013
+
2014
+		//get term meta field
2015
+		public function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2016
+		{
2017
+
2018
+			if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2019
+				$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2020
+				$post_type = $taxObject->object_type[0];
2021
+			}
2022
+
2023
+			if($post_type=='post'){$post_type='';}
2024
+			if($post_type){$post_type = $post_type.'_';}
2025
+
2026
+			$t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2027
+
2028
+			$m = get_option('tax_meta_' . $post_type  . $t_id);
2029
+			if (isset($m[$key])) {
2030
+				return $m[$key];
2031
+			} else {
2032
+				return '';
2033
+			}
2034
+		}
2035
+
2036
+		//delete meta
2037
+		public function delete_tax_meta($term_id, $key, $post_type = '')
2038
+		{
2039
+
2040
+			if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2041
+				$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2042
+				$post_type = $taxObject->object_type[0];
2043
+			}
2044
+
2045
+			if($post_type=='post'){$post_type='';}
2046
+			if($post_type){$post_type = $post_type.'_';}
2047
+
2048
+			$m = get_option('tax_meta_' . $post_type  . $term_id);
2049
+
2050
+			if (isset($m[$key])) {
2051
+				unset($m[$key]);
2052
+			}
2053
+			update_option('tax_meta_' . $post_type  . $term_id, $m);
2054
+		}
2055
+
2056
+		//update meta
2057
+		public function update_tax_meta($term_id, $key, $value, $post_type = '')
2058
+		{
2059
+
2060
+			if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2061
+				$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2062
+				$post_type = $taxObject->object_type[0];
2063
+			}
2064
+
2065
+			if($post_type=='post'){$post_type='';}
2066
+			if($post_type){$post_type = $post_type.'_';}
2067
+
2068
+			$m = get_option('tax_meta_' . $post_type  . $term_id);
2069
+
2070
+			$m[$key] = $value;
2071
+			update_option('tax_meta_' . $post_type  . $term_id, $m);
2072
+
2073
+			/**
2074
+			 * Called after the tax meta is updated.
2075
+			 *
2076
+			 * Used to update things after a GD category is saved.
2077
+			 *
2078
+			 * @since 1.0.0
2079
+			 * @param bool $false False.
2080
+			 * @param bool $true True.
2081
+			 * @param int $term_id The term id being updated.
2082
+			 * @param string $post_type The post type of the cat being updated.
2083
+			 */
2084
+			do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2085
+		}
2086
+
2087
+
2088
+	} // End Class
2089 2089
 
2090 2090
 endif; // End Check Class Exists
2091 2091
 
@@ -2095,67 +2095,67 @@  discard block
 block discarded – undo
2095 2095
 
2096 2096
 //get term meta field
2097 2097
 if (!function_exists('get_tax_meta')) {
2098
-    function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2099
-    {
2100
-
2101
-        if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2102
-            $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2103
-            $post_type = $taxObject->object_type[0];
2104
-        }
2105
-
2106
-        if($post_type=='post'){$post_type='';}
2107
-        if($post_type){$post_type = $post_type.'_';}
2108
-
2109
-        $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2110
-
2111
-        $m = get_option('tax_meta_' . $post_type  . $t_id);
2112
-        if (isset($m[$key])) {
2113
-            return $m[$key];
2114
-        } else {
2115
-            return '';
2116
-        }
2117
-    }
2098
+	function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2099
+	{
2100
+
2101
+		if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2102
+			$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2103
+			$post_type = $taxObject->object_type[0];
2104
+		}
2105
+
2106
+		if($post_type=='post'){$post_type='';}
2107
+		if($post_type){$post_type = $post_type.'_';}
2108
+
2109
+		$t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2110
+
2111
+		$m = get_option('tax_meta_' . $post_type  . $t_id);
2112
+		if (isset($m[$key])) {
2113
+			return $m[$key];
2114
+		} else {
2115
+			return '';
2116
+		}
2117
+	}
2118 2118
 }
2119 2119
 
2120 2120
 //delete meta
2121 2121
 if (!function_exists('delete_tax_meta')) {
2122
-    function delete_tax_meta($term_id, $key)
2123
-    {
2122
+	function delete_tax_meta($term_id, $key)
2123
+	{
2124 2124
 
2125
-        $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2126
-        $post_type = $taxObject->object_type[0];
2125
+		$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2126
+		$post_type = $taxObject->object_type[0];
2127 2127
 
2128
-        if($post_type=='post'){$post_type='';}
2129
-        if($post_type){$post_type = $post_type.'_';}
2128
+		if($post_type=='post'){$post_type='';}
2129
+		if($post_type){$post_type = $post_type.'_';}
2130 2130
 
2131
-        $m = get_option('tax_meta_' . $post_type . $term_id);
2131
+		$m = get_option('tax_meta_' . $post_type . $term_id);
2132 2132
 
2133
-        if (isset($m[$key])) {
2134
-            unset($m[$key]);
2135
-        }
2136
-        update_option('tax_meta_' . $post_type  . $term_id, $m);
2137
-    }
2133
+		if (isset($m[$key])) {
2134
+			unset($m[$key]);
2135
+		}
2136
+		update_option('tax_meta_' . $post_type  . $term_id, $m);
2137
+	}
2138 2138
 }
2139 2139
 
2140 2140
 //update meta
2141 2141
 if (!function_exists('update_tax_meta')) {
2142
-    function update_tax_meta($term_id, $key, $value, $post_type = '')
2143
-    {
2142
+	function update_tax_meta($term_id, $key, $value, $post_type = '')
2143
+	{
2144 2144
 
2145
-        if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2146
-            $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2147
-            $post_type = $taxObject->object_type[0];
2148
-        }
2145
+		if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2146
+			$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2147
+			$post_type = $taxObject->object_type[0];
2148
+		}
2149 2149
 
2150
-        if($post_type=='post'){$post_type='';}
2151
-        if($post_type){$post_type = $post_type.'_';}
2150
+		if($post_type=='post'){$post_type='';}
2151
+		if($post_type){$post_type = $post_type.'_';}
2152 2152
 
2153
-        $m = get_option('tax_meta_' . $post_type  . $term_id);
2153
+		$m = get_option('tax_meta_' . $post_type  . $term_id);
2154 2154
 
2155
-        $m[$key] = $value;
2156
-        update_option('tax_meta_' . $post_type . $term_id, $m);
2155
+		$m[$key] = $value;
2156
+		update_option('tax_meta_' . $post_type . $term_id, $m);
2157 2157
 
2158
-        /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */
2159
-        do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2160
-    }
2158
+		/** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */
2159
+		do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2160
+	}
2161 2161
 }
2162 2162
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +106 added lines, -69 removed lines patch added patch discarded remove patch
@@ -102,8 +102,9 @@  discard block
 block discarded – undo
102 102
         {
103 103
 
104 104
             // If we are not in admin area exit.
105
-            if (!is_admin())
106
-                return;
105
+            if (!is_admin()) {
106
+                            return;
107
+            }
107 108
 
108 109
             // Assign meta box values to local variables and add it's missed values.
109 110
             $this->_meta_box = $meta_box;
@@ -111,15 +112,15 @@  discard block
 block discarded – undo
111 112
             $this->_fields = &$this->_meta_box['fields'];
112 113
             $this->_Local_images = (isset($meta_box['local_images'])) ? true : false;
113 114
             $this->add_missed_values();
114
-            if (isset($meta_box['use_with_theme']))
115
-                if ($meta_box['use_with_theme'] === true) {
115
+            if (isset($meta_box['use_with_theme'])) {
116
+                            if ($meta_box['use_with_theme'] === true) {
116 117
                     $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
118
+            }
117 119
                 } elseif ($meta_box['use_with_theme'] === false) {
118 120
                     $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119 121
                 } else {
120 122
                     $this->SelfPath = $meta_box['use_with_theme'];
121
-                }
122
-            else {
123
+                } else {
123 124
                 $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
124 125
             }
125 126
 
@@ -190,8 +191,9 @@  discard block
 block discarded – undo
190 191
         {
191 192
 
192 193
             // Check if the field is an image or file. If not, return.
193
-            if (!$this->has_field('image') && !$this->has_field('file'))
194
-                return;
194
+            if (!$this->has_field('image') && !$this->has_field('file')) {
195
+                            return;
196
+            }
195 197
 
196 198
 
197 199
             add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100);
@@ -235,8 +237,9 @@  discard block
 block discarded – undo
235 237
         {
236 238
 
237 239
             // If post variables are empty, return.
238
-            if (!isset($_POST['at-insert']) || empty($_POST['attachments']))
239
-                return;
240
+            if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) {
241
+                            return;
242
+            }
240 243
 
241 244
             // Security Check
242 245
             check_admin_referer('media-form');
@@ -256,8 +259,9 @@  discard block
 block discarded – undo
256 259
                 $attachment = stripslashes_deep($attachment);
257 260
 
258 261
                 // If not selected or url is empty, continue in loop.
259
-                if (empty($attachment['selected']) || empty($attachment['url']))
260
-                    continue;
262
+                if (empty($attachment['selected']) || empty($attachment['url'])) {
263
+                                    continue;
264
+                }
261 265
 
262 266
                 $li = "<li id='item_{$attachment_id}'>";
263 267
                 $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
@@ -308,13 +312,15 @@  discard block
 block discarded – undo
308 312
 
309 313
 
310 314
             // If data is not set, die.
311
-            if (!isset($_POST['data']))
312
-                die();
315
+            if (!isset($_POST['data'])) {
316
+                            die();
317
+            }
313 318
 
314 319
             list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']);
315 320
 
316
-            if (!wp_verify_nonce($nonce, 'at_ajax_delete'))
317
-                die('1');
321
+            if (!wp_verify_nonce($nonce, 'at_ajax_delete')) {
322
+                            die('1');
323
+            }
318 324
 
319 325
             $this->delete_tax_meta($term_id, $key, $attach_id);
320 326
 
@@ -336,8 +342,9 @@  discard block
 block discarded – undo
336 342
             $ok = false;
337 343
             if (strpos($field_id, '[') === false) {
338 344
                 check_admin_referer("at-delete-mupload_" . urldecode($field_id));
339
-                if ($term_id > 0)
340
-                    $this->delete_tax_meta($term_id, $field_id);
345
+                if ($term_id > 0) {
346
+                                    $this->delete_tax_meta($term_id, $field_id);
347
+                }
341 348
                 //$ok = wp_delete_attachment( $attachment_id );
342 349
                 $ok = 1;
343 350
             } else {
@@ -349,8 +356,9 @@  discard block
 block discarded – undo
349 356
                 $saved = $this->get_tax_meta($term_id, $f[0], true);
350 357
                 if (isset($saved[$f[1]][$f[2]])) {
351 358
                     unset($saved[$f[1]][$f[2]]);
352
-                    if ($term_id > 0)
353
-                        update_post_meta($term_id, $f[0], $saved);
359
+                    if ($term_id > 0) {
360
+                                            update_post_meta($term_id, $f[0], $saved);
361
+                    }
354 362
                     //$ok = wp_delete_attachment( $attachment_id );
355 363
                     $ok = 1;
356 364
                 }
@@ -375,13 +383,15 @@  discard block
 block discarded – undo
375 383
         public function reorder_images()
376 384
         {
377 385
 
378
-            if (!isset($_POST['data']))
379
-                die();
386
+            if (!isset($_POST['data'])) {
387
+                            die();
388
+            }
380 389
 
381 390
             list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']);
382 391
 
383
-            if (!wp_verify_nonce($nonce, 'at_ajax_reorder'))
384
-                die('1');
392
+            if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) {
393
+                            die('1');
394
+            }
385 395
 
386 396
             parse_str($order, $items);
387 397
             $items = $items['item'];
@@ -513,8 +523,9 @@  discard block
 block discarded – undo
513 523
             foreach ($this->_fields as $field) {
514 524
                 $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']);
515 525
                 $meta = ($meta !== '') ? $meta : $field['std'];
516
-                if ('image' != $field['type'] && $field['type'] != 'repeater')
517
-                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
526
+                if ('image' != $field['type'] && $field['type'] != 'repeater') {
527
+                                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
528
+                }
518 529
 
519 530
                 if ($field['validate_func']) {
520 531
                     echo '<tr class="form-field form-required ' . $field['style'] . '">';
@@ -560,8 +571,9 @@  discard block
 block discarded – undo
560 571
                         $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
561 572
                         $m = $me[$f['id']];
562 573
                         $m = ($m !== '') ? $m : $f['std'];
563
-                        if ('image' != $f['type'] && $f['type'] != 'repeater')
564
-                            $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
574
+                        if ('image' != $f['type'] && $f['type'] != 'repeater') {
575
+                                                    $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
576
+                        }
565 577
                         //set new id for field in array format
566 578
                         $f['id'] = $id;
567 579
                         if (!$field['inline']) {
@@ -802,8 +814,9 @@  discard block
 block discarded – undo
802 814
         public function show_field_select($field, $meta)
803 815
         {
804 816
 
805
-            if (!is_array($meta))
806
-                $meta = (array)$meta;
817
+            if (!is_array($meta)) {
818
+                            $meta = (array)$meta;
819
+            }
807 820
 
808 821
             $this->show_field_begin($field, $meta);
809 822
             echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
@@ -826,8 +839,9 @@  discard block
 block discarded – undo
826 839
         public function show_field_radio($field, $meta)
827 840
         {
828 841
 
829
-            if (!is_array($meta))
830
-                $meta = (array)$meta;
842
+            if (!is_array($meta)) {
843
+                            $meta = (array)$meta;
844
+            }
831 845
 
832 846
             $this->show_field_begin($field, $meta);
833 847
             foreach ($field['options'] as $key => $value) {
@@ -889,8 +903,9 @@  discard block
 block discarded – undo
889 903
 
890 904
             global $post;
891 905
 
892
-            if (!is_array($meta))
893
-                $meta = (array)$meta;
906
+            if (!is_array($meta)) {
907
+                            $meta = (array)$meta;
908
+            }
894 909
 
895 910
             $this->show_field_begin($field, $meta);
896 911
             echo "{$field['desc']}<br />";
@@ -934,8 +949,9 @@  discard block
 block discarded – undo
934 949
             $this->show_field_begin($field, $meta);
935 950
             $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
936 951
             if (is_array($meta)) {
937
-                if (isset($meta[0]) && is_array($meta[0]))
938
-                    $meta = $meta[0];
952
+                if (isset($meta[0]) && is_array($meta[0])) {
953
+                                    $meta = $meta[0];
954
+                }
939 955
             }
940 956
 
941 957
             $uploads = wp_upload_dir();
@@ -947,8 +963,9 @@  discard block
 block discarded – undo
947 963
                 //print_r($uploads);
948 964
                 //print_r($file_info);
949 965
 
950
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
951
-                    $sub_dir = $file_info['dirname'];
966
+                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
967
+                                    $sub_dir = $file_info['dirname'];
968
+                }
952 969
 
953 970
                 $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs	
954 971
                 $uploads_baseurl = $uploads['baseurl'];
@@ -988,8 +1005,9 @@  discard block
 block discarded – undo
988 1005
         public function show_field_color($field, $meta)
989 1006
         {
990 1007
 
991
-            if (empty($meta))
992
-                $meta = '#';
1008
+            if (empty($meta)) {
1009
+                            $meta = '#';
1010
+            }
993 1011
 
994 1012
             $this->show_field_begin($field, $meta);
995 1013
 
@@ -1012,8 +1030,9 @@  discard block
 block discarded – undo
1012 1030
         public function show_field_checkbox_list($field, $meta)
1013 1031
         {
1014 1032
 
1015
-            if (!is_array($meta))
1016
-                $meta = (array)$meta;
1033
+            if (!is_array($meta)) {
1034
+                            $meta = (array)$meta;
1035
+            }
1017 1036
 
1018 1037
             $this->show_field_begin($field, $meta);
1019 1038
 
@@ -1073,7 +1092,9 @@  discard block
 block discarded – undo
1073 1092
         {
1074 1093
             global $post;
1075 1094
 
1076
-            if (!is_array($meta)) $meta = (array)$meta;
1095
+            if (!is_array($meta)) {
1096
+            	$meta = (array)$meta;
1097
+            }
1077 1098
             $this->show_field_begin($field, $meta);
1078 1099
             $options = $field['options'];
1079 1100
             $posts = get_posts($options['args']);
@@ -1111,7 +1132,9 @@  discard block
 block discarded – undo
1111 1132
         {
1112 1133
             global $post;
1113 1134
 
1114
-            if (!is_array($meta)) $meta = (array)$meta;
1135
+            if (!is_array($meta)) {
1136
+            	$meta = (array)$meta;
1137
+            }
1115 1138
             $this->show_field_begin($field, $meta);
1116 1139
             $options = $field['options'];
1117 1140
             $terms = get_terms($options['taxonomy'], $options['args']);
@@ -1145,17 +1168,20 @@  discard block
 block discarded – undo
1145 1168
         {
1146 1169
 
1147 1170
             $taxnow = '';
1148
-            if (isset($_POST['taxonomy']))
1149
-                $taxnow = $_POST['taxonomy'];
1171
+            if (isset($_POST['taxonomy'])) {
1172
+                            $taxnow = $_POST['taxonomy'];
1173
+            }
1150 1174
 
1151 1175
             if (!isset($term_id)                                                        // Check Revision
1152 1176
                 || (!in_array($taxnow, $this->_meta_box['pages']))                            // Check if current taxonomy type is supported.
1153 1177
                 || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce'))        // Check nonce - Security
1154 1178
                 || (!current_user_can('manage_categories'))
1155
-            )                                // Check permission
1179
+            ) {
1180
+            	// Check permission
1156 1181
             {
1157 1182
                 return $term_id;
1158 1183
             }
1184
+            }
1159 1185
 
1160 1186
 
1161 1187
             foreach ($this->_fields as $field) {
@@ -1249,8 +1275,9 @@  discard block
 block discarded – undo
1249 1275
         {
1250 1276
             $name = $field['id'];
1251 1277
             $this->delete_tax_meta($term_id, $name);
1252
-            if ($new === '' || $new === array())
1253
-                return;
1278
+            if ($new === '' || $new === array()) {
1279
+                            return;
1280
+            }
1254 1281
 
1255 1282
             $this->update_tax_meta($term_id, $name, $new);
1256 1283
         }
@@ -1270,8 +1297,9 @@  discard block
 block discarded – undo
1270 1297
             $name = $field['id'];
1271 1298
 
1272 1299
             $this->delete_tax_meta($term_id, $name);
1273
-            if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '')
1274
-                return;
1300
+            if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') {
1301
+                            return;
1302
+            }
1275 1303
 
1276 1304
             $this->update_tax_meta($term_id, $name, $new);
1277 1305
         }
@@ -1318,8 +1346,9 @@  discard block
 block discarded – undo
1318 1346
                                 break;
1319 1347
                         }
1320 1348
                     }
1321
-                    if (!$this->is_array_empty($n))
1322
-                        $temp[] = $n;
1349
+                    if (!$this->is_array_empty($n)) {
1350
+                                            $temp[] = $n;
1351
+                    }
1323 1352
                 }
1324 1353
                 if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) {
1325 1354
                     $this->update_tax_meta($term_id, $field['id'], $temp);
@@ -1347,14 +1376,16 @@  discard block
 block discarded – undo
1347 1376
         {
1348 1377
 
1349 1378
             $name = $field['id'];
1350
-            if (empty($_FILES[$name]))
1351
-                return;
1379
+            if (empty($_FILES[$name])) {
1380
+                            return;
1381
+            }
1352 1382
             $this->fix_file_array($_FILES[$name]);
1353 1383
             foreach ($_FILES[$name] as $position => $fileitem) {
1354 1384
 
1355 1385
                 $file = wp_handle_upload($fileitem, array('test_form' => false));
1356
-                if (empty($file['file']))
1357
-                    continue;
1386
+                if (empty($file['file'])) {
1387
+                                    continue;
1388
+                }
1358 1389
                 $filename = $file['file'];
1359 1390
 
1360 1391
                 $attachment = array(
@@ -1392,14 +1423,16 @@  discard block
 block discarded – undo
1392 1423
         {
1393 1424
 
1394 1425
             $name = $field['id'];
1395
-            if (empty($_FILES[$name]))
1396
-                return;
1426
+            if (empty($_FILES[$name])) {
1427
+                            return;
1428
+            }
1397 1429
             $this->fix_file_array($_FILES[$name]);
1398 1430
             foreach ($_FILES[$name] as $position => $fileitem) {
1399 1431
 
1400 1432
                 $file = wp_handle_upload($fileitem, array('test_form' => false));
1401
-                if (empty($file['file']))
1402
-                    continue;
1433
+                if (empty($file['file'])) {
1434
+                                    continue;
1435
+                }
1403 1436
                 $filename = $file['file'];
1404 1437
 
1405 1438
                 $attachment = array(
@@ -1454,8 +1487,9 @@  discard block
 block discarded – undo
1454 1487
         {
1455 1488
             if(is_array($this->_fields)) {
1456 1489
                 foreach ($this->_fields as $field) {
1457
-                    if ($type == $field['type'])
1458
-                        return true;
1490
+                    if ($type == $field['type']) {
1491
+                                            return true;
1492
+                    }
1459 1493
                 }
1460 1494
             }
1461 1495
             return false;
@@ -1993,18 +2027,21 @@  discard block
 block discarded – undo
1993 2027
          */
1994 2028
         public function is_array_empty($array)
1995 2029
         {
1996
-            if (!is_array($array))
1997
-                return true;
2030
+            if (!is_array($array)) {
2031
+                            return true;
2032
+            }
1998 2033
 
1999 2034
             foreach ($array as $a) {
2000 2035
                 if (is_array($a)) {
2001 2036
                     foreach ($a as $sub_a) {
2002
-                        if (!empty($sub_a) && $sub_a != '')
2003
-                            return false;
2037
+                        if (!empty($sub_a) && $sub_a != '') {
2038
+                                                    return false;
2039
+                        }
2004 2040
                     }
2005 2041
                 } else {
2006
-                    if (!empty($a) && $a != '')
2007
-                        return false;
2042
+                    if (!empty($a) && $a != '') {
2043
+                                            return false;
2044
+                    }
2008 2045
                 }
2009 2046
             }
2010 2047
             return true;
Please login to merge, or discard this patch.
geodirectory-functions/compatibility/X.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@
 block discarded – undo
113 113
  * @since 1.0.0
114 114
  * @package GeoDirectory
115 115
  * @param array $classes Class array.
116
- * @return array Modified class array.
116
+ * @return string[] Modified class array.
117 117
  */
118 118
 function geodir_x_body_class($classes)
119 119
 {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             // 8. Get shop title.
308 308
             //
309 309
 
310
-            GLOBAL $post,$wp;
310
+            GLOBAL $post, $wp;
311 311
 
312 312
             if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) {
313 313
                 geodir_breadcrumb();
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 
316 316
                 $stack = x_get_stack();
317 317
                 $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1
318
-                $home_text = '<span class="home"><i class="x-icon-home"></i></span>';               // 2
319
-                $home_link = home_url();                                                            // 3
320
-                $current_before = '<span class="current">';                                              // 4
321
-                $current_after = '</span>';                                                             // 5
322
-                $page_title = get_the_title();                                                       // 6
323
-                $blog_title = get_the_title(get_option('page_for_posts', true));                 // 7
324
-                $shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8
318
+                $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2
319
+                $home_link = home_url(); // 3
320
+                $current_before = '<span class="current">'; // 4
321
+                $current_after = '</span>'; // 5
322
+                $page_title = get_the_title(); // 6
323
+                $blog_title = get_the_title(get_option('page_for_posts', true)); // 7
324
+                $shop_title = get_theme_mod('x_' . $stack . '_shop_title'); // 8
325 325
 
326 326
                 if (function_exists('woocommerce_get_page_id')) {
327 327
                     $shop_url = x_get_shop_link();
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -19,60 +19,60 @@  discard block
 block discarded – undo
19 19
 function geodir_x_action_calls()
20 20
 {
21 21
 
22
-    /* ACTIONS
22
+	/* ACTIONS
23 23
     ****************************************************************************************/
24 24
 
25
-    // Add body class for styling purposes
26
-    add_filter('body_class', 'geodir_x_body_class');
25
+	// Add body class for styling purposes
26
+	add_filter('body_class', 'geodir_x_body_class');
27 27
 
28
-    // HOME TOP SIDEBAR
29
-    //remove_action( 'geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
30
-    //remove_action( 'geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
31
-    //add_action( 'geodir_wrapper_open', 'geodir_x_home_sidebar', 5 );
32
-    add_action('geodir_before_search_form', 'geodir_x_search_container_open');
33
-    add_action('geodir_after_search_form', 'geodir_x_search_container_close');
28
+	// HOME TOP SIDEBAR
29
+	//remove_action( 'geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
30
+	//remove_action( 'geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
31
+	//add_action( 'geodir_wrapper_open', 'geodir_x_home_sidebar', 5 );
32
+	add_action('geodir_before_search_form', 'geodir_x_search_container_open');
33
+	add_action('geodir_after_search_form', 'geodir_x_search_container_close');
34 34
 
35
-    // WRAPPER OPEN ACTIONS
36
-    remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10);
37
-    add_action('geodir_wrapper_open', 'geodir_x_action_wrapper_open', 9);
35
+	// WRAPPER OPEN ACTIONS
36
+	remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10);
37
+	add_action('geodir_wrapper_open', 'geodir_x_action_wrapper_open', 9);
38 38
 
39
-    // WRAPPER CLOSE ACTIONS
40
-    remove_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10);
41
-    add_action('geodir_wrapper_close', 'geodir_x_action_wrapper_close', 11);
39
+	// WRAPPER CLOSE ACTIONS
40
+	remove_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10);
41
+	add_action('geodir_wrapper_close', 'geodir_x_action_wrapper_close', 11);
42 42
 
43
-    // WRAPPER CONTENT OPEN ACTIONS
44
-    remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10);
45
-    add_action('geodir_wrapper_content_open', 'geodir_x_action_wrapper_content_open', 9, 3);
43
+	// WRAPPER CONTENT OPEN ACTIONS
44
+	remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10);
45
+	add_action('geodir_wrapper_content_open', 'geodir_x_action_wrapper_content_open', 9, 3);
46 46
 
47
-    // WRAPPER CONTENT CLOSE ACTIONS
48
-    remove_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10);
49
-    add_action('geodir_wrapper_content_close', 'geodir_x_action_wrapper_content_close', 11);
47
+	// WRAPPER CONTENT CLOSE ACTIONS
48
+	remove_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10);
49
+	add_action('geodir_wrapper_content_close', 'geodir_x_action_wrapper_content_close', 11);
50 50
 
51
-    // SIDEBAR RIGHT OPEN ACTIONS
52
-    remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10);
53
-    add_action('geodir_sidebar_right_open', 'geodir_x_action_sidebar_right_open', 10, 4);
51
+	// SIDEBAR RIGHT OPEN ACTIONS
52
+	remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10);
53
+	add_action('geodir_sidebar_right_open', 'geodir_x_action_sidebar_right_open', 10, 4);
54 54
 
55
-    // SIDEBAR RIGHT CLOSE ACTIONS
56
-    remove_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10);
57
-    add_action('geodir_sidebar_right_close', 'geodir_x_action_sidebar_right_close', 10, 1);
55
+	// SIDEBAR RIGHT CLOSE ACTIONS
56
+	remove_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10);
57
+	add_action('geodir_sidebar_right_close', 'geodir_x_action_sidebar_right_close', 10, 1);
58 58
 
59
-    // REMOVE BREADCRUMBS
60
-    remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20);
61
-    remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
62
-    remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20);
63
-    remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20);
64
-    remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20);
65
-    remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20);
59
+	// REMOVE BREADCRUMBS
60
+	remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20);
61
+	remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
62
+	remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20);
63
+	remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20);
64
+	remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20);
65
+	remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20);
66 66
 
67
-    // make top section wide
68
-    remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
69
-    remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
70
-    remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10);
71
-    remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10);
72
-    remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10);
73
-    remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10);
67
+	// make top section wide
68
+	remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
69
+	remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
70
+	remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10);
71
+	remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10);
72
+	remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10);
73
+	remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10);
74 74
 
75
-    add_action('geodir_wrapper_open', 'gd_X_compat_add_top_section_back', 5);
75
+	add_action('geodir_wrapper_open', 'gd_X_compat_add_top_section_back', 5);
76 76
 
77 77
 
78 78
 } // Close geodir_x_action_calls
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 function gd_X_compat_add_top_section_back()
90 90
 {
91 91
 
92
-    if (is_page_geodir_home() || geodir_is_page('location')) {
93
-        geodir_action_geodir_sidebar_home_top();
94
-    } elseif (geodir_is_page('listing')) {
95
-        geodir_action_geodir_sidebar_listings_top();
96
-    } elseif (geodir_is_page('detail')) {
97
-        geodir_action_geodir_sidebar_detail_top();
98
-    } elseif (geodir_is_page('search')) {
99
-        geodir_action_geodir_sidebar_search_top();
100
-    } elseif (geodir_is_page('author')) {
101
-        geodir_action_geodir_sidebar_author_top();
102
-    }
92
+	if (is_page_geodir_home() || geodir_is_page('location')) {
93
+		geodir_action_geodir_sidebar_home_top();
94
+	} elseif (geodir_is_page('listing')) {
95
+		geodir_action_geodir_sidebar_listings_top();
96
+	} elseif (geodir_is_page('detail')) {
97
+		geodir_action_geodir_sidebar_detail_top();
98
+	} elseif (geodir_is_page('search')) {
99
+		geodir_action_geodir_sidebar_search_top();
100
+	} elseif (geodir_is_page('author')) {
101
+		geodir_action_geodir_sidebar_author_top();
102
+	}
103 103
 
104 104
 
105 105
 }
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function geodir_x_body_class($classes)
119 119
 {
120
-    $classes[] = 'geodir-x';
121
-    return $classes;
120
+	$classes[] = 'geodir-x';
121
+	return $classes;
122 122
 }
123 123
 
124 124
 /**
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
  */
131 131
 function geodir_x_home_sidebar()
132 132
 {
133
-    //if ( geodir_is_geodir_page() ) {
134
-    global $wp;
135
-    if ($wp->query_vars['page_id'] == geodir_location_page_id() || is_home() && !geodir_is_page('login')) {
136
-        echo '<div class="x-main full">';
137
-        dynamic_sidebar('geodir_home_top');
138
-        echo '</div>';
139
-    }
140
-    //}
133
+	//if ( geodir_is_geodir_page() ) {
134
+	global $wp;
135
+	if ($wp->query_vars['page_id'] == geodir_location_page_id() || is_home() && !geodir_is_page('login')) {
136
+		echo '<div class="x-main full">';
137
+		dynamic_sidebar('geodir_home_top');
138
+		echo '</div>';
139
+	}
140
+	//}
141 141
 }
142 142
 
143 143
 /**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function geodir_x_search_container_open()
150 150
 {
151
-    echo '<div class="x-container-fluid x-container max">';
151
+	echo '<div class="x-container-fluid x-container max">';
152 152
 }
153 153
 
154 154
 /**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
  */
160 160
 function geodir_x_search_container_close()
161 161
 {
162
-    echo '</div>';
162
+	echo '</div>';
163 163
 }
164 164
 
165 165
 /**
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function geodir_x_action_wrapper_open()
172 172
 {
173
-    global $stack;
174
-    if ($stack == 'integrity') {
175
-        echo '<div class="x-container-fluid x-container max width offset">';
176
-    } elseif ($stack == 'renew') {
177
-        echo '<div class="x-container-fluid x-container max width offset cf">';
178
-    } elseif ($stack == 'icon') {
179
-        echo '<div class="x-main full" role="main">';
180
-    } elseif ($stack == 'ethos') {
181
-        echo '<div class="x-container-fluid x-container max width main"><div class="offset cf">';
182
-    }
173
+	global $stack;
174
+	if ($stack == 'integrity') {
175
+		echo '<div class="x-container-fluid x-container max width offset">';
176
+	} elseif ($stack == 'renew') {
177
+		echo '<div class="x-container-fluid x-container max width offset cf">';
178
+	} elseif ($stack == 'icon') {
179
+		echo '<div class="x-main full" role="main">';
180
+	} elseif ($stack == 'ethos') {
181
+		echo '<div class="x-container-fluid x-container max width main"><div class="offset cf">';
182
+	}
183 183
 }
184 184
 
185 185
 /**
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
  */
191 191
 function geodir_x_action_wrapper_close()
192 192
 {
193
-    global $stack;
194
-    if ($stack == 'ethos') {
195
-        echo '</div></div>';
196
-    } else {
197
-        echo '</div>';
198
-    }
193
+	global $stack;
194
+	if ($stack == 'ethos') {
195
+		echo '</div></div>';
196
+	} else {
197
+		echo '</div>';
198
+	}
199 199
 }
200 200
 
201 201
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  */
210 210
 function geodir_x_action_wrapper_content_open($type = '', $id = '', $class = '')
211 211
 {
212
-    echo '<div class="x-main left ' . $class . '" role="main">';
212
+	echo '<div class="x-main left ' . $class . '" role="main">';
213 213
 }
214 214
 
215 215
 /**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  */
221 221
 function geodir_x_action_wrapper_content_close()
222 222
 {
223
-    echo '</div>';
223
+	echo '</div>';
224 224
 }
225 225
 
226 226
 /**
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
  */
236 236
 function geodir_x_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '')
237 237
 {
238
-    echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">';
238
+	echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">';
239 239
 }
240 240
 
241 241
 /**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
  */
248 248
 function geodir_x_action_sidebar_right_close($type = '')
249 249
 {
250
-    echo '</aside>';
250
+	echo '</aside>';
251 251
 }
252 252
 
253 253
 add_filter('geodir_breadcrumb', 'geodir_x_breadcrumb');
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
  */
262 262
 function geodir_x_breadcrumb($breadcrumb)
263 263
 {
264
-    $breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '', $breadcrumb);
265
-    $breadcrumb = str_replace('<li>', '', $breadcrumb);
266
-    $breadcrumb = str_replace('</li>', '', $breadcrumb);
267
-    $breadcrumb = str_replace('Home', '<span class="home"><i class="x-icon-home"></i></span>', $breadcrumb);
268
-    $breadcrumb = str_replace('</ul></div>', '', $breadcrumb);
269
-    return $breadcrumb;
264
+	$breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '', $breadcrumb);
265
+	$breadcrumb = str_replace('<li>', '', $breadcrumb);
266
+	$breadcrumb = str_replace('</li>', '', $breadcrumb);
267
+	$breadcrumb = str_replace('Home', '<span class="home"><i class="x-icon-home"></i></span>', $breadcrumb);
268
+	$breadcrumb = str_replace('</ul></div>', '', $breadcrumb);
269
+	return $breadcrumb;
270 270
 }
271 271
 
272 272
 add_filter('geodir_breadcrumb_separator', 'geodir_x_breadcrumb_separator');
@@ -280,125 +280,125 @@  discard block
 block discarded – undo
280 280
  */
281 281
 function geodir_x_breadcrumb_separator($separator)
282 282
 {
283
-    $separator = str_replace(' > ', ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> ', $separator);
284
-    return $separator;
283
+	$separator = str_replace(' > ', ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> ', $separator);
284
+	return $separator;
285 285
 }
286 286
 
287 287
 if (!function_exists('x_breadcrumbs')) :
288
-    /**
289
-     * breadcrumbs.
290
-     *
291
-     * @since 1.0.0
292
-     * @package GeoDirectory
293
-     */
294
-    function x_breadcrumbs()
295
-    {
296
-
297
-        if (x_get_option('x_breadcrumb_display', '1')) {
298
-
299
-            //
300
-            // 1. Delimiter between crumbs.
301
-            // 2. Output text for the "Home" link.
302
-            // 3. Link to the home page.
303
-            // 4. Tag before the current crumb.
304
-            // 5. Tag after the current crumb.
305
-            // 6. Get page title.
306
-            // 7. Get blog title.
307
-            // 8. Get shop title.
308
-            //
309
-
310
-            GLOBAL $post,$wp;
311
-
312
-            if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) {
313
-                geodir_breadcrumb();
314
-            } else {
315
-
316
-                $stack = x_get_stack();
317
-                $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1
318
-                $home_text = '<span class="home"><i class="x-icon-home"></i></span>';               // 2
319
-                $home_link = home_url();                                                            // 3
320
-                $current_before = '<span class="current">';                                              // 4
321
-                $current_after = '</span>';                                                             // 5
322
-                $page_title = get_the_title();                                                       // 6
323
-                $blog_title = get_the_title(get_option('page_for_posts', true));                 // 7
324
-                $shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8
325
-
326
-                if (function_exists('woocommerce_get_page_id')) {
327
-                    $shop_url = x_get_shop_link();
328
-                    $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>';
329
-                }
330
-
331
-                if (is_front_page()) {
332
-                    echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>';
333
-                } elseif (is_home()) {
334
-                    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>';
335
-                } else {
336
-                    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
337
-                    if (is_category()) {
338
-                        $the_cat = get_category(get_query_var('cat'), false);
339
-                        if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter);
340
-                        echo $current_before . single_cat_title('', false) . $current_after;
341
-                    } elseif (x_is_product_category()) {
342
-                        echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
343
-                    } elseif (x_is_product_tag()) {
344
-                        echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after;
345
-                    } elseif (is_search()) {
346
-                        echo $current_before . __('Search Results for ', '__x__') . '&#8220;' . get_search_query() . '&#8221;' . $current_after;
347
-                    } elseif (is_singular('post')) {
348
-                        if (get_option('page_for_posts') == is_front_page()) {
349
-                            echo $current_before . $page_title . $current_after;
350
-                        } else {
351
-                            echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
352
-                        }
353
-                    } elseif (x_is_portfolio()) {
354
-                        echo $current_before . get_the_title() . $current_after;
355
-                    } elseif (x_is_portfolio_item()) {
356
-                        $link = x_get_parent_portfolio_link();
357
-                        $title = x_get_parent_portfolio_title();
358
-                        echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
359
-                    } elseif (x_is_product()) {
360
-                        echo $shop_link . $delimiter . $current_before . $page_title . $current_after;
361
-                    } elseif (is_page() && !$post->post_parent) {
362
-                        echo $current_before . $page_title . $current_after;
363
-                    } elseif (is_page() && $post->post_parent) {
364
-                        $parent_id = $post->post_parent;
365
-                        $breadcrumbs = array();
366
-                        while ($parent_id) {
367
-                            $page = get_page($parent_id);
368
-                            $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
369
-                            $parent_id = $page->post_parent;
370
-                        }
371
-                        $breadcrumbs = array_reverse($breadcrumbs);
372
-                        for ($i = 0; $i < count($breadcrumbs); $i++) {
373
-                            echo $breadcrumbs[$i];
374
-                            if ($i != count($breadcrumbs) - 1) echo $delimiter;
375
-                        }
376
-                        echo $delimiter . $current_before . $page_title . $current_after;
377
-                    } elseif (is_tag()) {
378
-                        echo $current_before . single_tag_title('', false) . $current_after;
379
-                    } elseif (is_author()) {
380
-                        GLOBAL $author;
381
-                        $userdata = get_userdata($author);
382
-                        echo $current_before . __('Posts by ', '__x__') . '&#8220;' . $userdata->display_name . $current_after . '&#8221;';
383
-                    } elseif (is_404()) {
384
-                        echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after;
385
-                    } elseif (is_archive()) {
386
-                        if (x_is_shop()) {
387
-                            echo $current_before . $shop_title . $current_after;
388
-                        } else {
389
-                            echo $current_before . __('Archives ', '__x__') . $current_after;
390
-                        }
391
-                    }
392
-                    if (get_query_var('paged')) {
393
-                        echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>';
394
-                    }
395
-                    echo '</div>';
396
-                }
397
-
398
-            }
399
-
400
-        }
401
-    } // ends my geodir check
288
+	/**
289
+	 * breadcrumbs.
290
+	 *
291
+	 * @since 1.0.0
292
+	 * @package GeoDirectory
293
+	 */
294
+	function x_breadcrumbs()
295
+	{
296
+
297
+		if (x_get_option('x_breadcrumb_display', '1')) {
298
+
299
+			//
300
+			// 1. Delimiter between crumbs.
301
+			// 2. Output text for the "Home" link.
302
+			// 3. Link to the home page.
303
+			// 4. Tag before the current crumb.
304
+			// 5. Tag after the current crumb.
305
+			// 6. Get page title.
306
+			// 7. Get blog title.
307
+			// 8. Get shop title.
308
+			//
309
+
310
+			GLOBAL $post,$wp;
311
+
312
+			if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) {
313
+				geodir_breadcrumb();
314
+			} else {
315
+
316
+				$stack = x_get_stack();
317
+				$delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1
318
+				$home_text = '<span class="home"><i class="x-icon-home"></i></span>';               // 2
319
+				$home_link = home_url();                                                            // 3
320
+				$current_before = '<span class="current">';                                              // 4
321
+				$current_after = '</span>';                                                             // 5
322
+				$page_title = get_the_title();                                                       // 6
323
+				$blog_title = get_the_title(get_option('page_for_posts', true));                 // 7
324
+				$shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8
325
+
326
+				if (function_exists('woocommerce_get_page_id')) {
327
+					$shop_url = x_get_shop_link();
328
+					$shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>';
329
+				}
330
+
331
+				if (is_front_page()) {
332
+					echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>';
333
+				} elseif (is_home()) {
334
+					echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>';
335
+				} else {
336
+					echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
337
+					if (is_category()) {
338
+						$the_cat = get_category(get_query_var('cat'), false);
339
+						if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter);
340
+						echo $current_before . single_cat_title('', false) . $current_after;
341
+					} elseif (x_is_product_category()) {
342
+						echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
343
+					} elseif (x_is_product_tag()) {
344
+						echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after;
345
+					} elseif (is_search()) {
346
+						echo $current_before . __('Search Results for ', '__x__') . '&#8220;' . get_search_query() . '&#8221;' . $current_after;
347
+					} elseif (is_singular('post')) {
348
+						if (get_option('page_for_posts') == is_front_page()) {
349
+							echo $current_before . $page_title . $current_after;
350
+						} else {
351
+							echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
352
+						}
353
+					} elseif (x_is_portfolio()) {
354
+						echo $current_before . get_the_title() . $current_after;
355
+					} elseif (x_is_portfolio_item()) {
356
+						$link = x_get_parent_portfolio_link();
357
+						$title = x_get_parent_portfolio_title();
358
+						echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
359
+					} elseif (x_is_product()) {
360
+						echo $shop_link . $delimiter . $current_before . $page_title . $current_after;
361
+					} elseif (is_page() && !$post->post_parent) {
362
+						echo $current_before . $page_title . $current_after;
363
+					} elseif (is_page() && $post->post_parent) {
364
+						$parent_id = $post->post_parent;
365
+						$breadcrumbs = array();
366
+						while ($parent_id) {
367
+							$page = get_page($parent_id);
368
+							$breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
369
+							$parent_id = $page->post_parent;
370
+						}
371
+						$breadcrumbs = array_reverse($breadcrumbs);
372
+						for ($i = 0; $i < count($breadcrumbs); $i++) {
373
+							echo $breadcrumbs[$i];
374
+							if ($i != count($breadcrumbs) - 1) echo $delimiter;
375
+						}
376
+						echo $delimiter . $current_before . $page_title . $current_after;
377
+					} elseif (is_tag()) {
378
+						echo $current_before . single_tag_title('', false) . $current_after;
379
+					} elseif (is_author()) {
380
+						GLOBAL $author;
381
+						$userdata = get_userdata($author);
382
+						echo $current_before . __('Posts by ', '__x__') . '&#8220;' . $userdata->display_name . $current_after . '&#8221;';
383
+					} elseif (is_404()) {
384
+						echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after;
385
+					} elseif (is_archive()) {
386
+						if (x_is_shop()) {
387
+							echo $current_before . $shop_title . $current_after;
388
+						} else {
389
+							echo $current_before . __('Archives ', '__x__') . $current_after;
390
+						}
391
+					}
392
+					if (get_query_var('paged')) {
393
+						echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>';
394
+					}
395
+					echo '</div>';
396
+				}
397
+
398
+			}
399
+
400
+		}
401
+	} // ends my geodir check
402 402
 endif;
403 403
 
404 404
 
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function geodir_x_location_switcher_menu_li_class($class)
415 415
 {
416
-    $class .= " menu-item-has-children ";
417
-    return $class;
416
+	$class .= " menu-item-has-children ";
417
+	return $class;
418 418
 }
419 419
 
420 420
 add_filter('geodir_sub_menu_li_class', 'geodir_x_sub_menu_li_class', 10, 1);
@@ -428,6 +428,6 @@  discard block
 block discarded – undo
428 428
  */
429 429
 function geodir_x_sub_menu_li_class($class)
430 430
 {
431
-    $class .= " menu-item-has-children ";
432
-    return $class;
431
+	$class .= " menu-item-has-children ";
432
+	return $class;
433 433
 }
434 434
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -336,7 +336,9 @@  discard block
 block discarded – undo
336 336
                     echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
337 337
                     if (is_category()) {
338 338
                         $the_cat = get_category(get_query_var('cat'), false);
339
-                        if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter);
339
+                        if ($the_cat->parent != 0) {
340
+                        	echo get_category_parents($the_cat->parent, TRUE, $delimiter);
341
+                        }
340 342
                         echo $current_before . single_cat_title('', false) . $current_after;
341 343
                     } elseif (x_is_product_category()) {
342 344
                         echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
@@ -371,7 +373,9 @@  discard block
 block discarded – undo
371 373
                         $breadcrumbs = array_reverse($breadcrumbs);
372 374
                         for ($i = 0; $i < count($breadcrumbs); $i++) {
373 375
                             echo $breadcrumbs[$i];
374
-                            if ($i != count($breadcrumbs) - 1) echo $delimiter;
376
+                            if ($i != count($breadcrumbs) - 1) {
377
+                            	echo $delimiter;
378
+                            }
375 379
                         }
376 380
                         echo $delimiter . $current_before . $page_title . $current_after;
377 381
                     } elseif (is_tag()) {
Please login to merge, or discard this patch.
geodirectory-functions/custom_fields_functions.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3448,7 +3448,7 @@  discard block
 block discarded – undo
3448 3448
  * @global object $wpdb WordPress Database object.
3449 3449
  * @global string $plugin_prefix Geodirectory plugin table prefix.
3450 3450
  * @param int $post_id The post ID.
3451
- * @return mixed Returns video.
3451
+ * @return string Returns video.
3452 3452
  */
3453 3453
 function geodir_get_video($post_id)
3454 3454
 {
@@ -3474,7 +3474,7 @@  discard block
 block discarded – undo
3474 3474
  * @global object $wpdb WordPress Database object.
3475 3475
  * @global string $plugin_prefix Geodirectory plugin table prefix.
3476 3476
  * @param int $post_id The post ID.
3477
- * @return mixed Returns special offers.
3477
+ * @return string Returns special offers.
3478 3478
  */
3479 3479
 function geodir_get_special_offers($post_id)
3480 3480
 {
@@ -3498,7 +3498,7 @@  discard block
 block discarded – undo
3498 3498
 	 *
3499 3499
 	 * @since 1.0.0
3500 3500
 	 * @package GeoDirectory
3501
-	 * @return mixed|void Returns max upload file size.
3501
+	 * @return string|null Returns max upload file size.
3502 3502
 	 */
3503 3503
 	function geodir_max_upload_size()
3504 3504
     {
Please login to merge, or discard this patch.
Braces   +369 added lines, -184 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
         global $wpdb;
52 52
         $result = 0;// no rows affected
53 53
         if (!geodir_column_exist($db, $column)) {
54
-            if (!empty($db) && !empty($column))
55
-                $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
54
+            if (!empty($db) && !empty($column)) {
55
+                            $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
+            }
56 57
         }
57 58
         return $result;
58 59
     }
@@ -82,10 +83,11 @@  discard block
 block discarded – undo
82 83
 
83 84
     $default_query = '';
84 85
 
85
-    if ($default == 'default')
86
-        $default_query = " and is_default IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query = " and is_default = '0' ";
86
+    if ($default == 'default') {
87
+            $default_query = " and is_default IN ('1') ";
88
+    } elseif ($default == 'custom') {
89
+            $default_query = " and is_default = '0' ";
90
+    }
89 91
 
90 92
     if ($fields_location == 'detail') {
91 93
         $default_query = " and show_on_detail='1' ";
@@ -240,10 +242,12 @@  discard block
 block discarded – undo
240 242
                 }
241 243
 
242 244
                 return $field_id;
243
-            } else
244
-                return 0;
245
-        } else
246
-            return 0;
245
+            } else {
246
+                            return 0;
247
+            }
248
+        } else {
249
+                    return 0;
250
+        }
247 251
     }
248 252
 }
249 253
 
@@ -351,7 +355,9 @@  discard block
 block discarded – undo
351 355
 		}*/
352 356
 
353 357
 
354
-            if ($post_type == '') $post_type = 'gd_place';
358
+            if ($post_type == '') {
359
+            	$post_type = 'gd_place';
360
+            }
355 361
 
356 362
 
357 363
             $detail_table = $plugin_prefix . $post_type . '_detail';
@@ -384,20 +390,23 @@  discard block
 block discarded – undo
384 390
             }
385 391
 
386 392
             $option_values = '';
387
-            if (isset($request_field['option_values']))
388
-                $option_values = $request_field['option_values'];
393
+            if (isset($request_field['option_values'])) {
394
+                            $option_values = $request_field['option_values'];
395
+            }
389 396
 
390 397
             $cat_sort = '';
391
-            if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort']))
392
-                $cat_sort = implode(",", $request_field['cat_sort']);
398
+            if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort'])) {
399
+                            $cat_sort = implode(",", $request_field['cat_sort']);
400
+            }
393 401
 
394 402
             $cat_filter = '';
395
-            if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter']))
396
-                $cat_filter = implode(",", $request_field['cat_filter']);
403
+            if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter'])) {
404
+                            $cat_filter = implode(",", $request_field['cat_filter']);
405
+            }
397 406
 
398
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
399
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
400
-            else {
407
+            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) {
408
+                            $price_pkg = implode(",", $request_field['show_on_pkg']);
409
+            } else {
401 410
                 $package_info = array();
402 411
 
403 412
                 $package_info = geodir_post_package_info($package_info, '', $post_type);
@@ -405,22 +414,29 @@  discard block
 block discarded – undo
405 414
             }
406 415
 
407 416
 
408
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
409
-                $extra_fields = $request_field['extra'];
417
+            if (isset($request_field['extra']) && !empty($request_field['extra'])) {
418
+                            $extra_fields = $request_field['extra'];
419
+            }
410 420
 
411
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
412
-                $is_default = $request_field['is_default'];
413
-            else
414
-                $is_default = '0';
421
+            if (isset($request_field['is_default']) && $request_field['is_default'] != '') {
422
+                            $is_default = $request_field['is_default'];
423
+            } else {
424
+                            $is_default = '0';
425
+            }
415 426
 
416
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
417
-                $is_admin = $request_field['is_admin'];
418
-            else
419
-                $is_admin = '0';
427
+            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') {
428
+                            $is_admin = $request_field['is_admin'];
429
+            } else {
430
+                            $is_admin = '0';
431
+            }
420 432
 
421 433
 
422
-            if ($is_active == '') $is_active = 1;
423
-            if ($is_required == '') $is_required = 0;
434
+            if ($is_active == '') {
435
+            	$is_active = 1;
436
+            }
437
+            if ($is_required == '') {
438
+            	$is_required = 0;
439
+            }
424 440
 
425 441
 
426 442
             if ($sort_order == '') {
@@ -688,7 +704,7 @@  discard block
 block discarded – undo
688 704
                             }
689 705
                             if($op_max){$op_size =$op_max; }
690 706
                         }
691
-                    }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
707
+                    } elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
692 708
                         if(strlen($option_values)){
693 709
                             $op_size =  strlen($option_values);
694 710
                         }
@@ -705,11 +721,13 @@  discard block
 block discarded – undo
705 721
                         return __('Column change failed, you may have too many columns.','geodirectory');
706 722
                     }
707 723
 
708
-                        if (isset($request_field['cat_display_type']))
709
-                            $extra_fields = $request_field['cat_display_type'];
724
+                        if (isset($request_field['cat_display_type'])) {
725
+                                                    $extra_fields = $request_field['cat_display_type'];
726
+                        }
710 727
 
711
-                        if (isset($request_field['multi_display_type']))
712
-                            $extra_fields = $request_field['multi_display_type'];
728
+                        if (isset($request_field['multi_display_type'])) {
729
+                                                    $extra_fields = $request_field['multi_display_type'];
730
+                        }
713 731
 
714 732
 
715 733
                         break;
@@ -721,8 +739,9 @@  discard block
 block discarded – undo
721 739
                     if($alter_result===false){
722 740
                         return __('Column change failed, you may have too many columns.','geodirectory');
723 741
                     }
724
-                        if (isset($request_field['advanced_editor']))
725
-                            $extra_fields = $request_field['advanced_editor'];
742
+                        if (isset($request_field['advanced_editor'])) {
743
+                                                    $extra_fields = $request_field['advanced_editor'];
744
+                        }
726 745
 
727 746
                         break;
728 747
 
@@ -816,8 +835,9 @@  discard block
 block discarded – undo
816 835
                 );
817 836
 
818 837
 
819
-                if ($cat_sort == '')
820
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
838
+                if ($cat_sort == '') {
839
+                                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
840
+                }
821 841
 
822 842
 
823 843
                 /**
@@ -1184,8 +1204,10 @@  discard block
 block discarded – undo
1184 1204
         }
1185 1205
 
1186 1206
         return $post_meta_info;
1187
-    else:
1188
-        return false;
1207
+    else {
1208
+    	:
1209
+        return false;
1210
+    }
1189 1211
     endif;
1190 1212
 }
1191 1213
 
@@ -1238,8 +1260,9 @@  discard block
 block discarded – undo
1238 1260
         if (is_admin()) {
1239 1261
             global $post;
1240 1262
 
1241
-            if (isset($_REQUEST['post']))
1242
-                $_REQUEST['pid'] = $_REQUEST['post'];
1263
+            if (isset($_REQUEST['post'])) {
1264
+                            $_REQUEST['pid'] = $_REQUEST['post'];
1265
+            }
1243 1266
         }
1244 1267
 
1245 1268
         if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
@@ -1271,7 +1294,10 @@  discard block
 block discarded – undo
1271 1294
             $fieldset_field_class = 'gd-fieldset-' . $fieldset_id;
1272 1295
             ?>
1273 1296
             <h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?>
1274
-            <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>';?></h5>
1297
+            <?php if ($admin_desc != '') {
1298
+	echo '<small>( ' . $admin_desc . ' )</small>';
1299
+}
1300
+?></h5>
1275 1301
             <?php
1276 1302
         } else if ($type == 'address') {
1277 1303
             $prefix = $name . '_';
@@ -1308,17 +1334,27 @@  discard block
 block discarded – undo
1308 1334
             }
1309 1335
 
1310 1336
             $location = geodir_get_default_location();
1311
-            if (empty($city)) $city = isset($location->city) ? $location->city : '';
1312
-            if (empty($region)) $region = isset($location->region) ? $location->region : '';
1313
-            if (empty($country)) $country = isset($location->country) ? $location->country : '';
1337
+            if (empty($city)) {
1338
+            	$city = isset($location->city) ? $location->city : '';
1339
+            }
1340
+            if (empty($region)) {
1341
+            	$region = isset($location->region) ? $location->region : '';
1342
+            }
1343
+            if (empty($country)) {
1344
+            	$country = isset($location->country) ? $location->country : '';
1345
+            }
1314 1346
 
1315 1347
             $lat_lng_blank = false;
1316 1348
             if (empty($lat) && empty($lng)) {
1317 1349
                 $lat_lng_blank = true;
1318 1350
             }
1319 1351
 
1320
-            if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : '';
1321
-            if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : '';
1352
+            if (empty($lat)) {
1353
+            	$lat = isset($location->city_latitude) ? $location->city_latitude : '';
1354
+            }
1355
+            if (empty($lng)) {
1356
+            	$lng = isset($location->city_longitude) ? $location->city_longitude : '';
1357
+            }
1322 1358
 
1323 1359
             /**
1324 1360
              * Filter the default latitude.
@@ -1342,10 +1378,16 @@  discard block
 block discarded – undo
1342 1378
             ?>
1343 1379
 
1344 1380
             <div id="geodir_<?php echo $prefix . 'address';?>_row"
1345
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1381
+                 class="<?php if ($is_required) {
1382
+	echo 'required_field';
1383
+}
1384
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1346 1385
                 <label>
1347 1386
                     <?php _e($address_title, 'geodirectory'); ?>
1348
-                    <?php if ($is_required) echo '<span>*</span>';?>
1387
+                    <?php if ($is_required) {
1388
+	echo '<span>*</span>';
1389
+}
1390
+?>
1349 1391
                 </label>
1350 1392
                 <input type="text" field_type="<?php echo $type;?>" name="<?php echo $prefix . 'address';?>"
1351 1393
                        id="<?php echo $prefix . 'address';?>" class="geodir_textfield"
@@ -1406,10 +1448,16 @@  discard block
 block discarded – undo
1406 1448
                 /* show lat lng */
1407 1449
                 $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?>
1408 1450
                 <div id="geodir_<?php echo $prefix . 'latitude'; ?>_row"
1409
-                     class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>>
1451
+                     class="<?php if ($is_required) {
1452
+	echo 'required_field';
1453
+}
1454
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>>
1410 1455
                     <label>
1411 1456
                         <?php echo PLACE_ADDRESS_LAT; ?>
1412
-                        <?php if ($is_required) echo '<span>*</span>'; ?>
1457
+                        <?php if ($is_required) {
1458
+	echo '<span>*</span>';
1459
+}
1460
+?>
1413 1461
                     </label>
1414 1462
                     <input type="text" field_type="<?php echo $type; ?>" name="<?php echo $prefix . 'latitude'; ?>"
1415 1463
                            id="<?php echo $prefix . 'latitude'; ?>" class="geodir_textfield"
@@ -1421,10 +1469,16 @@  discard block
 block discarded – undo
1421 1469
                 </div>
1422 1470
 
1423 1471
                 <div id="geodir_<?php echo $prefix . 'longitude'; ?>_row"
1424
-                     class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>>
1472
+                     class="<?php if ($is_required) {
1473
+	echo 'required_field';
1474
+}
1475
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>>
1425 1476
                     <label>
1426 1477
                         <?php echo PLACE_ADDRESS_LNG; ?>
1427
-                        <?php if ($is_required) echo '<span>*</span>'; ?>
1478
+                        <?php if ($is_required) {
1479
+	echo '<span>*</span>';
1480
+}
1481
+?>
1428 1482
                     </label>
1429 1483
                     <input type="text" field_type="<?php echo $type; ?>" name="<?php echo $prefix . 'longitude'; ?>"
1430 1484
                            id="<?php echo $prefix . 'longitude'; ?>" class="geodir_textfield"
@@ -1479,26 +1533,31 @@  discard block
 block discarded – undo
1479 1533
         <?php } elseif ($type == 'text') {
1480 1534
 
1481 1535
             //number and float validation $validation_pattern
1482
-            if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
1483
-            elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
1536
+            if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';} elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
1484 1537
             //print_r($val);
1485 1538
             //validation
1486 1539
             if(isset($val['validation_pattern']) && $val['validation_pattern']){
1487 1540
                 $validation = 'pattern="'.$val['validation_pattern'].'"';
1488
-            }else{$validation='';}
1541
+            } else{$validation='';}
1489 1542
 
1490 1543
             // validation message
1491 1544
             if(isset($val['validation_msg']) && $val['validation_msg']){
1492 1545
                 $validation_msg = 'title="'.$val['validation_msg'].'"';
1493
-            }else{$validation_msg='';}
1546
+            } else{$validation_msg='';}
1494 1547
             ?>
1495 1548
 
1496 1549
             <div id="<?php echo $name;?>_row"
1497
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1550
+                 class="<?php if ($is_required) {
1551
+	echo 'required_field';
1552
+}
1553
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1498 1554
                 <label>
1499 1555
                     <?php $site_title = __($site_title, 'geodirectory');
1500 1556
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1501
-                    <?php if ($is_required) echo '<span>*</span>';?>
1557
+                    <?php if ($is_required) {
1558
+	echo '<span>*</span>';
1559
+}
1560
+?>
1502 1561
                 </label>
1503 1562
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1504 1563
                        value="<?php echo esc_attr(stripslashes($value));?>" type="<?php echo $type;?>" class="geodir_textfield" <?php echo $validation;echo $validation_msg;?> />
@@ -1514,11 +1573,17 @@  discard block
 block discarded – undo
1514 1573
             }?>
1515 1574
 
1516 1575
             <div id="<?php echo $name;?>_row"
1517
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1576
+                 class="<?php if ($is_required) {
1577
+	echo 'required_field';
1578
+}
1579
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1518 1580
                 <label>
1519 1581
                     <?php $site_title = __($site_title, 'geodirectory');
1520 1582
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1521
-                    <?php if ($is_required) echo '<span>*</span>';?>
1583
+                    <?php if ($is_required) {
1584
+	echo '<span>*</span>';
1585
+}
1586
+?>
1522 1587
                 </label>
1523 1588
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1524 1589
                        value="<?php echo esc_attr(stripslashes($value));?>" type="email" class="geodir_textfield"/>
@@ -1534,11 +1599,17 @@  discard block
 block discarded – undo
1534 1599
             } ?>
1535 1600
 
1536 1601
             <div id="<?php echo $name;?>_row"
1537
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1602
+                 class="<?php if ($is_required) {
1603
+	echo 'required_field';
1604
+}
1605
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1538 1606
                 <label>
1539 1607
                     <?php $site_title = __($site_title, 'geodirectory');
1540 1608
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1541
-                    <?php if ($is_required) echo '<span>*</span>';?>
1609
+                    <?php if ($is_required) {
1610
+	echo '<span>*</span>';
1611
+}
1612
+?>
1542 1613
                 </label>
1543 1614
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1544 1615
                        value="<?php echo esc_attr(stripslashes($value));?>" type="tel" class="geodir_textfield"/>
@@ -1554,11 +1625,17 @@  discard block
 block discarded – undo
1554 1625
             }?>
1555 1626
 
1556 1627
             <div id="<?php echo $name;?>_row"
1557
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1628
+                 class="<?php if ($is_required) {
1629
+	echo 'required_field';
1630
+}
1631
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1558 1632
                 <label>
1559 1633
                     <?php $site_title = __($site_title, 'geodirectory');
1560 1634
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1561
-                    <?php if ($is_required) echo '<span>*</span>';?>
1635
+                    <?php if ($is_required) {
1636
+	echo '<span>*</span>';
1637
+}
1638
+?>
1562 1639
                 </label>
1563 1640
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1564 1641
                        value="<?php echo esc_attr(stripslashes($value));?>" type="url" class="geodir_textfield"
@@ -1573,11 +1650,17 @@  discard block
 block discarded – undo
1573 1650
 
1574 1651
         <?php } elseif ($type == 'radio') { ?>
1575 1652
             <div id="<?php echo $name;?>_row"
1576
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1653
+                 class="<?php if ($is_required) {
1654
+	echo 'required_field';
1655
+}
1656
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1577 1657
                 <label>
1578 1658
                     <?php $site_title = __($site_title, 'geodirectory');
1579 1659
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1580
-                    <?php if ($is_required) echo '<span>*</span>';?>
1660
+                    <?php if ($is_required) {
1661
+	echo '<span>*</span>';
1662
+}
1663
+?>
1581 1664
                 </label>
1582 1665
 				<?php if ($option_values) {
1583 1666
                     $option_values = geodir_string_values_to_options($option_values, true);
@@ -1602,11 +1685,17 @@  discard block
 block discarded – undo
1602 1685
         <?php } elseif ($type == 'checkbox') { ?>
1603 1686
 
1604 1687
             <div id="<?php echo $name;?>_row"
1605
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1688
+                 class="<?php if ($is_required) {
1689
+	echo 'required_field';
1690
+}
1691
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1606 1692
                 <label>
1607 1693
                     <?php $site_title = __($site_title, 'geodirectory');
1608 1694
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1609
-                    <?php if ($is_required) echo '<span>*</span>';?>
1695
+                    <?php if ($is_required) {
1696
+	echo '<span>*</span>';
1697
+}
1698
+?>
1610 1699
                 </label>
1611 1700
                 <?php if ($value != '1') {
1612 1701
                     $value = '0';
@@ -1626,11 +1715,17 @@  discard block
 block discarded – undo
1626 1715
             ?>
1627 1716
 
1628 1717
             <div id="<?php echo $name;?>_row"
1629
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1718
+                 class="<?php if ($is_required) {
1719
+	echo 'required_field';
1720
+}
1721
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1630 1722
                 <label>
1631 1723
                     <?php $site_title = __($site_title, 'geodirectory');
1632 1724
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1633
-                    <?php if ($is_required) echo '<span>*</span>';?>
1725
+                    <?php if ($is_required) {
1726
+	echo '<span>*</span>';
1727
+}
1728
+?>
1634 1729
                 </label><?php
1635 1730
 
1636 1731
 
@@ -1658,11 +1753,17 @@  discard block
 block discarded – undo
1658 1753
 
1659 1754
         <?php } elseif ($type == 'select') { ?>
1660 1755
             <div id="<?php echo $name;?>_row"
1661
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>">
1756
+                 class="<?php if ($is_required) {
1757
+	echo 'required_field';
1758
+}
1759
+?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>">
1662 1760
                 <label>
1663 1761
                     <?php $site_title = __($site_title, 'geodirectory');
1664 1762
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1665
-                    <?php if ($is_required) echo '<span>*</span>';?>
1763
+                    <?php if ($is_required) {
1764
+	echo '<span>*</span>';
1765
+}
1766
+?>
1666 1767
                 </label>
1667 1768
                 <?php
1668 1769
                 $option_values_arr = geodir_string_values_to_options($option_values, true);
@@ -1701,11 +1802,17 @@  discard block
 block discarded – undo
1701 1802
             }
1702 1803
             ?>
1703 1804
             <div id="<?php echo $name; ?>_row"
1704
-                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1805
+                 class="<?php if ($is_required) {
1806
+	echo 'required_field';
1807
+}
1808
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1705 1809
                 <label>
1706 1810
                     <?php $site_title = __($site_title, 'geodirectory');
1707 1811
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1708
-                    <?php if ($is_required) echo '<span>*</span>'; ?>
1812
+                    <?php if ($is_required) {
1813
+	echo '<span>*</span>';
1814
+}
1815
+?>
1709 1816
                 </label>
1710 1817
                 <input type="hidden" name="gd_field_<?php echo $name; ?>" value="1"/>
1711 1818
                 <?php if ($multi_display == 'select') { ?>
@@ -1775,11 +1882,17 @@  discard block
 block discarded – undo
1775 1882
             ?>
1776 1883
 
1777 1884
             <div id="<?php echo $name; ?>_row"
1778
-                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1885
+                 class="<?php if ($is_required) {
1886
+	echo 'required_field';
1887
+}
1888
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1779 1889
                 <label>
1780 1890
                     <?php $site_title = __($site_title, 'geodirectory');
1781 1891
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1782
-                    <?php if ($is_required) echo '<span>*</span>'; ?>
1892
+                    <?php if ($is_required) {
1893
+	echo '<span>*</span>';
1894
+}
1895
+?>
1783 1896
                 </label>
1784 1897
 
1785 1898
                 <?php $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); ?>
@@ -1796,8 +1909,9 @@  discard block
 block discarded – undo
1796 1909
             </div>
1797 1910
         <?php } elseif ($type == 'datepicker') {
1798 1911
 
1799
-            if ($extra_fields['date_format'] == '')
1800
-                $extra_fields['date_format'] = 'yy-mm-dd';
1912
+            if ($extra_fields['date_format'] == '') {
1913
+                            $extra_fields['date_format'] = 'yy-mm-dd';
1914
+            }
1801 1915
 
1802 1916
 
1803 1917
             $search = array('dd', 'mm', 'yy');
@@ -1835,12 +1949,18 @@  discard block
 block discarded – undo
1835 1949
 
1836 1950
             </script>
1837 1951
             <div id="<?php echo $name;?>_row"
1838
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1952
+                 class="<?php if ($is_required) {
1953
+	echo 'required_field';
1954
+}
1955
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1839 1956
                 <label>
1840 1957
 
1841 1958
                     <?php $site_title = __($site_title, 'geodirectory');
1842 1959
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1843
-                    <?php if ($is_required) echo '<span>*</span>';?>
1960
+                    <?php if ($is_required) {
1961
+	echo '<span>*</span>';
1962
+}
1963
+?>
1844 1964
                 </label>
1845 1965
 
1846 1966
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
@@ -1854,8 +1974,9 @@  discard block
 block discarded – undo
1854 1974
 
1855 1975
         <?php } elseif ($type == 'time') {
1856 1976
 
1857
-            if ($value != '')
1858
-                $value = date('H:i', strtotime($value));
1977
+            if ($value != '') {
1978
+                            $value = date('H:i', strtotime($value));
1979
+            }
1859 1980
             ?>
1860 1981
             <script type="text/javascript">
1861 1982
                 jQuery(document).ready(function () {
@@ -1868,12 +1989,18 @@  discard block
 block discarded – undo
1868 1989
                 });
1869 1990
             </script>
1870 1991
             <div id="<?php echo $name;?>_row"
1871
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1992
+                 class="<?php if ($is_required) {
1993
+	echo 'required_field';
1994
+}
1995
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1872 1996
                 <label>
1873 1997
 
1874 1998
                     <?php $site_title = __($site_title, 'geodirectory');
1875 1999
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1876
-                    <?php if ($is_required) echo '<span>*</span>';?>
2000
+                    <?php if ($is_required) {
2001
+	echo '<span>*</span>';
2002
+}
2003
+?>
1877 2004
                 </label>
1878 2005
                 <input readonly="readonly" field_type="<?php echo $type;?>" name="<?php echo $name;?>"
1879 2006
                        id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>" type="text" class="geodir_textfield"/>
@@ -1889,11 +2016,17 @@  discard block
 block discarded – undo
1889 2016
                 $value = '';
1890 2017
             } ?>
1891 2018
             <div id="<?php echo $name;?>_row"
1892
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
2019
+                 class="<?php if ($is_required) {
2020
+	echo 'required_field';
2021
+}
2022
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1893 2023
                 <label>
1894 2024
                     <?php $site_title = __($site_title, 'geodirectory');
1895 2025
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1896
-                    <?php if ($is_required) echo '<span>*</span>';?>
2026
+                    <?php if ($is_required) {
2027
+	echo '<span>*</span>';
2028
+}
2029
+?>
1897 2030
                 </label>
1898 2031
 
1899 2032
                 <div id="<?php echo $name;?>" class="geodir_taxonomy_field" style="float:left; width:70%;">
@@ -1927,8 +2060,9 @@  discard block
 block discarded – undo
1927 2060
                         $post_cat = implode(",", $post_cat[$name]);
1928 2061
 
1929 2062
                     } else {
1930
-                        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
1931
-                            $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true);
2063
+                        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2064
+                                                    $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true);
2065
+                        }
1932 2066
                     }
1933 2067
 
1934 2068
 
@@ -1966,21 +2100,24 @@  discard block
 block discarded – undo
1966 2100
 
1967 2101
                             $cat_display == '';
1968 2102
                             $multiple = '';
1969
-                            if ($cat_display == 'multiselect')
1970
-                                $multiple = 'multiple="multiple"';
2103
+                            if ($cat_display == 'multiselect') {
2104
+                                                            $multiple = 'multiple="multiple"';
2105
+                            }
1971 2106
 
1972 2107
                             echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
1973 2108
 
1974 2109
 
1975
-                            if ($cat_display == 'select')
1976
-                                echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
2110
+                            if ($cat_display == 'select') {
2111
+                                                            echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
2112
+                            }
1977 2113
 
1978 2114
                         }
1979 2115
 
1980 2116
                         echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0);
1981 2117
 
1982
-                        if ($cat_display == 'select' || $cat_display == 'multiselect')
1983
-                            echo '</select>';
2118
+                        if ($cat_display == 'select' || $cat_display == 'multiselect') {
2119
+                                                    echo '</select>';
2120
+                        }
1984 2121
 
1985 2122
                     } else {
1986 2123
 
@@ -2010,18 +2147,23 @@  discard block
 block discarded – undo
2010 2147
 
2011 2148
                 $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls.
2012 2149
 
2013
-            } else
2014
-                $file_value = '';
2150
+            } else {
2151
+                            $file_value = '';
2152
+            }
2015 2153
 
2016
-            if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple'])
2017
-                $file_multiple = true; // allow multiple files upload
2018
-            else
2019
-                $file_multiple = false;
2154
+            if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) {
2155
+                            $file_multiple = true;
2156
+            }
2157
+            // allow multiple files upload
2158
+            else {
2159
+                            $file_multiple = false;
2160
+            }
2020 2161
 
2021
-            if (isset($extra_fields['image_limit']) && $extra_fields['image_limit'])
2022
-                $file_image_limit = $extra_fields['image_limit'];
2023
-            else
2024
-                $file_image_limit = 1;
2162
+            if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) {
2163
+                            $file_image_limit = $extra_fields['image_limit'];
2164
+            } else {
2165
+                            $file_image_limit = 1;
2166
+            }
2025 2167
 
2026 2168
             $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2027 2169
 
@@ -2029,8 +2171,9 @@  discard block
 block discarded – undo
2029 2171
 
2030 2172
             if (!empty($file_value)) {
2031 2173
                 $curImages = explode(',', $file_value);
2032
-                if (!empty($curImages))
2033
-                    $file_totImg = count($curImages);
2174
+                if (!empty($curImages)) {
2175
+                                    $file_totImg = count($curImages);
2176
+                }
2034 2177
             }
2035 2178
 			
2036 2179
 			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
@@ -2045,12 +2188,18 @@  discard block
 block discarded – undo
2045 2188
             ?>
2046 2189
 
2047 2190
             <div id="<?php echo $name;?>_row"
2048
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
2191
+                 class="<?php if ($is_required) {
2192
+	echo 'required_field';
2193
+}
2194
+?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
2049 2195
 
2050 2196
                 <div id="<?php echo $file_id; ?>dropbox" style="text-align:center;">
2051 2197
                     <label
2052 2198
                         style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory');
2053
-                        echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label>
2199
+                        echo $site_title; ?><?php if ($is_required) {
2200
+                        	echo '<span>*</span>';
2201
+                        }
2202
+                        ?></label>
2054 2203
                     <input class="geodir-custom-file-upload" field_type="file" type="hidden"
2055 2204
                            name="<?php echo $file_id; ?>" id="<?php echo $file_id; ?>"
2056 2205
                            value="<?php echo esc_attr($file_value); ?>"/>
@@ -2191,9 +2340,10 @@  discard block
 block discarded – undo
2191 2340
             $field_set_start = 0;
2192 2341
 
2193 2342
 
2194
-            if ($fields_location == 'detail')
2195
-
2196
-                $i = 1;
2343
+            if ($fields_location == 'detail') {
2344
+            
2345
+                $i = 1;
2346
+            }
2197 2347
             foreach ($fields_info as $type) {
2198 2348
 				$type = stripslashes_deep($type); // strip slashes
2199 2349
                 $html = '';
@@ -2210,8 +2360,9 @@  discard block
 block discarded – undo
2210 2360
                     $variables_array['post_id'] = $post->ID;
2211 2361
                     $variables_array['label'] = __($type['site_title'], 'geodirectory');
2212 2362
                     $variables_array['value'] = '';
2213
-                    if (isset($post->{$type['htmlvar_name']}))
2214
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
2363
+                    if (isset($post->{$type['htmlvar_name']})) {
2364
+                                            $variables_array['value'] = $post->{$type['htmlvar_name']};
2365
+                    }
2215 2366
                 endif;
2216 2367
 
2217 2368
                 //if($type['field_icon'])
@@ -2338,8 +2489,9 @@  discard block
 block discarded – undo
2338 2489
                             if ($fields_location == 'detail') {
2339 2490
 
2340 2491
                                 $geodir_odd_even = 'geodir_more_info_odd';
2341
-                                if ($i % 2 == 0)
2342
-                                    $geodir_odd_even = 'geodir_more_info_even';
2492
+                                if ($i % 2 == 0) {
2493
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2494
+                                }
2343 2495
 
2344 2496
                                 $i++;
2345 2497
                             }
@@ -2413,8 +2565,9 @@  discard block
 block discarded – undo
2413 2565
                             if ($fields_location == 'detail') {
2414 2566
 
2415 2567
                                 $geodir_odd_even = 'geodir_more_info_odd';
2416
-                                if ($i % 2 == 0)
2417
-                                    $geodir_odd_even = 'geodir_more_info_even';
2568
+                                if ($i % 2 == 0) {
2569
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2570
+                                }
2418 2571
 
2419 2572
                                 $i++;
2420 2573
                             }
@@ -2456,8 +2609,9 @@  discard block
 block discarded – undo
2456 2609
                             if ($fields_location == 'detail') {
2457 2610
 
2458 2611
                                 $geodir_odd_even = 'geodir_more_info_odd';
2459
-                                if ($i % 2 == 0)
2460
-                                    $geodir_odd_even = 'geodir_more_info_even';
2612
+                                if ($i % 2 == 0) {
2613
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2614
+                                }
2461 2615
 
2462 2616
                                 $i++;
2463 2617
                             }
@@ -2477,9 +2631,10 @@  discard block
 block discarded – undo
2477 2631
                         if ($post->{$type['htmlvar_name']}):
2478 2632
 
2479 2633
                             $value = '';
2480
-                            if ($post->{$type['htmlvar_name']} != '')
2481
-                                //$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
2482
-                                $value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
2634
+                            if ($post->{$type['htmlvar_name']} != '') {
2635
+                                                            //$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
2636
+                                $value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
2637
+                            }
2483 2638
 
2484 2639
                             if (strpos($field_icon, 'http') !== false) {
2485 2640
                                 $field_icon_af = '';
@@ -2494,8 +2649,9 @@  discard block
 block discarded – undo
2494 2649
                             if ($fields_location == 'detail') {
2495 2650
 
2496 2651
                                 $geodir_odd_even = 'geodir_more_info_odd';
2497
-                                if ($i % 2 == 0)
2498
-                                    $geodir_odd_even = 'geodir_more_info_even';
2652
+                                if ($i % 2 == 0) {
2653
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2654
+                                }
2499 2655
 
2500 2656
                                 $i++;
2501 2657
                             }
@@ -2528,7 +2684,7 @@  discard block
 block discarded – undo
2528 2684
                             $value = '';
2529 2685
                             if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
2530 2686
                                 $value = date($date_format, strtotime($post_htmlvar_value));
2531
-                            }else{
2687
+                            } else{
2532 2688
                                 continue;
2533 2689
                             }
2534 2690
 
@@ -2545,8 +2701,9 @@  discard block
 block discarded – undo
2545 2701
                             if ($fields_location == 'detail') {
2546 2702
 
2547 2703
                                 $geodir_odd_even = 'geodir_more_info_odd';
2548
-                                if ($i % 2 == 0)
2549
-                                    $geodir_odd_even = 'geodir_more_info_even';
2704
+                                if ($i % 2 == 0) {
2705
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2706
+                                }
2550 2707
 
2551 2708
                                 $i++;
2552 2709
                             }
@@ -2578,8 +2735,9 @@  discard block
 block discarded – undo
2578 2735
                             if ($fields_location == 'detail') {
2579 2736
 
2580 2737
                                 $geodir_odd_even = 'geodir_more_info_odd';
2581
-                                if ($i % 2 == 0)
2582
-                                    $geodir_odd_even = 'geodir_more_info_even';
2738
+                                if ($i % 2 == 0) {
2739
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2740
+                                }
2583 2741
 
2584 2742
                                 $i++;
2585 2743
                             }
@@ -2603,8 +2761,9 @@  discard block
 block discarded – undo
2603 2761
                             if ($fields_location == 'detail') {
2604 2762
 
2605 2763
                                 $geodir_odd_even = 'geodir_more_info_odd';
2606
-                                if ($i % 2 == 0)
2607
-                                    $geodir_odd_even = 'geodir_more_info_even';
2764
+                                if ($i % 2 == 0) {
2765
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2766
+                                }
2608 2767
 
2609 2768
                                 $i++;
2610 2769
                             }
@@ -2654,8 +2813,9 @@  discard block
 block discarded – undo
2654 2813
                             if ($fields_location == 'detail') {
2655 2814
 
2656 2815
                                 $geodir_odd_even = 'geodir_more_info_odd';
2657
-                                if ($i % 2 == 0)
2658
-                                    $geodir_odd_even = 'geodir_more_info_even';
2816
+                                if ($i % 2 == 0) {
2817
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2818
+                                }
2659 2819
 
2660 2820
                                 $i++;
2661 2821
                             }
@@ -2675,8 +2835,10 @@  discard block
 block discarded – undo
2675 2835
 
2676 2836
                             if ($post->{$type['htmlvar_name']} == '1'):
2677 2837
                                 $html_val = __('Yes', 'geodirectory');
2678
-                            else:
2679
-                                $html_val = __('No', 'geodirectory');
2838
+                            else {
2839
+                            	:
2840
+                                $html_val = __('No', 'geodirectory');
2841
+                            }
2680 2842
                             endif;
2681 2843
 
2682 2844
                             if (strpos($field_icon, 'http') !== false) {
@@ -2692,8 +2854,9 @@  discard block
 block discarded – undo
2692 2854
                             if ($fields_location == 'detail') {
2693 2855
 
2694 2856
                                 $geodir_odd_even = 'geodir_more_info_odd';
2695
-                                if ($i % 2 == 0)
2696
-                                    $geodir_odd_even = 'geodir_more_info_even';
2857
+                                if ($i % 2 == 0) {
2858
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2859
+                                }
2697 2860
 
2698 2861
                                 $i++;
2699 2862
                             }
@@ -2737,8 +2900,9 @@  discard block
 block discarded – undo
2737 2900
                             if ($fields_location == 'detail') {
2738 2901
 
2739 2902
                                 $geodir_odd_even = 'geodir_more_info_odd';
2740
-                                if ($i % 2 == 0)
2741
-                                    $geodir_odd_even = 'geodir_more_info_even';
2903
+                                if ($i % 2 == 0) {
2904
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2905
+                                }
2742 2906
 
2743 2907
                                 $i++;
2744 2908
                             }
@@ -2789,8 +2953,9 @@  discard block
 block discarded – undo
2789 2953
                             if ($fields_location == 'detail') {
2790 2954
 
2791 2955
                                 $geodir_odd_even = 'geodir_more_info_odd';
2792
-                                if ($i % 2 == 0)
2793
-                                    $geodir_odd_even = 'geodir_more_info_even';
2956
+                                if ($i % 2 == 0) {
2957
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
2958
+                                }
2794 2959
 
2795 2960
                                 $i++;
2796 2961
                             }
@@ -2844,8 +3009,9 @@  discard block
 block discarded – undo
2844 3009
                             if ($fields_location == 'detail') {
2845 3010
 
2846 3011
                                 $geodir_odd_even = 'geodir_more_info_odd';
2847
-                                if ($i % 2 == 0)
2848
-                                    $geodir_odd_even = 'geodir_more_info_even';
3012
+                                if ($i % 2 == 0) {
3013
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
3014
+                                }
2849 3015
 
2850 3016
                                 $i++;
2851 3017
                             }
@@ -2890,8 +3056,9 @@  discard block
 block discarded – undo
2890 3056
                                 if ($fields_location == 'detail') {
2891 3057
 
2892 3058
                                     $geodir_odd_even = 'geodir_more_info_odd';
2893
-                                    if ($i % 2 == 0)
2894
-                                        $geodir_odd_even = 'geodir_more_info_even';
3059
+                                    if ($i % 2 == 0) {
3060
+                                                                            $geodir_odd_even = 'geodir_more_info_even';
3061
+                                    }
2895 3062
 
2896 3063
                                     $i++;
2897 3064
                                 }
@@ -2911,7 +3078,7 @@  discard block
 block discarded – undo
2911 3078
                                      */
2912 3079
                                     $email_name = apply_filters('geodir_email_field_name_output',$email,$type);
2913 3080
                                     $html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
2914
-                                }else{
3081
+                                } else{
2915 3082
                                     $html .=  $email;
2916 3083
                                 }
2917 3084
                                 $html .= '</span></div>';
@@ -2989,8 +3156,9 @@  discard block
 block discarded – undo
2989 3156
                                 if ($fields_location == 'detail') {
2990 3157
 
2991 3158
                                     $geodir_odd_even = 'geodir_more_info_odd';
2992
-                                    if ($i % 2 == 0)
2993
-                                        $geodir_odd_even = 'geodir_more_info_even';
3159
+                                    if ($i % 2 == 0) {
3160
+                                                                            $geodir_odd_even = 'geodir_more_info_even';
3161
+                                    }
2994 3162
 
2995 3163
                                     $i++;
2996 3164
                                 }
@@ -3024,8 +3192,9 @@  discard block
 block discarded – undo
3024 3192
                             if ($fields_location == 'detail') {
3025 3193
 
3026 3194
                                 $geodir_odd_even = 'geodir_more_info_odd';
3027
-                                if ($i % 2 == 0)
3028
-                                    $geodir_odd_even = 'geodir_more_info_even';
3195
+                                if ($i % 2 == 0) {
3196
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
3197
+                                }
3029 3198
 
3030 3199
                                 $i++;
3031 3200
                             }
@@ -3053,8 +3222,9 @@  discard block
 block discarded – undo
3053 3222
                             if ($fields_location == 'detail') {
3054 3223
 
3055 3224
                                 $geodir_odd_even = 'geodir_more_info_odd';
3056
-                                if ($i % 2 == 0)
3057
-                                    $geodir_odd_even = 'geodir_more_info_even';
3225
+                                if ($i % 2 == 0) {
3226
+                                                                    $geodir_odd_even = 'geodir_more_info_even';
3227
+                                }
3058 3228
 
3059 3229
                                 $i++;
3060 3230
                             }
@@ -3149,7 +3319,9 @@  discard block
 block discarded – undo
3149 3319
                      * @param string $html Custom field unfiltered HTML.
3150 3320
                      * @param array $variables_array Custom field variables array.
3151 3321
                      */
3152
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
3322
+                    if ($html) {
3323
+                    	echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
3324
+                    }
3153 3325
 
3154 3326
                     /**
3155 3327
                      * Called after a custom fields is output on the frontend.
@@ -3183,10 +3355,11 @@  discard block
 block discarded – undo
3183 3355
 	 */
3184 3356
 	function geodir_default_date_format()
3185 3357
     {
3186
-        if ($format = get_option('date_format'))
3187
-            return $format;
3188
-        else
3189
-            return 'dd-mm-yy';
3358
+        if ($format = get_option('date_format')) {
3359
+                    return $format;
3360
+        } else {
3361
+                    return 'dd-mm-yy';
3362
+        }
3190 3363
     }
3191 3364
 }
3192 3365
 
@@ -3293,11 +3466,13 @@  discard block
 block discarded – undo
3293 3466
                     // Set an array containing a list of acceptable formats
3294 3467
                     //$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');
3295 3468
 
3296
-					if (!function_exists('wp_handle_upload'))
3297
-						require_once(ABSPATH . 'wp-admin/includes/file.php');
3469
+					if (!function_exists('wp_handle_upload')) {
3470
+											require_once(ABSPATH . 'wp-admin/includes/file.php');
3471
+					}
3298 3472
 
3299
-					if (!is_dir($geodir_uploadpath))
3300
-						mkdir($geodir_uploadpath);
3473
+					if (!is_dir($geodir_uploadpath)) {
3474
+											mkdir($geodir_uploadpath);
3475
+					}
3301 3476
 
3302 3477
 					$new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
3303 3478
 					$explode_sub_dir = explode("/", $sub_dir);
@@ -3310,16 +3485,19 @@  discard block
 block discarded – undo
3310 3485
 					}
3311 3486
 
3312 3487
 					$uploaded_file = '';
3313
-					if (file_exists($img_path))
3314
-						$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
3488
+					if (file_exists($img_path)) {
3489
+											$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
3490
+					}
3315 3491
 
3316 3492
 					if ($curr_img_dir != $geodir_uploaddir) {
3317
-						if (file_exists($img_path))
3318
-							unlink($img_path);
3493
+						if (file_exists($img_path)) {
3494
+													unlink($img_path);
3495
+						}
3319 3496
 					}
3320 3497
 
3321
-					if (!empty($uploaded_file))
3322
-						$file_urls = $geodir_uploadurl . '/' . $new_name;
3498
+					if (!empty($uploaded_file)) {
3499
+											$file_urls = $geodir_uploadurl . '/' . $new_name;
3500
+					}
3323 3501
 
3324 3502
                 } else {
3325 3503
                     $file_urls = $post_image[$m];
@@ -3340,8 +3518,9 @@  discard block
 block discarded – undo
3340 3518
 
3341 3519
         geodir_save_post_meta($post_id, $field_id, $file_urls);
3342 3520
 
3343
-        if (!empty($invalid_files))
3344
-            geodir_remove_attachments($invalid_files);
3521
+        if (!empty($invalid_files)) {
3522
+                    geodir_remove_attachments($invalid_files);
3523
+        }
3345 3524
 
3346 3525
     }
3347 3526
 }
@@ -3567,8 +3746,9 @@  discard block
 block discarded – undo
3567 3746
 
3568 3747
         $all_postypes = geodir_get_posttypes();
3569 3748
 
3570
-        if (!in_array($post_type, $all_postypes))
3571
-            return false;
3749
+        if (!in_array($post_type, $all_postypes)) {
3750
+                    return false;
3751
+        }
3572 3752
 
3573 3753
         $fields = array();
3574 3754
 
@@ -3656,8 +3836,10 @@  discard block
 block discarded – undo
3656 3836
         }
3657 3837
 
3658 3838
         return $field_ids;
3659
-    else:
3660
-        return false;
3839
+    else {
3840
+    	:
3841
+        return false;
3842
+    }
3661 3843
     endif;
3662 3844
 }
3663 3845
 
@@ -3830,8 +4012,9 @@  discard block
 block discarded – undo
3830 4012
 
3831 4013
             return $field_id;
3832 4014
 
3833
-        } else
3834
-            return 0;
4015
+        } else {
4016
+                    return 0;
4017
+        }
3835 4018
 
3836 4019
     }
3837 4020
 }
@@ -3873,8 +4056,9 @@  discard block
 block discarded – undo
3873 4056
         $htmlvar_name = isset($field_types[1]) ? $field_types[1] : '';
3874 4057
 
3875 4058
         $site_title = '';
3876
-        if ($site_title == '')
3877
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
4059
+        if ($site_title == '') {
4060
+                    $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
4061
+        }
3878 4062
 
3879 4063
         if ($site_title == '') {
3880 4064
             $fields = geodir_get_custom_sort_options($post_type);
@@ -3888,8 +4072,9 @@  discard block
 block discarded – undo
3888 4072
             }
3889 4073
         }
3890 4074
 
3891
-        if ($htmlvar_name == '')
3892
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
4075
+        if ($htmlvar_name == '') {
4076
+                    $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
4077
+        }
3893 4078
 
3894 4079
         $nonce = wp_create_nonce('custom_fields_' . $result_str);
3895 4080
         
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50 50
     {
51 51
         global $wpdb;
52
-        $result = 0;// no rows affected
52
+        $result = 0; // no rows affected
53 53
         if (!geodir_column_exist($db, $column)) {
54 54
             if (!empty($db) && !empty($column))
55 55
                 $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
         $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
305 305
 
306 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'){
307
+        if (isset($request_field['data_type']) && $request_field['data_type'] == 'XVARCHAR') {
308 308
             $request_field['data_type'] = 'VARCHAR';
309 309
         }
310 310
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
                 $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
427 427
 
428
-                $sort_order = (int)$last_order + 1;
428
+                $sort_order = (int) $last_order + 1;
429 429
             }
430 430
 
431 431
             $default_value_add = '';
@@ -677,18 +677,18 @@  discard block
 block discarded – undo
677 677
                     $op_size = '500';
678 678
 
679 679
                     // only make the field as big as it needs to be.
680
-                    if(isset($option_values) && $option_values && $field_type=='select'){
681
-                        $option_values_arr = explode(',',$option_values);
682
-                        if(is_array($option_values_arr)){
680
+                    if (isset($option_values) && $option_values && $field_type == 'select') {
681
+                        $option_values_arr = explode(',', $option_values);
682
+                        if (is_array($option_values_arr)) {
683 683
                             $op_max = 0;
684
-                            foreach($option_values_arr as $op_val){
685
-                                if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
684
+                            foreach ($option_values_arr as $op_val) {
685
+                                if (strlen($op_val) && strlen($op_val) > $op_max) {$op_max = strlen($op_val); }
686 686
                             }
687
-                            if($op_max){$op_size =$op_max; }
687
+                            if ($op_max) {$op_size = $op_max; }
688 688
                         }
689
-                    }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
690
-                        if(strlen($option_values)){
691
-                            $op_size =  strlen($option_values);
689
+                    }elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
690
+                        if (strlen($option_values)) {
691
+                            $op_size = strlen($option_values);
692 692
                         }
693 693
                     }
694 694
 
@@ -699,8 +699,8 @@  discard block
 block discarded – undo
699 699
                         }
700 700
 
701 701
                     $alter_result = $wpdb->query($meta_field_add);
702
-                    if($alter_result===false){
703
-                        return __('Column change failed, you may have too many columns.','geodirectory');
702
+                    if ($alter_result === false) {
703
+                        return __('Column change failed, you may have too many columns.', 'geodirectory');
704 704
                     }
705 705
 
706 706
                         if (isset($request_field['cat_display_type']))
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
                     case 'html':
717 717
 
718 718
                     $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
719
-                    if($alter_result===false){
720
-                        return __('Column change failed, you may have too many columns.','geodirectory');
719
+                    if ($alter_result === false) {
720
+                        return __('Column change failed, you may have too many columns.', 'geodirectory');
721 721
                     }
722 722
                         if (isset($request_field['advanced_editor']))
723 723
                             $extra_fields = $request_field['advanced_editor'];
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
                     default:
732 732
                         if ($data_type != 'VARCHAR' && $data_type != '') {
733 733
                             if ($data_type == 'FLOAT' && $decimal_point > 0) {
734
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
734
+                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int) $decimal_point . ") NULL";
735 735
                             } else {
736 736
                                 $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
737 737
                             }
@@ -747,8 +747,8 @@  discard block
 block discarded – undo
747 747
                         }
748 748
 
749 749
                         $alter_result = $wpdb->query($default_value_add);
750
-                        if($alter_result===false){
751
-                            return __('Column change failed, you may have too many columns.','geodirectory');
750
+                        if ($alter_result === false) {
751
+                            return __('Column change failed, you may have too many columns.', 'geodirectory');
752 752
                         }
753 753
                         break;
754 754
                 endswitch;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 					for_admin_use = %s
797 797
 					where id = %d",
798 798
 
799
-                        array($post_type, $admin_title, $site_title, $field_type, $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_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)
799
+                        array($post_type, $admin_title, $site_title, $field_type, $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_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)
800 800
                     )
801 801
 
802 802
                 );
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
                         $data_type = 'TINYINT';
957 957
 
958 958
                         $meta_field_add = $data_type . "( 1 ) NOT NULL ";
959
-                        if ((int)$default_value === 1) {
959
+                        if ((int) $default_value === 1) {
960 960
                             $meta_field_add .= " DEFAULT '1'";
961 961
                         }
962 962
 
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
                             }
990 990
                         } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
991 991
                             if (strlen($option_values)) {
992
-                                $op_size =  strlen($option_values);
992
+                                $op_size = strlen($option_values);
993 993
                             }
994 994
 							
995 995
 							if (isset($request_field['multi_display_type'])) {
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
                             $meta_field_add = $data_type . " NULL ";
1063 1063
 
1064 1064
                             if ($data_type == 'FLOAT' && $decimal_point > 0) {
1065
-                                $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1065
+                                $meta_field_add = "DECIMAL(11, " . (int) $decimal_point . ") NULL ";
1066 1066
                             }
1067 1067
 
1068 1068
                             if (is_numeric($default_value) && $default_value != '') {
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 					validation_msg = %s,
1128 1128
 					for_admin_use = %s ",
1129 1129
 
1130
-                        array($post_type, $admin_title, $site_title, $field_type, $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_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)
1130
+                        array($post_type, $admin_title, $site_title, $field_type, $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_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)
1131 1131
 
1132 1132
                     )
1133 1133
 
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
             }
1141 1141
 
1142
-            return (int)$lastid;
1142
+            return (int) $lastid;
1143 1143
 
1144 1144
 
1145 1145
         } else {
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
         $value = '';
1229 1229
 
1230 1230
         /* field available to site admin only for edit */
1231
-        $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1231
+        $for_admin_use = isset($val['for_admin_use']) && (int) $val['for_admin_use'] == 1 ? true : false;
1232 1232
         if ($for_admin_use && !is_super_admin()) {
1233 1233
             continue;
1234 1234
         }
@@ -1265,11 +1265,11 @@  discard block
 block discarded – undo
1265 1265
         do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1266 1266
 
1267 1267
         if ($type == 'fieldset') {
1268
-            $fieldset_id = (int)$val['id'];
1268
+            $fieldset_id = (int) $val['id'];
1269 1269
             $fieldset_field_class = 'gd-fieldset-' . $fieldset_id;
1270 1270
             ?>
1271
-            <h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?>
1272
-            <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>';?></h5>
1271
+            <h5 id="geodir_fieldset_<?php echo $fieldset_id; ?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id; ?>"><?php echo $site_title; ?>
1272
+            <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>'; ?></h5>
1273 1273
             <?php
1274 1274
         } else if ($type == 'address') {
1275 1275
             $prefix = $name . '_';
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
                 $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : '';
1296 1296
                 $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : '';
1297 1297
             } else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) {
1298
-                $post_info = (array)$post_info;
1298
+                $post_info = (array) $post_info;
1299 1299
 
1300 1300
                 $address = $post_info[$prefix . 'address'];
1301 1301
                 $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : '';
@@ -1339,16 +1339,16 @@  discard block
 block discarded – undo
1339 1339
 
1340 1340
             ?>
1341 1341
 
1342
-            <div id="geodir_<?php echo $prefix . 'address';?>_row"
1343
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1342
+            <div id="geodir_<?php echo $prefix . 'address'; ?>_row"
1343
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1344 1344
                 <label>
1345 1345
                     <?php _e($address_title, 'geodirectory'); ?>
1346
-                    <?php if ($is_required) echo '<span>*</span>';?>
1346
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1347 1347
                 </label>
1348
-                <input type="text" field_type="<?php echo $type;?>" name="<?php echo $prefix . 'address';?>"
1349
-                       id="<?php echo $prefix . 'address';?>" class="geodir_textfield"
1348
+                <input type="text" field_type="<?php echo $type; ?>" name="<?php echo $prefix . 'address'; ?>"
1349
+                       id="<?php echo $prefix . 'address'; ?>" class="geodir_textfield"
1350 1350
                        value="<?php echo esc_attr(stripslashes($address)); ?>"/>
1351
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1351
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1352 1352
                 <?php if ($is_required) { ?>
1353 1353
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1354 1354
                 <?php } ?>
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
             if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?>
1370 1370
 
1371 1371
                 <div id="geodir_<?php echo $prefix . 'zip'; ?>_row"
1372
-                     class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1372
+                     class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1373 1373
                     <label>
1374 1374
                         <?php _e($zip_title, 'geodirectory'); ?>
1375 1375
                         <?php /*if($is_required) echo '<span>*</span>';*/ ?>
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
             <?php if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { ?>
1387 1387
 
1388
-                <div id="geodir_<?php echo $prefix . 'map'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1388
+                <div id="geodir_<?php echo $prefix . 'map'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1389 1389
                     <?php
1390 1390
                     /**
1391 1391
                      * Contains add listing page map functions.
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
                 /* show lat lng */
1405 1405
                 $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?>
1406 1406
                 <div id="geodir_<?php echo $prefix . 'latitude'; ?>_row"
1407
-                     class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>>
1407
+                     class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>" <?php echo $style_latlng; ?>>
1408 1408
                     <label>
1409 1409
                         <?php echo PLACE_ADDRESS_LAT; ?>
1410 1410
                         <?php if ($is_required) echo '<span>*</span>'; ?>
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
                 </div>
1420 1420
 
1421 1421
                 <div id="geodir_<?php echo $prefix . 'longitude'; ?>_row"
1422
-                     class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>>
1422
+                     class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>" <?php echo $style_latlng; ?>>
1423 1423
                     <label>
1424 1424
                         <?php echo PLACE_ADDRESS_LNG; ?>
1425 1425
                         <?php if ($is_required) echo '<span>*</span>'; ?>
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
             <?php } ?>
1436 1436
 
1437 1437
             <?php if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { ?>
1438
-                <div id="geodir_<?php echo $prefix . 'mapview'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1438
+                <div id="geodir_<?php echo $prefix . 'mapview'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1439 1439
                     <label><?php _e($mapview_title, 'geodirectory'); ?></label>
1440 1440
 
1441 1441
 
@@ -1477,30 +1477,30 @@  discard block
 block discarded – undo
1477 1477
         <?php } elseif ($type == 'text') {
1478 1478
 
1479 1479
             //number and float validation $validation_pattern
1480
-            if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
1481
-            elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
1480
+            if (isset($val['data_type']) && $val['data_type'] == 'INT') {$type = 'number'; }
1481
+            elseif (isset($val['data_type']) && $val['data_type'] == 'FLOAT') {$type = 'float'; }
1482 1482
             //print_r($val);
1483 1483
             //validation
1484
-            if(isset($val['validation_pattern']) && $val['validation_pattern']){
1485
-                $validation = 'pattern="'.$val['validation_pattern'].'"';
1486
-            }else{$validation='';}
1484
+            if (isset($val['validation_pattern']) && $val['validation_pattern']) {
1485
+                $validation = 'pattern="' . $val['validation_pattern'] . '"';
1486
+            } else {$validation = ''; }
1487 1487
 
1488 1488
             // validation message
1489
-            if(isset($val['validation_msg']) && $val['validation_msg']){
1490
-                $validation_msg = 'title="'.$val['validation_msg'].'"';
1491
-            }else{$validation_msg='';}
1489
+            if (isset($val['validation_msg']) && $val['validation_msg']) {
1490
+                $validation_msg = 'title="' . $val['validation_msg'] . '"';
1491
+            } else {$validation_msg = ''; }
1492 1492
             ?>
1493 1493
 
1494
-            <div id="<?php echo $name;?>_row"
1495
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1494
+            <div id="<?php echo $name; ?>_row"
1495
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1496 1496
                 <label>
1497 1497
                     <?php $site_title = __($site_title, 'geodirectory');
1498 1498
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1499
-                    <?php if ($is_required) echo '<span>*</span>';?>
1499
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1500 1500
                 </label>
1501
-                <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1502
-                       value="<?php echo esc_attr(stripslashes($value));?>" type="<?php echo $type;?>" class="geodir_textfield" <?php echo $validation;echo $validation_msg;?> />
1503
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1501
+                <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>"
1502
+                       value="<?php echo esc_attr(stripslashes($value)); ?>" type="<?php echo $type; ?>" class="geodir_textfield" <?php echo $validation; echo $validation_msg; ?> />
1503
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1504 1504
                 <?php if ($is_required) { ?>
1505 1505
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1506 1506
                 <?php } ?>
@@ -1511,16 +1511,16 @@  discard block
 block discarded – undo
1511 1511
                 $value = '';
1512 1512
             }?>
1513 1513
 
1514
-            <div id="<?php echo $name;?>_row"
1515
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1514
+            <div id="<?php echo $name; ?>_row"
1515
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1516 1516
                 <label>
1517 1517
                     <?php $site_title = __($site_title, 'geodirectory');
1518 1518
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1519
-                    <?php if ($is_required) echo '<span>*</span>';?>
1519
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1520 1520
                 </label>
1521
-                <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1522
-                       value="<?php echo esc_attr(stripslashes($value));?>" type="email" class="geodir_textfield"/>
1523
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1521
+                <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>"
1522
+                       value="<?php echo esc_attr(stripslashes($value)); ?>" type="email" class="geodir_textfield"/>
1523
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1524 1524
                 <?php if ($is_required) { ?>
1525 1525
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1526 1526
                 <?php } ?>
@@ -1531,16 +1531,16 @@  discard block
 block discarded – undo
1531 1531
                 $value = '';
1532 1532
             } ?>
1533 1533
 
1534
-            <div id="<?php echo $name;?>_row"
1535
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1534
+            <div id="<?php echo $name; ?>_row"
1535
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1536 1536
                 <label>
1537 1537
                     <?php $site_title = __($site_title, 'geodirectory');
1538 1538
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1539
-                    <?php if ($is_required) echo '<span>*</span>';?>
1539
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1540 1540
                 </label>
1541
-                <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1542
-                       value="<?php echo esc_attr(stripslashes($value));?>" type="tel" class="geodir_textfield"/>
1543
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1541
+                <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>"
1542
+                       value="<?php echo esc_attr(stripslashes($value)); ?>" type="tel" class="geodir_textfield"/>
1543
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1544 1544
                 <?php if ($is_required) { ?>
1545 1545
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1546 1546
                 <?php } ?>
@@ -1551,31 +1551,31 @@  discard block
 block discarded – undo
1551 1551
                 $value = '';
1552 1552
             }?>
1553 1553
 
1554
-            <div id="<?php echo $name;?>_row"
1555
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1554
+            <div id="<?php echo $name; ?>_row"
1555
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1556 1556
                 <label>
1557 1557
                     <?php $site_title = __($site_title, 'geodirectory');
1558 1558
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1559
-                    <?php if ($is_required) echo '<span>*</span>';?>
1559
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1560 1560
                 </label>
1561
-                <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1562
-                       value="<?php echo esc_attr(stripslashes($value));?>" type="url" class="geodir_textfield"
1561
+                <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>"
1562
+                       value="<?php echo esc_attr(stripslashes($value)); ?>" type="url" class="geodir_textfield"
1563 1563
                        oninvalid="setCustomValidity('<?php _e('Please enter a valid URL including http://', 'geodirectory'); ?>')"
1564 1564
                        onchange="try{setCustomValidity('')}catch(e){}"
1565 1565
                     />
1566
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1566
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1567 1567
                 <?php if ($is_required) { ?>
1568 1568
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1569 1569
                 <?php } ?>
1570 1570
             </div>
1571 1571
 
1572 1572
         <?php } elseif ($type == 'radio') { ?>
1573
-            <div id="<?php echo $name;?>_row"
1574
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1573
+            <div id="<?php echo $name; ?>_row"
1574
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1575 1575
                 <label>
1576 1576
                     <?php $site_title = __($site_title, 'geodirectory');
1577 1577
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1578
-                    <?php if ($is_required) echo '<span>*</span>';?>
1578
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1579 1579
                 </label>
1580 1580
 				<?php if ($option_values) {
1581 1581
                     $option_values = geodir_string_values_to_options($option_values, true);
@@ -1584,14 +1584,14 @@  discard block
 block discarded – undo
1584 1584
 						foreach ($option_values as $option_value) {
1585 1585
 							if (empty($option_value['optgroup'])) {
1586 1586
 							?>
1587
-							<input name="<?php echo $name;?>" id="<?php echo $name;?>" <?php checked($value, $option_value['value']);?> value="<?php echo esc_attr($option_value['value']); ?>" class="gd-checkbox" field_type="<?php echo $type;?>" type="radio" /><?php echo $option_value['label']; ?>
1587
+							<input name="<?php echo $name; ?>" id="<?php echo $name; ?>" <?php checked($value, $option_value['value']); ?> value="<?php echo esc_attr($option_value['value']); ?>" class="gd-checkbox" field_type="<?php echo $type; ?>" type="radio" /><?php echo $option_value['label']; ?>
1588 1588
 							<?php
1589 1589
 							}
1590 1590
 						}
1591 1591
 					}
1592 1592
                 }
1593 1593
                 ?>
1594
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1594
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1595 1595
                 <?php if ($is_required) { ?>
1596 1596
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1597 1597
                 <?php } ?>
@@ -1599,22 +1599,22 @@  discard block
 block discarded – undo
1599 1599
 
1600 1600
         <?php } elseif ($type == 'checkbox') { ?>
1601 1601
 
1602
-            <div id="<?php echo $name;?>_row"
1603
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1602
+            <div id="<?php echo $name; ?>_row"
1603
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1604 1604
                 <label>
1605 1605
                     <?php $site_title = __($site_title, 'geodirectory');
1606 1606
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1607
-                    <?php if ($is_required) echo '<span>*</span>';?>
1607
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1608 1608
                 </label>
1609 1609
                 <?php if ($value != '1') {
1610 1610
                     $value = '0';
1611 1611
                 }?>
1612
-                <input type="hidden" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>"/>
1612
+                <input type="hidden" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($value); ?>"/>
1613 1613
                 <input  <?php if ($value == '1') {
1614 1614
                     echo 'checked="checked"';
1615
-                }?>  value="1" class="gd-checkbox" field_type="<?php echo $type;?>" type="checkbox"
1616
-                     onchange="if(this.checked){jQuery('#<?php echo $name;?>').val('1');} else{ jQuery('#<?php echo $name;?>').val('0');}"/>
1617
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1615
+                }?>  value="1" class="gd-checkbox" field_type="<?php echo $type; ?>" type="checkbox"
1616
+                     onchange="if(this.checked){jQuery('#<?php echo $name; ?>').val('1');} else{ jQuery('#<?php echo $name; ?>').val('0');}"/>
1617
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1618 1618
                 <?php if ($is_required) { ?>
1619 1619
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1620 1620
                 <?php } ?>
@@ -1623,44 +1623,44 @@  discard block
 block discarded – undo
1623 1623
         <?php } elseif ($type == 'textarea') {
1624 1624
             ?>
1625 1625
 
1626
-            <div id="<?php echo $name;?>_row"
1627
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1626
+            <div id="<?php echo $name; ?>_row"
1627
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1628 1628
                 <label>
1629 1629
                     <?php $site_title = __($site_title, 'geodirectory');
1630 1630
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1631
-                    <?php if ($is_required) echo '<span>*</span>';?>
1631
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1632 1632
                 </label><?php
1633 1633
 
1634 1634
 
1635 1635
                 if (is_array($extra_fields) && in_array('1', $extra_fields)) {
1636 1636
 
1637
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?>
1637
+                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); ?>
1638 1638
 
1639
-                <div class="editor" field_id="<?php echo $name;?>" field_type="editor">
1639
+                <div class="editor" field_id="<?php echo $name; ?>" field_type="editor">
1640 1640
                     <?php wp_editor(stripslashes($value), $name, $editor_settings); ?>
1641 1641
                     </div><?php
1642 1642
 
1643 1643
                 } else {
1644 1644
 
1645
-                    ?><textarea field_type="<?php echo $type;?>" class="geodir_textarea" name="<?php echo $name;?>"
1646
-                                id="<?php echo $name;?>"><?php echo stripslashes($value);?></textarea><?php
1645
+                    ?><textarea field_type="<?php echo $type; ?>" class="geodir_textarea" name="<?php echo $name; ?>"
1646
+                                id="<?php echo $name; ?>"><?php echo stripslashes($value); ?></textarea><?php
1647 1647
 
1648 1648
                 }?>
1649 1649
 
1650 1650
 
1651
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1651
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1652 1652
                 <?php if ($is_required) { ?>
1653 1653
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1654 1654
                 <?php } ?>
1655 1655
             </div>
1656 1656
 
1657 1657
         <?php } elseif ($type == 'select') { ?>
1658
-            <div id="<?php echo $name;?>_row"
1659
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>">
1658
+            <div id="<?php echo $name; ?>_row"
1659
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class; ?>">
1660 1660
                 <label>
1661 1661
                     <?php $site_title = __($site_title, 'geodirectory');
1662 1662
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1663
-                    <?php if ($is_required) echo '<span>*</span>';?>
1663
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1664 1664
                 </label>
1665 1665
                 <?php
1666 1666
                 $option_values_arr = geodir_string_values_to_options($option_values, true);
@@ -1681,11 +1681,11 @@  discard block
 block discarded – undo
1681 1681
                     }
1682 1682
                 }
1683 1683
                 ?>
1684
-                <select field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1684
+                <select field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>"
1685 1685
                         class="geodir_textfield textfield_x chosen_select"
1686
-                        data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '&hellip;';?>"
1687
-                        option-ajaxchosen="false"><?php echo $select_options;?></select>
1688
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1686
+                        data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '&hellip;'; ?>"
1687
+                        option-ajaxchosen="false"><?php echo $select_options; ?></select>
1688
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1689 1689
                 <?php if ($is_required) { ?>
1690 1690
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1691 1691
                 <?php } ?>
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
             }
1700 1700
             ?>
1701 1701
             <div id="<?php echo $name; ?>_row"
1702
-                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1702
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1703 1703
                 <label>
1704 1704
                     <?php $site_title = __($site_title, 'geodirectory');
1705 1705
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
             ?>
1774 1774
 
1775 1775
             <div id="<?php echo $name; ?>_row"
1776
-                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1776
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1777 1777
                 <label>
1778 1778
                     <?php $site_title = __($site_title, 'geodirectory');
1779 1779
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
@@ -1803,8 +1803,8 @@  discard block
 block discarded – undo
1803 1803
 
1804 1804
             $date_format = str_replace($search, $replace, $extra_fields['date_format']);
1805 1805
 
1806
-            if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty
1807
-            if($value && !isset($_REQUEST['backandedit'])) {
1806
+            if ($value == '0000-00-00') {$value = ''; }//if date not set, then mark it empty
1807
+            if ($value && !isset($_REQUEST['backandedit'])) {
1808 1808
                 $time = strtotime($value);
1809 1809
                 $value = date($date_format, $time);
1810 1810
             }
@@ -1814,37 +1814,37 @@  discard block
 block discarded – undo
1814 1814
 
1815 1815
                 jQuery(function () {
1816 1816
 
1817
-                    jQuery("#<?php echo $name;?>").datepicker({changeMonth: true, changeYear: true <?php
1817
+                    jQuery("#<?php echo $name; ?>").datepicker({changeMonth: true, changeYear: true <?php
1818 1818
                     /**
1819 1819
                      * Used to add extra option to datepicker per custom field.
1820 1820
                      *
1821 1821
                      * @since 1.5.7
1822 1822
                      * @param string $name The custom field name.
1823 1823
                      */
1824
-                    echo apply_filters("gd_datepicker_extra_{$name}",'');?>});
1824
+                    echo apply_filters("gd_datepicker_extra_{$name}", ''); ?>});
1825 1825
 
1826
-                    jQuery("#<?php echo $name;?>").datepicker("option", "dateFormat", '<?php echo $extra_fields['date_format'];?>');
1826
+                    jQuery("#<?php echo $name; ?>").datepicker("option", "dateFormat", '<?php echo $extra_fields['date_format']; ?>');
1827 1827
 
1828
-                    <?php if(!empty($value)){?>
1829
-                    jQuery("#<?php echo $name;?>").datepicker("setDate", "<?php echo $value;?>");
1828
+                    <?php if (!empty($value)) {?>
1829
+                    jQuery("#<?php echo $name; ?>").datepicker("setDate", "<?php echo $value; ?>");
1830 1830
                     <?php } ?>
1831 1831
 
1832 1832
                 });
1833 1833
 
1834 1834
             </script>
1835
-            <div id="<?php echo $name;?>_row"
1836
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1835
+            <div id="<?php echo $name; ?>_row"
1836
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1837 1837
                 <label>
1838 1838
 
1839 1839
                     <?php $site_title = __($site_title, 'geodirectory');
1840 1840
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1841
-                    <?php if ($is_required) echo '<span>*</span>';?>
1841
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1842 1842
                 </label>
1843 1843
 
1844
-                <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1845
-                       value="<?php echo esc_attr($value);?>" type="text" class="geodir_textfield"/>
1844
+                <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>"
1845
+                       value="<?php echo esc_attr($value); ?>" type="text" class="geodir_textfield"/>
1846 1846
 
1847
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1847
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1848 1848
                 <?php if ($is_required) { ?>
1849 1849
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1850 1850
                 <?php } ?>
@@ -1858,25 +1858,25 @@  discard block
 block discarded – undo
1858 1858
             <script type="text/javascript">
1859 1859
                 jQuery(document).ready(function () {
1860 1860
 
1861
-                    jQuery('#<?php echo $name;?>').timepicker({
1861
+                    jQuery('#<?php echo $name; ?>').timepicker({
1862 1862
                         showPeriod: true,
1863 1863
                         showLeadingZero: true,
1864 1864
                         showPeriod: true,
1865 1865
                     });
1866 1866
                 });
1867 1867
             </script>
1868
-            <div id="<?php echo $name;?>_row"
1869
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1868
+            <div id="<?php echo $name; ?>_row"
1869
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1870 1870
                 <label>
1871 1871
 
1872 1872
                     <?php $site_title = __($site_title, 'geodirectory');
1873 1873
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1874
-                    <?php if ($is_required) echo '<span>*</span>';?>
1874
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1875 1875
                 </label>
1876
-                <input readonly="readonly" field_type="<?php echo $type;?>" name="<?php echo $name;?>"
1877
-                       id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>" type="text" class="geodir_textfield"/>
1876
+                <input readonly="readonly" field_type="<?php echo $type; ?>" name="<?php echo $name; ?>"
1877
+                       id="<?php echo $name; ?>" value="<?php echo esc_attr($value); ?>" type="text" class="geodir_textfield"/>
1878 1878
 
1879
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1879
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1880 1880
                 <?php if ($is_required) { ?>
1881 1881
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1882 1882
                 <?php } ?>
@@ -1886,15 +1886,15 @@  discard block
 block discarded – undo
1886 1886
             if ($value == $val['default']) {
1887 1887
                 $value = '';
1888 1888
             } ?>
1889
-            <div id="<?php echo $name;?>_row"
1890
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1889
+            <div id="<?php echo $name; ?>_row"
1890
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
1891 1891
                 <label>
1892 1892
                     <?php $site_title = __($site_title, 'geodirectory');
1893 1893
                     echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1894
-                    <?php if ($is_required) echo '<span>*</span>';?>
1894
+                    <?php if ($is_required) echo '<span>*</span>'; ?>
1895 1895
                 </label>
1896 1896
 
1897
-                <div id="<?php echo $name;?>" class="geodir_taxonomy_field" style="float:left; width:70%;">
1897
+                <div id="<?php echo $name; ?>" class="geodir_taxonomy_field" style="float:left; width:70%;">
1898 1898
                     <?php
1899 1899
                     global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats;
1900 1900
 
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
 
1907 1907
                         $package_info = array();
1908 1908
 
1909
-                        $package_info = (array)geodir_post_package_info($package_info, $post, $post_type);
1909
+                        $package_info = (array) geodir_post_package_info($package_info, $post, $post_type);
1910 1910
 
1911 1911
                         if (!empty($package_info)) {
1912 1912
 
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
                     ?>
1990 1990
                 </div>
1991 1991
 
1992
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1992
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1993 1993
                 <?php if ($is_required) { ?>
1994 1994
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
1995 1995
                 <?php } ?>
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
                     $file_totImg = count($curImages);
2032 2032
             }
2033 2033
 			
2034
-			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
2034
+			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? implode(",", $extra_fields['gd_file_types']) : '';
2035 2035
 			$display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
2036 2036
 
2037 2037
             ?>
@@ -2042,13 +2042,13 @@  discard block
 block discarded – undo
2042 2042
 			</h5>   <?php */
2043 2043
             ?>
2044 2044
 
2045
-            <div id="<?php echo $name;?>_row"
2046
-                 class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
2045
+            <div id="<?php echo $name; ?>_row"
2046
+                 class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>">
2047 2047
 
2048 2048
                 <div id="<?php echo $file_id; ?>dropbox" style="text-align:center;">
2049 2049
                     <label
2050 2050
                         style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory');
2051
-                        echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label>
2051
+                        echo $site_title; ?><?php if ($is_required) echo '<span>*</span>'; ?></label>
2052 2052
                     <input class="geodir-custom-file-upload" field_type="file" type="hidden"
2053 2053
                            name="<?php echo $file_id; ?>" id="<?php echo $file_id; ?>"
2054 2054
                            value="<?php echo esc_attr($file_value); ?>"/>
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
                            id="<?php echo $file_id; ?>image_limit" value="<?php echo $file_image_limit; ?>"/>
2057 2057
 					<?php if ($allowed_file_types != '') { ?>
2058 2058
 					<input type="hidden" name="<?php echo $file_id; ?>_allowed_types"
2059
-                           id="<?php echo $file_id; ?>_allowed_types" value="<?php echo esc_attr($allowed_file_types); ?>" data-exts="<?php echo esc_attr($display_file_types);?>"/>
2059
+                           id="<?php echo $file_id; ?>_allowed_types" value="<?php echo esc_attr($allowed_file_types); ?>" data-exts="<?php echo esc_attr($display_file_types); ?>"/>
2060 2060
 					<?php } ?>
2061 2061
                     <input type="hidden" name="<?php echo $file_id; ?>totImg" id="<?php echo $file_id; ?>totImg"
2062 2062
                            value="<?php if (isset($file_totImg)) {
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
                             <?php /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */
2073 2073
                             ?>
2074 2074
                             <input id="<?php echo $file_id; ?>plupload-browse-button" type="button"
2075
-                                   value="<?php ($file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory') ); ?>"
2075
+                                   value="<?php ($file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory')); ?>"
2076 2076
                                    class="geodir_button" style="margin-top:10px;"/>
2077 2077
                             <span class="ajaxnonceplu"
2078 2078
                                   id="ajaxnonceplu<?php echo wp_create_nonce($file_id . 'pluploadan'); ?>"></span>
@@ -2095,7 +2095,7 @@  discard block
 block discarded – undo
2095 2095
 
2096 2096
                     </div>
2097 2097
                 </div>
2098
-                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?> <?php echo ( $display_file_types != '' ? __('Allowed file types:', 'geodirectory') . ' ' . $display_file_types : '' );?></span>
2098
+                <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> <?php echo ($display_file_types != '' ? __('Allowed file types:', 'geodirectory') . ' ' . $display_file_types : ''); ?></span>
2099 2099
                 <?php if ($is_required) { ?>
2100 2100
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
2101 2101
                 <?php } ?>
@@ -2200,7 +2200,7 @@  discard block
 block discarded – undo
2200 2200
 
2201 2201
                 $variables_array = array();
2202 2202
 
2203
-                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'))) {
2203
+                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'))) {
2204 2204
                     continue;
2205 2205
                 }
2206 2206
 
@@ -2226,12 +2226,12 @@  discard block
 block discarded – undo
2226 2226
 
2227 2227
                     case 'fieldset':
2228 2228
 
2229
-                        $fieldset_class = 'fieldset-'.sanitize_title_with_dashes($type['site_title']);
2229
+                        $fieldset_class = 'fieldset-' . sanitize_title_with_dashes($type['site_title']);
2230 2230
 
2231 2231
                         if ($field_set_start == 1) {
2232
-                            echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>';
2232
+                            echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="' . $fieldset_class . '">' . __($type['site_title'], 'geodirectory') . '</h2>';
2233 2233
                         } else {
2234
-                            echo '<h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>';
2234
+                            echo '<h2 class="' . $fieldset_class . '">' . __($type['site_title'], 'geodirectory') . '</h2>';
2235 2235
                             $field_set_start = 1;
2236 2236
                         }
2237 2237
 
@@ -2403,7 +2403,7 @@  discard block
 block discarded – undo
2403 2403
 
2404 2404
 							$website = !empty($a_url['url']) ? $a_url['url'] : '';
2405 2405
 							$title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title'];
2406
-                            if(!empty($type['default_value'])){$title = $type['default_value'];}
2406
+                            if (!empty($type['default_value'])) {$title = $type['default_value']; }
2407 2407
 							$title = $title != '' ? __(stripslashes($title), 'geodirectory') : '';
2408 2408
 
2409 2409
 
@@ -2516,17 +2516,17 @@  discard block
 block discarded – undo
2516 2516
                                 $date_format = $date_format['date_format'];
2517 2517
                             }
2518 2518
 
2519
-                            $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
2520
-                            $replace = array('d','j','l','m','n','F','Y');//PHP date format
2519
+                            $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format
2520
+                            $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format
2521 2521
 
2522 2522
                             $date_format = str_replace($search, $replace, $date_format);
2523 2523
 
2524 2524
                             $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
2525 2525
 
2526 2526
                             $value = '';
2527
-                            if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
2527
+                            if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']} != "0000-00-00") {
2528 2528
                                 $value = date($date_format, strtotime($post_htmlvar_value));
2529
-                            }else{
2529
+                            } else {
2530 2530
                                 continue;
2531 2531
                             }
2532 2532
 
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
 
2670 2670
                         $html_var = $type['htmlvar_name'];
2671 2671
 
2672
-                        if ((int)$post->$html_var == 1):
2672
+                        if ((int) $post->$html_var == 1):
2673 2673
 
2674 2674
                             if ($post->{$type['htmlvar_name']} == '1'):
2675 2675
                                 $html_val = __('Yes', 'geodirectory');
@@ -2897,8 +2897,8 @@  discard block
 block discarded – undo
2897 2897
                                 $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
2898 2898
                                 $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2899 2899
                                 $html .= '</span><span class="geodir-email-address-output">';
2900
-                                $email = stripslashes($post->{$type['htmlvar_name']}) ;
2901
-                                if($e_split = explode('@',$email)){
2900
+                                $email = stripslashes($post->{$type['htmlvar_name']});
2901
+                                if ($e_split = explode('@', $email)) {
2902 2902
                                     /**
2903 2903
                                      * Filter email custom field name output.
2904 2904
                                      *
@@ -2907,10 +2907,10 @@  discard block
 block discarded – undo
2907 2907
                                      * @param string $email The email string being output.
2908 2908
                                      * @param array $type Custom field variables array.
2909 2909
                                      */
2910
-                                    $email_name = apply_filters('geodir_email_field_name_output',$email,$type);
2911
-                                    $html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
2912
-                                }else{
2913
-                                    $html .=  $email;
2910
+                                    $email_name = apply_filters('geodir_email_field_name_output', $email, $type);
2911
+                                    $html .= "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
2912
+                                } else {
2913
+                                    $html .= $email;
2914 2914
                                 }
2915 2915
                                 $html .= '</span></div>';
2916 2916
                             }
@@ -2930,7 +2930,7 @@  discard block
 block discarded – undo
2930 2930
                             if (!empty($files)):
2931 2931
 
2932 2932
                                $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL;
2933
-							   $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'] : '';
2933
+							   $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'] : '';
2934 2934
 								
2935 2935
 								$file_paths = '';
2936 2936
                                 foreach ($files as $file) {
@@ -2961,7 +2961,7 @@  discard block
 block discarded – undo
2961 2961
                                         // If the uploaded file is image
2962 2962
                                         if (in_array($uploaded_file_type, $image_file_types)) {
2963 2963
                                             $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
2964
-                                            $file_paths .= '<a href="'.$file.'">';
2964
+                                            $file_paths .= '<a href="' . $file . '">';
2965 2965
 											$file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
2966 2966
 											$file_paths .= '</a>';
2967 2967
                                             //$file_paths .= '<img src="'.$file.'"  />';	
@@ -3098,7 +3098,7 @@  discard block
 block discarded – undo
3098 3098
                                     $terms = $termsOrdered;
3099 3099
                                 }
3100 3100
                             }
3101
-                            $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
3101
+                            $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object) $terms) : '';
3102 3102
 
3103 3103
                             if ($html_value != '') {
3104 3104
                                 if (strpos($field_icon, 'http') !== false) {
@@ -3260,7 +3260,7 @@  discard block
 block discarded – undo
3260 3260
             $geodir_uploadurl = $uploads['url'];
3261 3261
             $sub_dir = $uploads['subdir'];
3262 3262
 			
3263
-			$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'] : '';
3263
+			$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'] : '';
3264 3264
 
3265 3265
             for ($m = 0; $m < count($post_image); $m++) {
3266 3266
 
@@ -3331,8 +3331,8 @@  discard block
 block discarded – undo
3331 3331
         if (!empty($postcurr_images)) {
3332 3332
 
3333 3333
             if ($file_urls != $postcurr_images) {
3334
-                $invalid_files[] = (object)array('src' => $postcurr_images);
3335
-                $invalid_files = (object)$invalid_files;
3334
+                $invalid_files[] = (object) array('src' => $postcurr_images);
3335
+                $invalid_files = (object) $invalid_files;
3336 3336
             }
3337 3337
         }
3338 3338
 
@@ -3414,7 +3414,7 @@  discard block
 block discarded – undo
3414 3414
         // remove handle custom file uploaddir
3415 3415
         remove_filter('upload_dir', 'geodir_upload_dir');
3416 3416
 
3417
-        if(!isset($status['url']) && isset($status['error'])){
3417
+        if (!isset($status['url']) && isset($status['error'])) {
3418 3418
             print_r($status);
3419 3419
         }
3420 3420
 
@@ -3490,10 +3490,10 @@  discard block
 block discarded – undo
3490 3490
 	 */
3491 3491
 	function geodir_max_upload_size()
3492 3492
     {
3493
-        $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
3493
+        $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
3494 3494
 
3495 3495
         if ($max_filesize > 0 && $max_filesize < 1) {
3496
-            $max_filesize = (int)($max_filesize * 1024) . 'kb';
3496
+            $max_filesize = (int) ($max_filesize * 1024) . 'kb';
3497 3497
         } else {
3498 3498
             $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
3499 3499
         }
@@ -3801,7 +3801,7 @@  discard block
 block discarded – undo
3801 3801
         }
3802 3802
 
3803 3803
 
3804
-        return (int)$lastid;
3804
+        return (int) $lastid;
3805 3805
 
3806 3806
     }
3807 3807
 }
@@ -3892,38 +3892,38 @@  discard block
 block discarded – undo
3892 3892
         $nonce = wp_create_nonce('custom_fields_' . $result_str);
3893 3893
         
3894 3894
         ?>
3895
-        <li class="text" id="licontainer_<?php echo $result_str;?>">
3896
-            <div class="title title<?php echo $result_str;?> gt-fieldset"
3897
-                 title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory');?>"
3898
-                 ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
3895
+        <li class="text" id="licontainer_<?php echo $result_str; ?>">
3896
+            <div class="title title<?php echo $result_str; ?> gt-fieldset"
3897
+                 title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory'); ?>"
3898
+                 ondblclick="show_hide('field_frm<?php echo $result_str; ?>')">
3899 3899
                 <?php
3900 3900
 
3901 3901
                 $nonce = wp_create_nonce('custom_fields_' . $result_str);
3902 3902
                 ?>
3903 3903
 
3904
-                <div title="<?php _e('Click to remove field', 'geodirectory');?>"
3905
-                     onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
3904
+                <div title="<?php _e('Click to remove field', 'geodirectory'); ?>"
3905
+                     onclick="delete_sort_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>', this)"
3906 3906
                      class="handlediv close"></div>
3907 3907
 
3908 3908
                 <b style="cursor:pointer;"
3909
-                   onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(__('Field:', 'geodirectory') . ' (' . $site_title . ')');?></b>
3909
+                   onclick="show_hide('field_frm<?php echo $result_str; ?>')"><?php echo geodir_ucwords(__('Field:', 'geodirectory') . ' (' . $site_title . ')'); ?></b>
3910 3910
 
3911 3911
             </div>
3912 3912
 
3913
-            <div id="field_frm<?php echo $result_str;?>" class="field_frm"
3913
+            <div id="field_frm<?php echo $result_str; ?>" class="field_frm"
3914 3914
                  style="display:<?php if ($field_ins_upd == 'submit') {
3915 3915
                      echo 'block;';
3916 3916
                  } else {
3917 3917
                      echo 'none;';
3918 3918
                  } ?>">
3919 3919
                 <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
3920
-                <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/>
3921
-                <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/>
3922
-                <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/>
3920
+                <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type; ?>"/>
3921
+                <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?>"/>
3922
+                <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str; ?>"/>
3923 3923
                 <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
3924 3924
                     echo $field_info->data_type;
3925 3925
                 }?>"/>
3926
-                <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/>
3926
+                <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name; ?>"/>
3927 3927
 
3928 3928
 
3929 3929
                 <table class="widefat post fixed" border="0" style="width:100%;">
@@ -4005,42 +4005,42 @@  discard block
 block discarded – undo
4005 4005
                     <?php } ?>
4006 4006
 
4007 4007
                     <tr>
4008
-                        <td><strong><?php _e('Is active :', 'geodirectory');?></strong></td>
4008
+                        <td><strong><?php _e('Is active :', 'geodirectory'); ?></strong></td>
4009 4009
                         <td align="left">
4010 4010
                             <select name="is_active" id="is_active">
4011 4011
                                 <option
4012 4012
                                     value="1" <?php if (isset($field_info->is_active) && $field_info->is_active == '1') {
4013 4013
                                     echo 'selected="selected"';
4014
-                                }?>><?php _e('Yes', 'geodirectory');?></option>
4014
+                                }?>><?php _e('Yes', 'geodirectory'); ?></option>
4015 4015
                                 <option
4016 4016
                                     value="0" <?php if (isset($field_info->is_active) && $field_info->is_active == '0') {
4017 4017
                                     echo 'selected="selected"';
4018
-                                }?>><?php _e('No', 'geodirectory');?></option>
4018
+                                }?>><?php _e('No', 'geodirectory'); ?></option>
4019 4019
                             </select>
4020 4020
                             <br/>
4021
-                            <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory');?></span>
4021
+                            <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory'); ?></span>
4022 4022
                         </td>
4023 4023
                     </tr>
4024 4024
 
4025 4025
                     <tr>
4026
-                        <td><strong><?php _e('Display order :', 'geodirectory');?></strong></td>
4026
+                        <td><strong><?php _e('Display order :', 'geodirectory'); ?></strong></td>
4027 4027
                         <td align="left"><input type="text" readonly="readonly" name="sort_order" id="sort_order"
4028 4028
                                                 value="<?php if (isset($field_info->sort_order)) {
4029 4029
                                                     echo esc_attr($field_info->sort_order);
4030 4030
                                                 }?>" size="50"/>
4031 4031
                             <br/>
4032
-                            <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory');?></span>
4032
+                            <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory'); ?></span>
4033 4033
                         </td>
4034 4034
                     </tr>
4035 4035
 
4036 4036
                     <tr>
4037 4037
                         <td>&nbsp;</td>
4038 4038
                         <td align="left">
4039
-                            <input type="button" class="button" name="save" id="save" value="<?php esc_attr_e('Save', 'geodirectory');?>"
4040
-                                   onclick="save_sort_field('<?php echo $result_str;?>')"/>
4039
+                            <input type="button" class="button" name="save" id="save" value="<?php esc_attr_e('Save', 'geodirectory'); ?>"
4040
+                                   onclick="save_sort_field('<?php echo $result_str; ?>')"/>
4041 4041
 
4042
-                            <a href="javascript:void(0)"><input type="button" name="delete" value="<?php esc_attr_e('Delete', 'geodirectory');?>"
4043
-                                                                onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
4042
+                            <a href="javascript:void(0)"><input type="button" name="delete" value="<?php esc_attr_e('Delete', 'geodirectory'); ?>"
4043
+                                                                onclick="delete_sort_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>', this)"
4044 4044
                                                                 class="button_n"/></a>
4045 4045
 
4046 4046
                         </td>
@@ -4075,7 +4075,7 @@  discard block
 block discarded – undo
4075 4075
         if (!$package_id || !$field_name || !$post_type) {
4076 4076
             return true;
4077 4077
         }
4078
-        $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));
4078
+        $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));
4079 4079
 
4080 4080
         if ($wpdb->get_var($sql)) {
4081 4081
             return true;
Please login to merge, or discard this patch.
Indentation   +2441 added lines, -2441 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Custom fields functions
4
- *
5
- * @since 1.0.0
6
- * @package GeoDirectory
7
- * @global object $wpdb WordPress Database object.
8
- * @global string $table_prefix WordPress Database Table prefix.
9
- */
3
+	 * Custom fields functions
4
+	 *
5
+	 * @since 1.0.0
6
+	 * @package GeoDirectory
7
+	 * @global object $wpdb WordPress Database object.
8
+	 * @global string $table_prefix WordPress Database Table prefix.
9
+	 */
10 10
 global $wpdb, $table_prefix;
11 11
 
12 12
 if (!function_exists('geodir_column_exist')) {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @since 1.0.0
17 17
 	 * @package GeoDirectory
18
-     * @global object $wpdb WordPress Database object.
18
+	 * @global object $wpdb WordPress Database object.
19 19
 	 * @param string $db The table name.
20 20
 	 * @param string $column The column name.
21 21
 	 * @return bool If column exists returns true. Otherwise false.
22 22
 	 */
23 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
-    }
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')) {
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @since 1.0.0
43 43
 	 * @package GeoDirectory
44
-     * @global object $wpdb WordPress Database object.
44
+	 * @global object $wpdb WordPress Database object.
45 45
 	 * @param string $db The table name.
46 46
 	 * @param string $column The column name.
47 47
 	 * @param string $column_attr The column attributes.
48 48
 	 */
49 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
-    }
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,83 +72,83 @@  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_default IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query = " and is_default = '0' ";
89
-
90
-    if ($fields_location == 'detail') {
91
-        $default_query = " and show_on_detail='1' ";
92
-    } elseif ($fields_location == 'listing') {
93
-        $default_query = " and show_on_listing='1' ";
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_default IN ('1') ";
87
+	elseif ($default == 'custom')
88
+		$default_query = " and is_default = '0' ";
89
+
90
+	if ($fields_location == 'detail') {
91
+		$default_query = " and show_on_detail='1' ";
92
+	} elseif ($fields_location == 'listing') {
93
+		$default_query = " and show_on_listing='1' ";
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 154
 if (!function_exists('geodir_custom_field_adminhtml')) {
@@ -157,32 +157,32 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @since 1.0.0
159 159
 	 * @package GeoDirectory
160
-     * @global object $wpdb WordPress Database object.
160
+	 * @global object $wpdb WordPress Database object.
161 161
 	 * @param string $field_type The form field type.
162 162
 	 * @param object|int $result_str The custom field results object or row id.
163 163
 	 * @param string $field_ins_upd When set to "submit" displays form.
164 164
 	 * @param bool $default when set to true field will be for admin use only.
165 165
 	 */
166 166
 	function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false)
167
-    {
168
-        global $wpdb;
169
-        $cf = $result_str;
170
-        if (!is_object($cf)) {
171
-
172
-            $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
173
-
174
-        } else {
175
-            $field_info = $cf;
176
-            $result_str = $cf->id;
177
-        }
178
-        /**
179
-         * Contains custom field html.
180
-         *
181
-         * @since 1.0.0
182
-         */
183
-        include('custom_field_html.php');
184
-
185
-    }
167
+	{
168
+		global $wpdb;
169
+		$cf = $result_str;
170
+		if (!is_object($cf)) {
171
+
172
+			$field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
173
+
174
+		} else {
175
+			$field_info = $cf;
176
+			$result_str = $cf->id;
177
+		}
178
+		/**
179
+		 * Contains custom field html.
180
+		 *
181
+		 * @since 1.0.0
182
+		 */
183
+		include('custom_field_html.php');
184
+
185
+	}
186 186
 }
187 187
 
188 188
 if (!function_exists('geodir_custom_field_delete')) {
@@ -192,59 +192,59 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.0.0
193 193
 	 * @since 1.5.7 Delete field from sorting fields table when custom field deleted.
194 194
 	 * @package GeoDirectory
195
-     * @global object $wpdb WordPress Database object.
196
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
195
+	 * @global object $wpdb WordPress Database object.
196
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
197 197
 	 * @param string $field_id The custom field ID.
198 198
 	 * @return int|string If field deleted successfully, returns field id. Otherwise returns 0.
199 199
 	 */
200 200
 	function geodir_custom_field_delete($field_id = '') {
201
-        global $wpdb, $plugin_prefix;
201
+		global $wpdb, $plugin_prefix;
202 202
         
203 203
 		if ($field_id != '') {
204
-            $cf = trim($field_id, '_');
204
+			$cf = trim($field_id, '_');
205 205
 
206
-            if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
207
-                $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
206
+			if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
207
+				$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
208 208
 
209
-                $post_type = $field->post_type;
209
+				$post_type = $field->post_type;
210 210
 				$htmlvar_name = $field->htmlvar_name;
211 211
 				
212 212
 				if ($post_type != '' && $htmlvar_name != '') {
213 213
 					$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)));
214 214
 				}
215 215
 
216
-                /**
217
-                 * Called after a custom field is deleted.
218
-                 *
219
-                 * @since 1.0.0
220
-                 * @param string $cf The fields ID.
221
-                 * @param string $field->htmlvar_name The html variable name for the field.
222
-                 * @param string $post_type The post type the field belongs to.
223
-                 */
224
-                do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
225
-
226
-                if ($field->field_type == 'address') {
227
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
228
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
229
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
230
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
231
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
232
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
233
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
234
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
235
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
236
-                } else {
237
-                    if ($field->field_type != 'fieldset') {
238
-                        $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
239
-                    }
240
-                }
241
-
242
-                return $field_id;
243
-            } else
244
-                return 0;
245
-        } else
246
-            return 0;
247
-    }
216
+				/**
217
+				 * Called after a custom field is deleted.
218
+				 *
219
+				 * @since 1.0.0
220
+				 * @param string $cf The fields ID.
221
+				 * @param string $field->htmlvar_name The html variable name for the field.
222
+				 * @param string $post_type The post type the field belongs to.
223
+				 */
224
+				do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
225
+
226
+				if ($field->field_type == 'address') {
227
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
228
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
229
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
230
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
231
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
232
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
233
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
234
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
235
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
236
+				} else {
237
+					if ($field->field_type != 'fieldset') {
238
+						$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
239
+					}
240
+				}
241
+
242
+				return $field_id;
243
+			} else
244
+				return 0;
245
+		} else
246
+			return 0;
247
+	}
248 248
 }
249 249
 
250 250
 if (!function_exists('geodir_custom_field_save')) {
@@ -252,519 +252,519 @@  discard block
 block discarded – undo
252 252
 	 * Save or Update custom fields into the database.
253 253
 	 *
254 254
 	 * @since 1.0.0
255
-     * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
255
+	 * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
256 256
 	 * @package GeoDirectory
257
-     * @global object $wpdb WordPress Database object.
258
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
257
+	 * @global object $wpdb WordPress Database object.
258
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
259 259
 	 * @param array $request_field {
260
-     *    Attributes of the request field array.
261
-     *
262
-     *    @type string $action Ajax Action name. Default "geodir_ajax_action".
263
-     *    @type string $manage_field_type Field type Default "custom_fields".
264
-     *    @type string $create_field Create field Default "true".
265
-     *    @type string $field_ins_upd Field ins upd Default "submit".
266
-     *    @type string $_wpnonce WP nonce value.
267
-     *    @type string $listing_type Listing type Example "gd_place".
268
-     *    @type string $field_type Field type Example "radio".
269
-     *    @type string $field_id Field id Example "12".
270
-     *    @type string $data_type Data type Example "VARCHAR".
271
-     *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
272
-     *    @type array $show_on_pkg Package list to display this field.
273
-     *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
274
-     *    @type string $site_title Section title which you wish to display in frontend.
275
-     *    @type string $admin_desc Section description which will appear in frontend.
276
-     *    @type string $htmlvar_name Html variable name. This should be a unique name.
277
-     *    @type string $clabels Section Title which will appear in backend.
278
-     *    @type string $default_value The default value (for "link" this will be used as the link text).
279
-     *    @type string $sort_order The display order of this field in backend. e.g. 5.
280
-     *    @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.
281
-     *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
282
-     *    @type string $is_required Use "1" to set field as required.
283
-     *    @type string $required_msg Enter text for error message if field required and have not full fill requirment.
284
-     *    @type string $show_on_listing Want to show this on listing page?.
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
-     * }
260
+	 *    Attributes of the request field array.
261
+	 *
262
+	 *    @type string $action Ajax Action name. Default "geodir_ajax_action".
263
+	 *    @type string $manage_field_type Field type Default "custom_fields".
264
+	 *    @type string $create_field Create field Default "true".
265
+	 *    @type string $field_ins_upd Field ins upd Default "submit".
266
+	 *    @type string $_wpnonce WP nonce value.
267
+	 *    @type string $listing_type Listing type Example "gd_place".
268
+	 *    @type string $field_type Field type Example "radio".
269
+	 *    @type string $field_id Field id Example "12".
270
+	 *    @type string $data_type Data type Example "VARCHAR".
271
+	 *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
272
+	 *    @type array $show_on_pkg Package list to display this field.
273
+	 *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
274
+	 *    @type string $site_title Section title which you wish to display in frontend.
275
+	 *    @type string $admin_desc Section description which will appear in frontend.
276
+	 *    @type string $htmlvar_name Html variable name. This should be a unique name.
277
+	 *    @type string $clabels Section Title which will appear in backend.
278
+	 *    @type string $default_value The default value (for "link" this will be used as the link text).
279
+	 *    @type string $sort_order The display order of this field in backend. e.g. 5.
280
+	 *    @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.
281
+	 *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
282
+	 *    @type string $is_required Use "1" to set field as required.
283
+	 *    @type string $required_msg Enter text for error message if field required and have not full fill requirment.
284
+	 *    @type string $show_on_listing Want to show this on listing page?.
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 292
 	 * @param bool $default Not yet implemented.
293 293
 	 * @return int|string If field is unique returns inserted row id. Otherwise returns error string.
294 294
 	 */
295 295
 	function geodir_custom_field_save($request_field = array(), $default = false)
296
-    {
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
+
297 313
 
298
-        global $wpdb, $plugin_prefix;
314
+		/*-------- check dublicate validation --------*/
299 315
 
300
-        $old_html_variable = '';
316
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
317
+		$post_type = $request_field['listing_type'];
301 318
 
302
-        $data_type = trim($request_field['data_type']);
319
+		if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
320
+			$cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
321
+		}
303 322
 
304
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
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
+		);
305 329
 
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 330
 
311
-        $cf = trim($result_str, '_');
331
+		if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
312 332
 
333
+			if ($cf != '') {
313 334
 
314
-        /*-------- check dublicate validation --------*/
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
+				);
315 341
 
316
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
317
-        $post_type = $request_field['listing_type'];
342
+			}
318 343
 
319
-        if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
320
-            $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
321
-        }
344
+			if (!empty($post_meta_info)) {
345
+				$post_val = $post_meta_info;
346
+				$old_html_variable = $post_val->htmlvar_name;
322 347
 
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
-        );
348
+			}
329 349
 
330 350
 
331
-        if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
332 351
 
333
-            if ($cf != '') {
352
+			if ($post_type == '') $post_type = 'gd_place';
334 353
 
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 354
 
342
-            }
355
+			$detail_table = $plugin_prefix . $post_type . '_detail';
343 356
 
344
-            if (!empty($post_meta_info)) {
345
-                $post_val = $post_meta_info;
346
-                $old_html_variable = $post_val->htmlvar_name;
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
+			$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
362
+			$admin_desc = $request_field['admin_desc'];
363
+			$clabels = $request_field['clabels'];
364
+			$default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
365
+			$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
366
+			$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
367
+			$is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
368
+			$required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
369
+			$css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
370
+			$field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
371
+			$show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
372
+			$show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
373
+			$show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
374
+			$decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
375
+			$decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
376
+			$validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
377
+			$validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
378
+			$for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
347 379
 
348
-            }
380
+			if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
381
+				$htmlvar_name = 'geodir_' . $htmlvar_name;
382
+			}
349 383
 
384
+			$option_values = '';
385
+			if (isset($request_field['option_values']))
386
+				$option_values = $request_field['option_values'];
350 387
 
388
+			$cat_sort = '';
389
+			if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort']))
390
+				$cat_sort = implode(",", $request_field['cat_sort']);
351 391
 
352
-            if ($post_type == '') $post_type = 'gd_place';
392
+			$cat_filter = '';
393
+			if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter']))
394
+				$cat_filter = implode(",", $request_field['cat_filter']);
353 395
 
396
+			if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
397
+				$price_pkg = implode(",", $request_field['show_on_pkg']);
398
+			else {
399
+				$package_info = array();
354 400
 
355
-            $detail_table = $plugin_prefix . $post_type . '_detail';
401
+				$package_info = geodir_post_package_info($package_info, '', $post_type);
402
+				$price_pkg = $package_info->pid;
403
+			}
356 404
 
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
-            $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
362
-            $admin_desc = $request_field['admin_desc'];
363
-            $clabels = $request_field['clabels'];
364
-            $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
365
-            $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
366
-            $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
367
-            $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
368
-            $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
369
-            $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
370
-            $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
371
-            $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
372
-            $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
373
-            $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
374
-            $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
375
-            $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
376
-            $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
377
-            $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
378
-            $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
379 405
 
380
-            if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
381
-                $htmlvar_name = 'geodir_' . $htmlvar_name;
382
-            }
406
+			if (isset($request_field['extra']) && !empty($request_field['extra']))
407
+				$extra_fields = $request_field['extra'];
383 408
 
384
-            $option_values = '';
385
-            if (isset($request_field['option_values']))
386
-                $option_values = $request_field['option_values'];
409
+			if (isset($request_field['is_default']) && $request_field['is_default'] != '')
410
+				$is_default = $request_field['is_default'];
411
+			else
412
+				$is_default = '0';
387 413
 
388
-            $cat_sort = '';
389
-            if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort']))
390
-                $cat_sort = implode(",", $request_field['cat_sort']);
414
+			if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
415
+				$is_admin = $request_field['is_admin'];
416
+			else
417
+				$is_admin = '0';
391 418
 
392
-            $cat_filter = '';
393
-            if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter']))
394
-                $cat_filter = implode(",", $request_field['cat_filter']);
395 419
 
396
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
397
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
398
-            else {
399
-                $package_info = array();
420
+			if ($is_active == '') $is_active = 1;
421
+			if ($is_required == '') $is_required = 0;
400 422
 
401
-                $package_info = geodir_post_package_info($package_info, '', $post_type);
402
-                $price_pkg = $package_info->pid;
403
-            }
404 423
 
424
+			if ($sort_order == '') {
405 425
 
406
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
407
-                $extra_fields = $request_field['extra'];
426
+				$last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
408 427
 
409
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
410
-                $is_default = $request_field['is_default'];
411
-            else
412
-                $is_default = '0';
428
+				$sort_order = (int)$last_order + 1;
429
+			}
413 430
 
414
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
415
-                $is_admin = $request_field['is_admin'];
416
-            else
417
-                $is_admin = '0';
431
+			$default_value_add = '';
418 432
 
433
+			if (!empty($post_meta_info)) {
434
+				switch ($field_type):
419 435
 
420
-            if ($is_active == '') $is_active = 1;
421
-            if ($is_required == '') $is_required = 0;
436
+					case 'address':
422 437
 
438
+						if ($htmlvar_name != '') {
439
+							$prefix = $htmlvar_name . '_';
440
+						}
441
+						$old_prefix = $old_html_variable . '_';
423 442
 
424
-            if ($sort_order == '') {
425 443
 
426
-                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
444
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
427 445
 
428
-                $sort_order = (int)$last_order + 1;
429
-            }
446
+						if ($default_value != '') {
447
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
448
+						}
430 449
 
431
-            $default_value_add = '';
450
+						$wpdb->query($meta_field_add);
432 451
 
433
-            if (!empty($post_meta_info)) {
434
-                switch ($field_type):
452
+						if ($extra_fields != '') {
435 453
 
436
-                    case 'address':
454
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
437 455
 
438
-                        if ($htmlvar_name != '') {
439
-                            $prefix = $htmlvar_name . '_';
440
-                        }
441
-                        $old_prefix = $old_html_variable . '_';
456
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
457
+								if ($is_column) {
458
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
442 459
 
460
+									if ($default_value != '') {
461
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
462
+									}
443 463
 
444
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
464
+									$wpdb->query($meta_field_add);
465
+								} else {
445 466
 
446
-                        if ($default_value != '') {
447
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
448
-                        }
467
+									$meta_field_add = "VARCHAR( 50 ) NULL";
468
+									if ($default_value != '') {
469
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
470
+									}
471
+									geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
449 472
 
450
-                        $wpdb->query($meta_field_add);
473
+								}
451 474
 
452
-                        if ($extra_fields != '') {
453 475
 
454
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
476
+							}
455 477
 
456
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
457
-                                if ($is_column) {
458
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
459 478
 
460
-                                    if ($default_value != '') {
461
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
462
-                                    }
479
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
463 480
 
464
-                                    $wpdb->query($meta_field_add);
465
-                                } else {
481
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
466 482
 
467
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
468
-                                    if ($default_value != '') {
469
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
470
-                                    }
471
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
483
+								if ($is_column) {
484
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
472 485
 
473
-                                }
486
+									if ($default_value != '') {
487
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
488
+									}
474 489
 
490
+									$wpdb->query($meta_field_add);
491
+								} else {
492
+									$meta_field_add = "VARCHAR( 50 ) NULL";
493
+									if ($default_value != '') {
494
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
495
+									}
475 496
 
476
-                            }
497
+									geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
498
+								}
477 499
 
500
+							}
501
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
478 502
 
479
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
503
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
480 504
 
481
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
505
+								if ($is_column) {
482 506
 
483
-                                if ($is_column) {
484
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
507
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
485 508
 
486
-                                    if ($default_value != '') {
487
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
488
-                                    }
509
+									if ($default_value != '') {
510
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
511
+									}
489 512
 
490
-                                    $wpdb->query($meta_field_add);
491
-                                } else {
492
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
493
-                                    if ($default_value != '') {
494
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
495
-                                    }
513
+									$wpdb->query($meta_field_add);
514
+								} else {
496 515
 
497
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
498
-                                }
516
+									$meta_field_add = "VARCHAR( 50 ) NULL";
517
+									if ($default_value != '') {
518
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
519
+									}
499 520
 
500
-                            }
501
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
521
+									geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
502 522
 
503
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
523
+								}
504 524
 
505
-                                if ($is_column) {
525
+							}
526
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
506 527
 
507
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
528
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
508 529
 
509
-                                    if ($default_value != '') {
510
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
511
-                                    }
530
+								if ($is_column) {
512 531
 
513
-                                    $wpdb->query($meta_field_add);
514
-                                } else {
532
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
515 533
 
516
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
517
-                                    if ($default_value != '') {
518
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
519
-                                    }
534
+									if ($default_value != '') {
535
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
536
+									}
520 537
 
521
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
538
+									$wpdb->query($meta_field_add);
539
+								} else {
522 540
 
523
-                                }
541
+									$meta_field_add = "VARCHAR( 50 ) NULL";
542
+									if ($default_value != '') {
543
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
544
+									}
524 545
 
525
-                            }
526
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
546
+									geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
527 547
 
528
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
548
+								}
529 549
 
530
-                                if ($is_column) {
550
+							}
551
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
531 552
 
532
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
553
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
554
+								if ($is_column) {
533 555
 
534
-                                    if ($default_value != '') {
535
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
536
-                                    }
556
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
537 557
 
538
-                                    $wpdb->query($meta_field_add);
539
-                                } else {
558
+									if ($default_value != '') {
559
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
560
+									}
540 561
 
541
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
542
-                                    if ($default_value != '') {
543
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
544
-                                    }
562
+									$wpdb->query($meta_field_add);
563
+								} else {
545 564
 
546
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
565
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
566
+									$meta_field_add = "VARCHAR( 20 ) NULL";
567
+									if ($default_value != '') {
568
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
569
+									}
547 570
 
548
-                                }
571
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
549 572
 
550
-                            }
551
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
573
+								}
552 574
 
553
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
554
-                                if ($is_column) {
555 575
 
556
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
576
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
557 577
 
558
-                                    if ($default_value != '') {
559
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
560
-                                    }
578
+								if ($is_column) {
579
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
561 580
 
562
-                                    $wpdb->query($meta_field_add);
563
-                                } else {
581
+									if ($default_value != '') {
582
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
583
+									}
564 584
 
565
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
566
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
567
-                                    if ($default_value != '') {
568
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
569
-                                    }
585
+									$wpdb->query($meta_field_add);
586
+								} else {
570 587
 
571
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
588
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
589
+									$meta_field_add = "VARCHAR( 20 ) NULL";
590
+									if ($default_value != '') {
591
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
592
+									}
572 593
 
573
-                                }
594
+									geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
595
+								}
574 596
 
597
+							}
598
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
575 599
 
576
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
600
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
577 601
 
578
-                                if ($is_column) {
579
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
602
+								if ($is_column) {
603
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
580 604
 
581
-                                    if ($default_value != '') {
582
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
583
-                                    }
605
+									if ($default_value != '') {
606
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
607
+									}
584 608
 
585
-                                    $wpdb->query($meta_field_add);
586
-                                } else {
609
+									$wpdb->query($meta_field_add);
610
+								} else {
587 611
 
588
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
589
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
590
-                                    if ($default_value != '') {
591
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
592
-                                    }
612
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
593 613
 
594
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
595
-                                }
614
+									$meta_field_add = "VARCHAR( 15 ) NULL";
615
+									if ($default_value != '') {
616
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
617
+									}
596 618
 
597
-                            }
598
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
619
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
620
+								}
599 621
 
600
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
601 622
 
602
-                                if ($is_column) {
603
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
623
+							}
624
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
604 625
 
605
-                                    if ($default_value != '') {
606
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
607
-                                    }
626
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
627
+								if ($is_column) {
628
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
608 629
 
609
-                                    $wpdb->query($meta_field_add);
610
-                                } else {
630
+									if ($default_value != '') {
631
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
632
+									}
611 633
 
612
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
634
+									$wpdb->query($meta_field_add);
613 635
 
614
-                                    $meta_field_add = "VARCHAR( 15 ) NULL";
615
-                                    if ($default_value != '') {
616
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
617
-                                    }
636
+								} else {
618 637
 
619
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
620
-                                }
638
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
621 639
 
640
+									$meta_field_add = "VARCHAR( 3 ) NULL";
641
+									if ($default_value != '') {
642
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
643
+									}
622 644
 
623
-                            }
624
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
645
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
646
+								}
625 647
 
626
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
627
-                                if ($is_column) {
628
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
648
+							}
649
+							// show lat lng
650
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
651
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
629 652
 
630
-                                    if ($default_value != '') {
631
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
632
-                                    }
653
+								if ($is_column) {
654
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
655
+									$meta_field_add .= " DEFAULT '1'";
633 656
 
634
-                                    $wpdb->query($meta_field_add);
657
+									$wpdb->query($meta_field_add);
658
+								} else {
659
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
635 660
 
636
-                                } else {
661
+									$meta_field_add = "VARCHAR( 3 ) NULL";
662
+									$meta_field_add .= " DEFAULT '1'";
637 663
 
638
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
664
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
665
+								}
639 666
 
640
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
641
-                                    if ($default_value != '') {
642
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
643
-                                    }
667
+							}
668
+						}// end extra
644 669
 
645
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
646
-                                }
670
+						break;
647 671
 
648
-                            }
649
-                            // show lat lng
650
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
651
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
672
+					case 'checkbox':
673
+					case 'multiselect':
674
+					case 'select':
675
+					case 'taxonomy':
652 676
 
653
-                                if ($is_column) {
654
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
655
-                                    $meta_field_add .= " DEFAULT '1'";
677
+					$op_size = '500';
656 678
 
657
-                                    $wpdb->query($meta_field_add);
658
-                                } else {
659
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
679
+					// only make the field as big as it needs to be.
680
+					if(isset($option_values) && $option_values && $field_type=='select'){
681
+						$option_values_arr = explode(',',$option_values);
682
+						if(is_array($option_values_arr)){
683
+							$op_max = 0;
684
+							foreach($option_values_arr as $op_val){
685
+								if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
686
+							}
687
+							if($op_max){$op_size =$op_max; }
688
+						}
689
+					}elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
690
+						if(strlen($option_values)){
691
+							$op_size =  strlen($option_values);
692
+						}
693
+					}
660 694
 
661
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
662
-                                    $meta_field_add .= " DEFAULT '1'";
695
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
663 696
 
664
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
665
-                                }
697
+						if ($default_value != '') {
698
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
699
+						}
666 700
 
667
-                            }
668
-                        }// end extra
701
+					$alter_result = $wpdb->query($meta_field_add);
702
+					if($alter_result===false){
703
+						return __('Column change failed, you may have too many columns.','geodirectory');
704
+					}
669 705
 
670
-                        break;
706
+						if (isset($request_field['cat_display_type']))
707
+							$extra_fields = $request_field['cat_display_type'];
671 708
 
672
-                    case 'checkbox':
673
-                    case 'multiselect':
674
-                    case 'select':
675
-                    case 'taxonomy':
709
+						if (isset($request_field['multi_display_type']))
710
+							$extra_fields = $request_field['multi_display_type'];
676 711
 
677
-                    $op_size = '500';
678 712
 
679
-                    // only make the field as big as it needs to be.
680
-                    if(isset($option_values) && $option_values && $field_type=='select'){
681
-                        $option_values_arr = explode(',',$option_values);
682
-                        if(is_array($option_values_arr)){
683
-                            $op_max = 0;
684
-                            foreach($option_values_arr as $op_val){
685
-                                if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
686
-                            }
687
-                            if($op_max){$op_size =$op_max; }
688
-                        }
689
-                    }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
690
-                        if(strlen($option_values)){
691
-                            $op_size =  strlen($option_values);
692
-                        }
693
-                    }
713
+						break;
694 714
 
695
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
715
+					case 'textarea':
716
+					case 'html':
696 717
 
697
-                        if ($default_value != '') {
698
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
699
-                        }
718
+					$alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
719
+					if($alter_result===false){
720
+						return __('Column change failed, you may have too many columns.','geodirectory');
721
+					}
722
+						if (isset($request_field['advanced_editor']))
723
+							$extra_fields = $request_field['advanced_editor'];
700 724
 
701
-                    $alter_result = $wpdb->query($meta_field_add);
702
-                    if($alter_result===false){
703
-                        return __('Column change failed, you may have too many columns.','geodirectory');
704
-                    }
725
+						break;
705 726
 
706
-                        if (isset($request_field['cat_display_type']))
707
-                            $extra_fields = $request_field['cat_display_type'];
727
+					case 'fieldset':
728
+						// Nothig happend for fieldset
729
+						break;
708 730
 
709
-                        if (isset($request_field['multi_display_type']))
710
-                            $extra_fields = $request_field['multi_display_type'];
731
+					default:
732
+						if ($data_type != 'VARCHAR' && $data_type != '') {
733
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
734
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
735
+							} else {
736
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
737
+							}
711 738
 
739
+							if (is_numeric($default_value) && $default_value != '') {
740
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
741
+							}
742
+						} else {
743
+							$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
744
+							if ($default_value != '') {
745
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
746
+							}
747
+						}
712 748
 
713
-                        break;
749
+						$alter_result = $wpdb->query($default_value_add);
750
+						if($alter_result===false){
751
+							return __('Column change failed, you may have too many columns.','geodirectory');
752
+						}
753
+						break;
754
+				endswitch;
714 755
 
715
-                    case 'textarea':
716
-                    case 'html':
756
+				$extra_field_query = '';
757
+				if (!empty($extra_fields)) {
758
+					$extra_field_query = serialize($extra_fields);
759
+				}
717 760
 
718
-                    $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
719
-                    if($alter_result===false){
720
-                        return __('Column change failed, you may have too many columns.','geodirectory');
721
-                    }
722
-                        if (isset($request_field['advanced_editor']))
723
-                            $extra_fields = $request_field['advanced_editor'];
761
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
724 762
 
725
-                        break;
763
+				$wpdb->query(
726 764
 
727
-                    case 'fieldset':
728
-                        // Nothig happend for fieldset
729
-                        break;
765
+					$wpdb->prepare(
730 766
 
731
-                    default:
732
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
733
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
734
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
735
-                            } else {
736
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
737
-                            }
738
-
739
-                            if (is_numeric($default_value) && $default_value != '') {
740
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
741
-                            }
742
-                        } else {
743
-                            $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
744
-                            if ($default_value != '') {
745
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
746
-                            }
747
-                        }
748
-
749
-                        $alter_result = $wpdb->query($default_value_add);
750
-                        if($alter_result===false){
751
-                            return __('Column change failed, you may have too many columns.','geodirectory');
752
-                        }
753
-                        break;
754
-                endswitch;
755
-
756
-                $extra_field_query = '';
757
-                if (!empty($extra_fields)) {
758
-                    $extra_field_query = serialize($extra_fields);
759
-                }
760
-
761
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
762
-
763
-                $wpdb->query(
764
-
765
-                    $wpdb->prepare(
766
-
767
-                        "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
767
+						"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
768 768
 					post_type = %s,
769 769
 					admin_title = %s,
770 770
 					site_title = %s,
@@ -796,307 +796,307 @@  discard block
 block discarded – undo
796 796
 					for_admin_use = %s
797 797
 					where id = %d",
798 798
 
799
-                        array($post_type, $admin_title, $site_title, $field_type, $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_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)
800
-                    )
799
+						array($post_type, $admin_title, $site_title, $field_type, $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_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)
800
+					)
801 801
 
802
-                );
802
+				);
803 803
 
804
-                $lastid = trim($cf);
804
+				$lastid = trim($cf);
805 805
 
806 806
 
807
-                $wpdb->query(
808
-                    $wpdb->prepare(
809
-                        "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
807
+				$wpdb->query(
808
+					$wpdb->prepare(
809
+						"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
810 810
 					 	site_title=%s
811 811
 					where post_type = %s and htmlvar_name = %s",
812
-                        array($site_title, $post_type, $htmlvar_name)
813
-                    )
814
-                );
815
-
816
-
817
-                if ($cat_sort == '')
818
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
819
-
820
-
821
-                /**
822
-                 * Called after all custom fields are saved for a post.
823
-                 *
824
-                 * @since 1.0.0
825
-                 * @param int $lastid The post ID.
826
-                 */
827
-                do_action('geodir_after_custom_fields_updated', $lastid);
828
-
829
-            } else {
830
-
831
-                switch ($field_type):
832
-
833
-                    case 'address':
834
-
835
-                        $data_type = '';
836
-
837
-                        if ($htmlvar_name != '') {
838
-                            $prefix = $htmlvar_name . '_';
839
-                        }
840
-                        $old_prefix = $old_html_variable;
841
-
842
-                        //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
843
-
844
-                        $meta_field_add = "VARCHAR( 254 ) NULL";
845
-                        if ($default_value != '') {
846
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
847
-                        }
848
-
849
-                        geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
850
-                        //$wpdb->query($meta_field_add);
851
-
852
-
853
-                        if (!empty($extra_fields)) {
812
+						array($site_title, $post_type, $htmlvar_name)
813
+					)
814
+				);
815
+
816
+
817
+				if ($cat_sort == '')
818
+					$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
819
+
820
+
821
+				/**
822
+				 * Called after all custom fields are saved for a post.
823
+				 *
824
+				 * @since 1.0.0
825
+				 * @param int $lastid The post ID.
826
+				 */
827
+				do_action('geodir_after_custom_fields_updated', $lastid);
828
+
829
+			} else {
830
+
831
+				switch ($field_type):
832
+
833
+					case 'address':
834
+
835
+						$data_type = '';
836
+
837
+						if ($htmlvar_name != '') {
838
+							$prefix = $htmlvar_name . '_';
839
+						}
840
+						$old_prefix = $old_html_variable;
841
+
842
+						//$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
843
+
844
+						$meta_field_add = "VARCHAR( 254 ) NULL";
845
+						if ($default_value != '') {
846
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
847
+						}
848
+
849
+						geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
850
+						//$wpdb->query($meta_field_add);
851
+
854 852
 
855
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
856
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
857
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
858
-                                if ($default_value != '') {
859
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
860
-                                }
861
-
862
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
863
-                                //$wpdb->query($meta_field_add);
864
-                            }
865
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
866
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
867
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
868
-                                if ($default_value != '') {
869
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
870
-                                }
871
-
872
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
873
-                                //$wpdb->query($meta_field_add);
874
-                            }
875
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
876
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
877
-
878
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
879
-                                if ($default_value != '') {
880
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
881
-                                }
882
-
883
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
884
-                                //$wpdb->query($meta_field_add);
885
-                            }
886
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
887
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
888
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
889
-                                if ($default_value != '') {
890
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
891
-                                }
892
-
893
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
894
-                                //$wpdb->query($meta_field_add);
895
-                            }
896
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
897
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
898
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
899
-                                if ($default_value != '') {
900
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
901
-                                }
902
-
903
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
904
-                                //$wpdb->query($meta_field_add);
905
-
906
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
907
-
908
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
909
-                                if ($default_value != '') {
910
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
911
-                                }
912
-
913
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
914
-
915
-                                //$wpdb->query($meta_field_add);
916
-                            }
917
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
918
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
919
-
920
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
921
-                                if ($default_value != '') {
922
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
923
-                                }
924
-
925
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
926
-
927
-                                //$wpdb->query($meta_field_add);
928
-                            }
929
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
930
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
931
-
932
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
933
-                                if ($default_value != '') {
934
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
935
-                                }
936
-
937
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
938
-
939
-                                //$wpdb->query($meta_field_add);
940
-                            }
941
-                            // show lat lng
942
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
943
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
944
-
945
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
946
-                                $meta_field_add .= " DEFAULT '1'";
947
-
948
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
949
-                                //$wpdb->query($meta_field_add);
950
-                            }
951
-                        }
952
-
953
-                        break;
954
-
955
-                    case 'checkbox':
956
-                        $data_type = 'TINYINT';
957
-
958
-                        $meta_field_add = $data_type . "( 1 ) NOT NULL ";
959
-                        if ((int)$default_value === 1) {
960
-                            $meta_field_add .= " DEFAULT '1'";
961
-                        }
962
-
963
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
964
-                        if ($add_result === false) {
965
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
966
-                        }
967
-                        break;
968
-                    case 'multiselect':
969
-                    case 'select':
970
-                        $data_type = 'VARCHAR';
971
-                        $op_size = '500';
972
-
973
-                        // only make the field as big as it needs to be.
974
-                        if (isset($option_values) && $option_values && $field_type == 'select') {
975
-                            $option_values_arr = explode(',', $option_values);
853
+						if (!empty($extra_fields)) {
854
+
855
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
856
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
857
+								$meta_field_add = "VARCHAR( 30 ) NULL";
858
+								if ($default_value != '') {
859
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
860
+								}
861
+
862
+								geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
863
+								//$wpdb->query($meta_field_add);
864
+							}
865
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
866
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
867
+								$meta_field_add = "VARCHAR( 30 ) NULL";
868
+								if ($default_value != '') {
869
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
870
+								}
871
+
872
+								geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
873
+								//$wpdb->query($meta_field_add);
874
+							}
875
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
876
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
877
+
878
+								$meta_field_add = "VARCHAR( 30 ) NULL";
879
+								if ($default_value != '') {
880
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
881
+								}
882
+
883
+								geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
884
+								//$wpdb->query($meta_field_add);
885
+							}
886
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
887
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
888
+								$meta_field_add = "VARCHAR( 15 ) NULL";
889
+								if ($default_value != '') {
890
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
891
+								}
892
+
893
+								geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
894
+								//$wpdb->query($meta_field_add);
895
+							}
896
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
897
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
898
+								$meta_field_add = "VARCHAR( 20 ) NULL";
899
+								if ($default_value != '') {
900
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
901
+								}
902
+
903
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
904
+								//$wpdb->query($meta_field_add);
905
+
906
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
907
+
908
+								$meta_field_add = "VARCHAR( 20 ) NULL";
909
+								if ($default_value != '') {
910
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
911
+								}
912
+
913
+								geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
914
+
915
+								//$wpdb->query($meta_field_add);
916
+							}
917
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
918
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
919
+
920
+								$meta_field_add = "VARCHAR( 15 ) NULL";
921
+								if ($default_value != '') {
922
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
923
+								}
924
+
925
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
926
+
927
+								//$wpdb->query($meta_field_add);
928
+							}
929
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
930
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
931
+
932
+								$meta_field_add = "VARCHAR( 3 ) NULL";
933
+								if ($default_value != '') {
934
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
935
+								}
936
+
937
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
938
+
939
+								//$wpdb->query($meta_field_add);
940
+							}
941
+							// show lat lng
942
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
943
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
944
+
945
+								$meta_field_add = "VARCHAR( 3 ) NULL";
946
+								$meta_field_add .= " DEFAULT '1'";
947
+
948
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
949
+								//$wpdb->query($meta_field_add);
950
+							}
951
+						}
952
+
953
+						break;
954
+
955
+					case 'checkbox':
956
+						$data_type = 'TINYINT';
957
+
958
+						$meta_field_add = $data_type . "( 1 ) NOT NULL ";
959
+						if ((int)$default_value === 1) {
960
+							$meta_field_add .= " DEFAULT '1'";
961
+						}
962
+
963
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
964
+						if ($add_result === false) {
965
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
966
+						}
967
+						break;
968
+					case 'multiselect':
969
+					case 'select':
970
+						$data_type = 'VARCHAR';
971
+						$op_size = '500';
972
+
973
+						// only make the field as big as it needs to be.
974
+						if (isset($option_values) && $option_values && $field_type == 'select') {
975
+							$option_values_arr = explode(',', $option_values);
976 976
                             
977 977
 							if (is_array($option_values_arr)) {
978
-                                $op_max = 0;
978
+								$op_max = 0;
979 979
                                 
980 980
 								foreach ($option_values_arr as $op_val) {
981
-                                    if (strlen($op_val) && strlen($op_val) > $op_max) {
981
+									if (strlen($op_val) && strlen($op_val) > $op_max) {
982 982
 										$op_max = strlen($op_val);
983 983
 									}
984
-                                }
984
+								}
985 985
                                 
986 986
 								if ($op_max) {
987 987
 									$op_size = $op_max;
988 988
 								}
989
-                            }
990
-                        } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
991
-                            if (strlen($option_values)) {
992
-                                $op_size =  strlen($option_values);
993
-                            }
989
+							}
990
+						} elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
991
+							if (strlen($option_values)) {
992
+								$op_size =  strlen($option_values);
993
+							}
994 994
 							
995 995
 							if (isset($request_field['multi_display_type'])) {
996 996
 								$extra_fields = $request_field['multi_display_type'];
997 997
 							}
998
-                        }
998
+						}
999 999
 
1000
-                        $meta_field_add = $data_type . "( $op_size ) NULL ";
1001
-                        if ($default_value != '') {
1002
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
1003
-                        }
1000
+						$meta_field_add = $data_type . "( $op_size ) NULL ";
1001
+						if ($default_value != '') {
1002
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
1003
+						}
1004 1004
 
1005
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1006
-                        if ($add_result === false) {
1007
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1008
-                        }
1009
-                        break;
1010
-                    case 'textarea':
1011
-                    case 'html':
1012
-                    case 'url':
1005
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1006
+						if ($add_result === false) {
1007
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1008
+						}
1009
+						break;
1010
+					case 'textarea':
1011
+					case 'html':
1012
+					case 'url':
1013 1013
 
1014
-                        $data_type = 'TEXT';
1014
+						$data_type = 'TEXT';
1015 1015
 
1016
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1016
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1017 1017
 
1018
-                        $meta_field_add = $data_type . " NULL ";
1019
-                        /*if($default_value != '')
1018
+						$meta_field_add = $data_type . " NULL ";
1019
+						/*if($default_value != '')
1020 1020
 					{ $meta_field_add .= " DEFAULT '".$default_value."'"; }*/
1021 1021
 
1022
-                    $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1023
-                    if ($add_result === false) {
1024
-                        return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1025
-                    }
1022
+					$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1023
+					if ($add_result === false) {
1024
+						return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1025
+					}
1026 1026
 
1027
-                        break;
1027
+						break;
1028 1028
 
1029
-                    case 'datepicker':
1029
+					case 'datepicker':
1030 1030
 
1031
-                        $data_type = 'DATE';
1031
+						$data_type = 'DATE';
1032 1032
 
1033
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1033
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1034 1034
 
1035
-                        $meta_field_add = $data_type . " NULL ";
1035
+						$meta_field_add = $data_type . " NULL ";
1036 1036
 
1037
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1038
-                        if ($add_result === false) {
1039
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1040
-                        }
1037
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1038
+						if ($add_result === false) {
1039
+							return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1040
+						}
1041 1041
 
1042
-                        break;
1042
+						break;
1043 1043
 
1044
-                    case 'time':
1044
+					case 'time':
1045 1045
 
1046
-                        $data_type = 'TIME';
1046
+						$data_type = 'TIME';
1047 1047
 
1048
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1048
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1049 1049
 
1050
-                        $meta_field_add = $data_type . " NULL ";
1050
+						$meta_field_add = $data_type . " NULL ";
1051 1051
 
1052
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1053
-                        if ($add_result === false) {
1054
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1055
-                        }
1052
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1053
+						if ($add_result === false) {
1054
+							return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1055
+						}
1056 1056
 
1057
-                        break;
1057
+						break;
1058 1058
 
1059
-                    default:
1059
+					default:
1060 1060
 
1061
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
1062
-                            $meta_field_add = $data_type . " NULL ";
1061
+						if ($data_type != 'VARCHAR' && $data_type != '') {
1062
+							$meta_field_add = $data_type . " NULL ";
1063 1063
 
1064
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
1065
-                                $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1066
-                            }
1064
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
1065
+								$meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1066
+							}
1067 1067
 
1068
-                            if (is_numeric($default_value) && $default_value != '') {
1069
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1070
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1071
-                            }
1072
-                        } else {
1073
-                            $meta_field_add = " VARCHAR( 254 ) NULL ";
1068
+							if (is_numeric($default_value) && $default_value != '') {
1069
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1070
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1071
+							}
1072
+						} else {
1073
+							$meta_field_add = " VARCHAR( 254 ) NULL ";
1074 1074
 
1075
-                            if ($default_value != '') {
1076
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1077
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1078
-                            }
1079
-                        }
1075
+							if ($default_value != '') {
1076
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1077
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1078
+							}
1079
+						}
1080 1080
 
1081
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1082
-                        if ($add_result === false) {
1083
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1084
-                        }
1085
-                        break;
1086
-                endswitch;
1081
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1082
+						if ($add_result === false) {
1083
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1084
+						}
1085
+						break;
1086
+				endswitch;
1087 1087
 
1088
-                $extra_field_query = '';
1089
-                if (!empty($extra_fields)) {
1090
-                    $extra_field_query = serialize($extra_fields);
1091
-                }
1088
+				$extra_field_query = '';
1089
+				if (!empty($extra_fields)) {
1090
+					$extra_field_query = serialize($extra_fields);
1091
+				}
1092 1092
 
1093
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1093
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1094 1094
 
1095
-                $wpdb->query(
1095
+				$wpdb->query(
1096 1096
 
1097
-                    $wpdb->prepare(
1097
+					$wpdb->prepare(
1098 1098
 
1099
-                        "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1099
+						"insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1100 1100
 					post_type = %s,
1101 1101
 					admin_title = %s,
1102 1102
 					site_title = %s,
@@ -1127,26 +1127,26 @@  discard block
 block discarded – undo
1127 1127
 					validation_msg = %s,
1128 1128
 					for_admin_use = %s ",
1129 1129
 
1130
-                        array($post_type, $admin_title, $site_title, $field_type, $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_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)
1130
+						array($post_type, $admin_title, $site_title, $field_type, $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_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)
1131 1131
 
1132
-                    )
1132
+					)
1133 1133
 
1134
-                );
1134
+				);
1135 1135
 
1136
-                $lastid = $wpdb->insert_id;
1136
+				$lastid = $wpdb->insert_id;
1137 1137
 
1138
-                $lastid = trim($lastid);
1138
+				$lastid = trim($lastid);
1139 1139
 
1140
-            }
1140
+			}
1141 1141
 
1142
-            return (int)$lastid;
1142
+			return (int)$lastid;
1143 1143
 
1144 1144
 
1145
-        } else {
1146
-            return 'HTML Variable Name should be a unique name';
1147
-        }
1145
+		} else {
1146
+			return 'HTML Variable Name should be a unique name';
1147
+		}
1148 1148
 
1149
-    }
1149
+	}
1150 1150
 }
1151 1151
 
1152 1152
 /**
@@ -1161,30 +1161,30 @@  discard block
 block discarded – undo
1161 1161
 function godir_set_field_order($field_ids = array())
1162 1162
 {
1163 1163
 
1164
-    global $wpdb;
1164
+	global $wpdb;
1165 1165
 
1166
-    $count = 0;
1167
-    if (!empty($field_ids)):
1168
-        $post_meta_info = false;
1169
-        foreach ($field_ids as $id) {
1166
+	$count = 0;
1167
+	if (!empty($field_ids)):
1168
+		$post_meta_info = false;
1169
+		foreach ($field_ids as $id) {
1170 1170
 
1171
-            $cf = trim($id, '_');
1171
+			$cf = trim($id, '_');
1172 1172
 
1173
-            $post_meta_info = $wpdb->query(
1174
-                $wpdb->prepare(
1175
-                    "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1173
+			$post_meta_info = $wpdb->query(
1174
+				$wpdb->prepare(
1175
+					"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1176 1176
 															sort_order=%d 
1177 1177
 															where id= %d",
1178
-                    array($count, $cf)
1179
-                )
1180
-            );
1181
-            $count++;
1182
-        }
1183
-
1184
-        return $post_meta_info;
1185
-    else:
1186
-        return false;
1187
-    endif;
1178
+					array($count, $cf)
1179
+				)
1180
+			);
1181
+			$count++;
1182
+		}
1183
+
1184
+		return $post_meta_info;
1185
+	else:
1186
+		return false;
1187
+	endif;
1188 1188
 }
1189 1189
 
1190 1190
 
@@ -1204,140 +1204,140 @@  discard block
 block discarded – undo
1204 1204
  * @param string $post_type Optional. The wordpress post type.
1205 1205
  */
1206 1206
 function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') {
1207
-    global $is_default, $mapzoom, $gd_session;
1207
+	global $is_default, $mapzoom, $gd_session;
1208 1208
 
1209
-    $show_editors = array();
1210
-    $listing_type = $post_type;
1209
+	$show_editors = array();
1210
+	$listing_type = $post_type;
1211 1211
 
1212
-    $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1212
+	$custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1213 1213
 
1214
-    $fieldset_id = '';
1214
+	$fieldset_id = '';
1215 1215
 	$fieldset_field_class = 'gd-fieldset-details';
1216 1216
 	foreach ($custom_fields as $key => $val) {
1217
-        $val = stripslashes_deep($val); // strip slashes from labels
1217
+		$val = stripslashes_deep($val); // strip slashes from labels
1218 1218
 		$name = $val['name'];
1219
-        $site_title = $val['site_title'];
1220
-        $type = $val['type'];
1221
-        $admin_desc = $val['desc'];
1222
-        $option_values = $val['option_values'];
1223
-        $is_required = $val['is_required'];
1224
-        $is_default = $val['is_default'];
1225
-        $is_admin = $val['is_admin'];
1226
-        $required_msg = $val['required_msg'];
1227
-        $extra_fields = unserialize($val['extra_fields']);
1228
-        $value = '';
1229
-
1230
-        /* field available to site admin only for edit */
1231
-        $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1232
-        if ($for_admin_use && !is_super_admin()) {
1233
-            continue;
1234
-        }
1235
-
1236
-        if (is_admin()) {
1237
-            global $post;
1238
-
1239
-            if (isset($_REQUEST['post']))
1240
-                $_REQUEST['pid'] = $_REQUEST['post'];
1241
-        }
1242
-
1243
-        if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1244
-            $post = $gd_ses_listing;
1245
-            $value = isset($post[$name]) ? $post[$name] : '';
1246
-        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1247
-            $value = geodir_get_post_meta($_REQUEST['pid'], $name, true);
1248
-        } else {
1249
-            if ($value == '') {
1250
-                $value = $val['default'];
1251
-            }
1252
-        }
1253
-
1254
-        /**
1255
-         * Called before the custom fields info is output for submitting a post.
1256
-         *
1257
-         * Used dynamic hook type geodir_before_custom_form_field_$name.
1258
-         *
1259
-         * @since 1.0.0
1260
-         * @param string $listing_type The post post type.
1261
-         * @param int $package_id The price package ID for the post.
1262
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1263
-         * @see 'geodir_after_custom_form_field_$name'
1264
-         */
1265
-        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1266
-
1267
-        if ($type == 'fieldset') {
1268
-            $fieldset_id = (int)$val['id'];
1269
-            $fieldset_field_class = 'gd-fieldset-' . $fieldset_id;
1270
-            ?>
1219
+		$site_title = $val['site_title'];
1220
+		$type = $val['type'];
1221
+		$admin_desc = $val['desc'];
1222
+		$option_values = $val['option_values'];
1223
+		$is_required = $val['is_required'];
1224
+		$is_default = $val['is_default'];
1225
+		$is_admin = $val['is_admin'];
1226
+		$required_msg = $val['required_msg'];
1227
+		$extra_fields = unserialize($val['extra_fields']);
1228
+		$value = '';
1229
+
1230
+		/* field available to site admin only for edit */
1231
+		$for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1232
+		if ($for_admin_use && !is_super_admin()) {
1233
+			continue;
1234
+		}
1235
+
1236
+		if (is_admin()) {
1237
+			global $post;
1238
+
1239
+			if (isset($_REQUEST['post']))
1240
+				$_REQUEST['pid'] = $_REQUEST['post'];
1241
+		}
1242
+
1243
+		if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1244
+			$post = $gd_ses_listing;
1245
+			$value = isset($post[$name]) ? $post[$name] : '';
1246
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1247
+			$value = geodir_get_post_meta($_REQUEST['pid'], $name, true);
1248
+		} else {
1249
+			if ($value == '') {
1250
+				$value = $val['default'];
1251
+			}
1252
+		}
1253
+
1254
+		/**
1255
+		 * Called before the custom fields info is output for submitting a post.
1256
+		 *
1257
+		 * Used dynamic hook type geodir_before_custom_form_field_$name.
1258
+		 *
1259
+		 * @since 1.0.0
1260
+		 * @param string $listing_type The post post type.
1261
+		 * @param int $package_id The price package ID for the post.
1262
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1263
+		 * @see 'geodir_after_custom_form_field_$name'
1264
+		 */
1265
+		do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1266
+
1267
+		if ($type == 'fieldset') {
1268
+			$fieldset_id = (int)$val['id'];
1269
+			$fieldset_field_class = 'gd-fieldset-' . $fieldset_id;
1270
+			?>
1271 1271
             <h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?>
1272 1272
             <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>';?></h5>
1273 1273
             <?php
1274
-        } else if ($type == 'address') {
1275
-            $prefix = $name . '_';
1276
-
1277
-            ($site_title != '') ? $address_title = $site_title : $address_title = geodir_ucwords($prefix . ' address');
1278
-            ($extra_fields['zip_lable'] != '') ? $zip_title = $extra_fields['zip_lable'] : $zip_title = geodir_ucwords($prefix . ' zip/post code ');
1279
-            ($extra_fields['map_lable'] != '') ? $map_title = $extra_fields['map_lable'] : $map_title = geodir_ucwords('set address on map');
1280
-            ($extra_fields['mapview_lable'] != '') ? $mapview_title = $extra_fields['mapview_lable'] : $mapview_title = geodir_ucwords($prefix . ' mapview');
1281
-
1282
-            $address = '';
1283
-            $zip = '';
1284
-            $mapview = '';
1285
-            $mapzoom = '';
1286
-            $lat = '';
1287
-            $lng = '';
1288
-
1289
-            if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1290
-                $post = $gd_ses_listing;
1291
-                $address = $post[$prefix . 'address'];
1292
-                $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : '';
1293
-                $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : '';
1294
-                $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : '';
1295
-                $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : '';
1296
-                $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : '';
1297
-            } else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) {
1298
-                $post_info = (array)$post_info;
1299
-
1300
-                $address = $post_info[$prefix . 'address'];
1301
-                $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : '';
1302
-                $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : '';
1303
-                $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : '';
1304
-                $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : '';
1305
-                $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : '';
1306
-            }
1307
-
1308
-            $location = geodir_get_default_location();
1309
-            if (empty($city)) $city = isset($location->city) ? $location->city : '';
1310
-            if (empty($region)) $region = isset($location->region) ? $location->region : '';
1311
-            if (empty($country)) $country = isset($location->country) ? $location->country : '';
1312
-
1313
-            $lat_lng_blank = false;
1314
-            if (empty($lat) && empty($lng)) {
1315
-                $lat_lng_blank = true;
1316
-            }
1317
-
1318
-            if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : '';
1319
-            if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : '';
1320
-
1321
-            /**
1322
-             * Filter the default latitude.
1323
-             *
1324
-             * @since 1.0.0
1325
-             *
1326
-             * @param float $lat Default latitude.
1327
-             * @param bool $is_admin For admin use only?.
1328
-             */
1329
-            $lat = apply_filters('geodir_default_latitude', $lat, $is_admin);
1330
-            /**
1331
-             * Filter the default longitude.
1332
-             *
1333
-             * @since 1.0.0
1334
-             *
1335
-             * @param float $lat Default longitude.
1336
-             * @param bool $is_admin For admin use only?.
1337
-             */
1338
-            $lng = apply_filters('geodir_default_longitude', $lng, $is_admin);
1339
-
1340
-            ?>
1274
+		} else if ($type == 'address') {
1275
+			$prefix = $name . '_';
1276
+
1277
+			($site_title != '') ? $address_title = $site_title : $address_title = geodir_ucwords($prefix . ' address');
1278
+			($extra_fields['zip_lable'] != '') ? $zip_title = $extra_fields['zip_lable'] : $zip_title = geodir_ucwords($prefix . ' zip/post code ');
1279
+			($extra_fields['map_lable'] != '') ? $map_title = $extra_fields['map_lable'] : $map_title = geodir_ucwords('set address on map');
1280
+			($extra_fields['mapview_lable'] != '') ? $mapview_title = $extra_fields['mapview_lable'] : $mapview_title = geodir_ucwords($prefix . ' mapview');
1281
+
1282
+			$address = '';
1283
+			$zip = '';
1284
+			$mapview = '';
1285
+			$mapzoom = '';
1286
+			$lat = '';
1287
+			$lng = '';
1288
+
1289
+			if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1290
+				$post = $gd_ses_listing;
1291
+				$address = $post[$prefix . 'address'];
1292
+				$zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : '';
1293
+				$lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : '';
1294
+				$lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : '';
1295
+				$mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : '';
1296
+				$mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : '';
1297
+			} else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) {
1298
+				$post_info = (array)$post_info;
1299
+
1300
+				$address = $post_info[$prefix . 'address'];
1301
+				$zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : '';
1302
+				$lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : '';
1303
+				$lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : '';
1304
+				$mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : '';
1305
+				$mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : '';
1306
+			}
1307
+
1308
+			$location = geodir_get_default_location();
1309
+			if (empty($city)) $city = isset($location->city) ? $location->city : '';
1310
+			if (empty($region)) $region = isset($location->region) ? $location->region : '';
1311
+			if (empty($country)) $country = isset($location->country) ? $location->country : '';
1312
+
1313
+			$lat_lng_blank = false;
1314
+			if (empty($lat) && empty($lng)) {
1315
+				$lat_lng_blank = true;
1316
+			}
1317
+
1318
+			if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : '';
1319
+			if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : '';
1320
+
1321
+			/**
1322
+			 * Filter the default latitude.
1323
+			 *
1324
+			 * @since 1.0.0
1325
+			 *
1326
+			 * @param float $lat Default latitude.
1327
+			 * @param bool $is_admin For admin use only?.
1328
+			 */
1329
+			$lat = apply_filters('geodir_default_latitude', $lat, $is_admin);
1330
+			/**
1331
+			 * Filter the default longitude.
1332
+			 *
1333
+			 * @since 1.0.0
1334
+			 *
1335
+			 * @param float $lat Default longitude.
1336
+			 * @param bool $is_admin For admin use only?.
1337
+			 */
1338
+			$lng = apply_filters('geodir_default_longitude', $lng, $is_admin);
1339
+
1340
+			?>
1341 1341
 
1342 1342
             <div id="geodir_<?php echo $prefix . 'address';?>_row"
1343 1343
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
@@ -1356,17 +1356,17 @@  discard block
 block discarded – undo
1356 1356
 
1357 1357
 
1358 1358
             <?php
1359
-            /**
1360
-             * Called after the address input on the add listings.
1361
-             *
1362
-             * This is used by the location manage to add further locations info etc.
1363
-             *
1364
-             * @since 1.0.0
1365
-             * @param array $val The array of setting for the custom field. {@see geodir_custom_field_save()}.
1366
-             */
1367
-            do_action('geodir_address_extra_listing_fields', $val);
1368
-
1369
-            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?>
1359
+			/**
1360
+			 * Called after the address input on the add listings.
1361
+			 *
1362
+			 * This is used by the location manage to add further locations info etc.
1363
+			 *
1364
+			 * @since 1.0.0
1365
+			 * @param array $val The array of setting for the custom field. {@see geodir_custom_field_save()}.
1366
+			 */
1367
+			do_action('geodir_address_extra_listing_fields', $val);
1368
+
1369
+			if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?>
1370 1370
 
1371 1371
                 <div id="geodir_<?php echo $prefix . 'zip'; ?>_row"
1372 1372
                      class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
@@ -1387,22 +1387,22 @@  discard block
 block discarded – undo
1387 1387
 
1388 1388
                 <div id="geodir_<?php echo $prefix . 'map'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1389 1389
                     <?php
1390
-                    /**
1391
-                     * Contains add listing page map functions.
1392
-                     *
1393
-                     * @since 1.0.0
1394
-                     */
1395
-                    include(geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php");
1396
-                    if ($lat_lng_blank) {
1397
-                        $lat = '';
1398
-                        $lng = '';
1399
-                    }
1400
-                    ?>
1390
+					/**
1391
+					 * Contains add listing page map functions.
1392
+					 *
1393
+					 * @since 1.0.0
1394
+					 */
1395
+					include(geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php");
1396
+					if ($lat_lng_blank) {
1397
+						$lat = '';
1398
+						$lng = '';
1399
+					}
1400
+					?>
1401 1401
                     <span class="geodir_message_note"><?php echo GET_MAP_MSG; ?></span>
1402 1402
                 </div>
1403 1403
                 <?php
1404
-                /* show lat lng */
1405
-                $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?>
1404
+				/* show lat lng */
1405
+				$style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?>
1406 1406
                 <div id="geodir_<?php echo $prefix . 'latitude'; ?>_row"
1407 1407
                      class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>>
1408 1408
                     <label>
@@ -1443,27 +1443,27 @@  discard block
 block discarded – undo
1443 1443
                                                             class="gd-checkbox"
1444 1444
                                                             name="<?php echo $prefix . 'mapview'; ?>"
1445 1445
                                                             id="<?php echo $prefix . 'mapview'; ?>" <?php if ($mapview == 'ROADMAP' || $mapview == '') {
1446
-                            echo 'checked="checked"';
1447
-                        } ?>  value="ROADMAP" size="25"/> <?php _e('Default Map', 'geodirectory'); ?></span>
1446
+							echo 'checked="checked"';
1447
+						} ?>  value="ROADMAP" size="25"/> <?php _e('Default Map', 'geodirectory'); ?></span>
1448 1448
                     <span class="geodir_user_define"> <input field_type="<?php echo $type; ?>" type="radio"
1449 1449
                                                              class="gd-checkbox"
1450 1450
                                                              name="<?php echo $prefix . 'mapview'; ?>"
1451 1451
                                                              id="map_view1" <?php if ($mapview == 'SATELLITE') {
1452
-                            echo 'checked="checked"';
1453
-                        } ?> value="SATELLITE" size="25"/> <?php _e('Satellite Map', 'geodirectory'); ?></span>
1452
+							echo 'checked="checked"';
1453
+						} ?> value="SATELLITE" size="25"/> <?php _e('Satellite Map', 'geodirectory'); ?></span>
1454 1454
 
1455 1455
                     <span class="geodir_user_define"><input field_type="<?php echo $type; ?>" type="radio"
1456 1456
                                                             class="gd-checkbox"
1457 1457
                                                             name="<?php echo $prefix . 'mapview'; ?>"
1458 1458
                                                             id="map_view2" <?php if ($mapview == 'HYBRID') {
1459
-                            echo 'checked="checked"';
1460
-                        } ?>  value="HYBRID" size="25"/> <?php _e('Hybrid Map', 'geodirectory'); ?></span>
1459
+							echo 'checked="checked"';
1460
+						} ?>  value="HYBRID" size="25"/> <?php _e('Hybrid Map', 'geodirectory'); ?></span>
1461 1461
 					<span class="geodir_user_define"><input field_type="<?php echo $type; ?>" type="radio"
1462 1462
                                                             class="gd-checkbox"
1463 1463
                                                             name="<?php echo $prefix . 'mapview'; ?>"
1464 1464
                                                             id="map_view3" <?php if ($mapview == 'TERRAIN') {
1465
-                            echo 'checked="checked"';
1466
-                        } ?>  value="TERRAIN" size="25"/> <?php _e('Terrain Map', 'geodirectory'); ?></span>
1465
+							echo 'checked="checked"';
1466
+						} ?>  value="TERRAIN" size="25"/> <?php _e('Terrain Map', 'geodirectory'); ?></span>
1467 1467
 
1468 1468
 
1469 1469
                 </div>
@@ -1471,31 +1471,31 @@  discard block
 block discarded – undo
1471 1471
 
1472 1472
             <?php if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { ?>
1473 1473
                 <input type="hidden" value="<?php if (isset($mapzoom)) {
1474
-                    echo esc_attr($mapzoom);
1475
-                } ?>" name="<?php echo $prefix . 'mapzoom'; ?>" id="<?php echo $prefix . 'mapzoom'; ?>"/>
1474
+					echo esc_attr($mapzoom);
1475
+				} ?>" name="<?php echo $prefix . 'mapzoom'; ?>" id="<?php echo $prefix . 'mapzoom'; ?>"/>
1476 1476
             <?php }?>
1477 1477
         <?php } elseif ($type == 'text') {
1478 1478
 
1479
-            //number and float validation $validation_pattern
1480
-            if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
1481
-            elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
1482
-            //print_r($val);
1483
-            //validation
1484
-            if(isset($val['validation_pattern']) && $val['validation_pattern']){
1485
-                $validation = 'pattern="'.$val['validation_pattern'].'"';
1486
-            }else{$validation='';}
1487
-
1488
-            // validation message
1489
-            if(isset($val['validation_msg']) && $val['validation_msg']){
1490
-                $validation_msg = 'title="'.$val['validation_msg'].'"';
1491
-            }else{$validation_msg='';}
1492
-            ?>
1479
+			//number and float validation $validation_pattern
1480
+			if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
1481
+			elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
1482
+			//print_r($val);
1483
+			//validation
1484
+			if(isset($val['validation_pattern']) && $val['validation_pattern']){
1485
+				$validation = 'pattern="'.$val['validation_pattern'].'"';
1486
+			}else{$validation='';}
1487
+
1488
+			// validation message
1489
+			if(isset($val['validation_msg']) && $val['validation_msg']){
1490
+				$validation_msg = 'title="'.$val['validation_msg'].'"';
1491
+			}else{$validation_msg='';}
1492
+			?>
1493 1493
 
1494 1494
             <div id="<?php echo $name;?>_row"
1495 1495
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1496 1496
                 <label>
1497 1497
                     <?php $site_title = __($site_title, 'geodirectory');
1498
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1498
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1499 1499
                     <?php if ($is_required) echo '<span>*</span>';?>
1500 1500
                 </label>
1501 1501
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
@@ -1507,15 +1507,15 @@  discard block
 block discarded – undo
1507 1507
             </div>
1508 1508
 
1509 1509
         <?php } elseif ($type == 'email') {
1510
-            if ($value == $val['default']) {
1511
-                $value = '';
1512
-            }?>
1510
+			if ($value == $val['default']) {
1511
+				$value = '';
1512
+			}?>
1513 1513
 
1514 1514
             <div id="<?php echo $name;?>_row"
1515 1515
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1516 1516
                 <label>
1517 1517
                     <?php $site_title = __($site_title, 'geodirectory');
1518
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1518
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1519 1519
                     <?php if ($is_required) echo '<span>*</span>';?>
1520 1520
                 </label>
1521 1521
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
@@ -1527,15 +1527,15 @@  discard block
 block discarded – undo
1527 1527
             </div>
1528 1528
 
1529 1529
         <?php } elseif ($type == 'phone') {
1530
-            if ($value == $val['default']) {
1531
-                $value = '';
1532
-            } ?>
1530
+			if ($value == $val['default']) {
1531
+				$value = '';
1532
+			} ?>
1533 1533
 
1534 1534
             <div id="<?php echo $name;?>_row"
1535 1535
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1536 1536
                 <label>
1537 1537
                     <?php $site_title = __($site_title, 'geodirectory');
1538
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1538
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1539 1539
                     <?php if ($is_required) echo '<span>*</span>';?>
1540 1540
                 </label>
1541 1541
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
@@ -1547,15 +1547,15 @@  discard block
 block discarded – undo
1547 1547
             </div>
1548 1548
 
1549 1549
         <?php } elseif ($type == 'url') {
1550
-            if ($value == $val['default']) {
1551
-                $value = '';
1552
-            }?>
1550
+			if ($value == $val['default']) {
1551
+				$value = '';
1552
+			}?>
1553 1553
 
1554 1554
             <div id="<?php echo $name;?>_row"
1555 1555
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1556 1556
                 <label>
1557 1557
                     <?php $site_title = __($site_title, 'geodirectory');
1558
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1558
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1559 1559
                     <?php if ($is_required) echo '<span>*</span>';?>
1560 1560
                 </label>
1561 1561
                 <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
@@ -1574,11 +1574,11 @@  discard block
 block discarded – undo
1574 1574
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1575 1575
                 <label>
1576 1576
                     <?php $site_title = __($site_title, 'geodirectory');
1577
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1577
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1578 1578
                     <?php if ($is_required) echo '<span>*</span>';?>
1579 1579
                 </label>
1580 1580
 				<?php if ($option_values) {
1581
-                    $option_values = geodir_string_values_to_options($option_values, true);
1581
+					$option_values = geodir_string_values_to_options($option_values, true);
1582 1582
 					
1583 1583
 					if (!empty($option_values)) {
1584 1584
 						foreach ($option_values as $option_value) {
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
 							}
1590 1590
 						}
1591 1591
 					}
1592
-                }
1593
-                ?>
1592
+				}
1593
+				?>
1594 1594
                 <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1595 1595
                 <?php if ($is_required) { ?>
1596 1596
                     <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span>
@@ -1603,16 +1603,16 @@  discard block
 block discarded – undo
1603 1603
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1604 1604
                 <label>
1605 1605
                     <?php $site_title = __($site_title, 'geodirectory');
1606
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1606
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1607 1607
                     <?php if ($is_required) echo '<span>*</span>';?>
1608 1608
                 </label>
1609 1609
                 <?php if ($value != '1') {
1610
-                    $value = '0';
1611
-                }?>
1610
+					$value = '0';
1611
+				}?>
1612 1612
                 <input type="hidden" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>"/>
1613 1613
                 <input  <?php if ($value == '1') {
1614
-                    echo 'checked="checked"';
1615
-                }?>  value="1" class="gd-checkbox" field_type="<?php echo $type;?>" type="checkbox"
1614
+					echo 'checked="checked"';
1615
+				}?>  value="1" class="gd-checkbox" field_type="<?php echo $type;?>" type="checkbox"
1616 1616
                      onchange="if(this.checked){jQuery('#<?php echo $name;?>').val('1');} else{ jQuery('#<?php echo $name;?>').val('0');}"/>
1617 1617
                 <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
1618 1618
                 <?php if ($is_required) { ?>
@@ -1621,31 +1621,31 @@  discard block
 block discarded – undo
1621 1621
             </div>
1622 1622
 
1623 1623
         <?php } elseif ($type == 'textarea') {
1624
-            ?>
1624
+			?>
1625 1625
 
1626 1626
             <div id="<?php echo $name;?>_row"
1627 1627
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1628 1628
                 <label>
1629 1629
                     <?php $site_title = __($site_title, 'geodirectory');
1630
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1630
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1631 1631
                     <?php if ($is_required) echo '<span>*</span>';?>
1632 1632
                 </label><?php
1633 1633
 
1634 1634
 
1635
-                if (is_array($extra_fields) && in_array('1', $extra_fields)) {
1635
+				if (is_array($extra_fields) && in_array('1', $extra_fields)) {
1636 1636
 
1637
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?>
1637
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?>
1638 1638
 
1639 1639
                 <div class="editor" field_id="<?php echo $name;?>" field_type="editor">
1640 1640
                     <?php wp_editor(stripslashes($value), $name, $editor_settings); ?>
1641 1641
                     </div><?php
1642 1642
 
1643
-                } else {
1643
+				} else {
1644 1644
 
1645
-                    ?><textarea field_type="<?php echo $type;?>" class="geodir_textarea" name="<?php echo $name;?>"
1645
+					?><textarea field_type="<?php echo $type;?>" class="geodir_textarea" name="<?php echo $name;?>"
1646 1646
                                 id="<?php echo $name;?>"><?php echo stripslashes($value);?></textarea><?php
1647 1647
 
1648
-                }?>
1648
+				}?>
1649 1649
 
1650 1650
 
1651 1651
                 <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
@@ -1659,28 +1659,28 @@  discard block
 block discarded – undo
1659 1659
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>">
1660 1660
                 <label>
1661 1661
                     <?php $site_title = __($site_title, 'geodirectory');
1662
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1662
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1663 1663
                     <?php if ($is_required) echo '<span>*</span>';?>
1664 1664
                 </label>
1665 1665
                 <?php
1666
-                $option_values_arr = geodir_string_values_to_options($option_values, true);
1667
-                $select_options = '';
1668
-                if (!empty($option_values_arr)) {
1669
-                    foreach ($option_values_arr as $option_row) {
1670
-                        if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
1671
-                            $option_label = isset($option_row['label']) ? $option_row['label'] : '';
1672
-
1673
-                            $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
1674
-                        } else {
1675
-                            $option_label = isset($option_row['label']) ? $option_row['label'] : '';
1676
-                            $option_value = isset($option_row['value']) ? $option_row['value'] : '';
1677
-                            $selected = $option_value == $value ? 'selected="selected"' : '';
1678
-
1679
-                            $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
1680
-                        }
1681
-                    }
1682
-                }
1683
-                ?>
1666
+				$option_values_arr = geodir_string_values_to_options($option_values, true);
1667
+				$select_options = '';
1668
+				if (!empty($option_values_arr)) {
1669
+					foreach ($option_values_arr as $option_row) {
1670
+						if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
1671
+							$option_label = isset($option_row['label']) ? $option_row['label'] : '';
1672
+
1673
+							$select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
1674
+						} else {
1675
+							$option_label = isset($option_row['label']) ? $option_row['label'] : '';
1676
+							$option_value = isset($option_row['value']) ? $option_row['value'] : '';
1677
+							$selected = $option_value == $value ? 'selected="selected"' : '';
1678
+
1679
+							$select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
1680
+						}
1681
+					}
1682
+				}
1683
+				?>
1684 1684
                 <select field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>"
1685 1685
                         class="geodir_textfield textfield_x chosen_select"
1686 1686
                         data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '&hellip;';?>"
@@ -1692,17 +1692,17 @@  discard block
 block discarded – undo
1692 1692
             </div>
1693 1693
 
1694 1694
         <?php
1695
-        } else if ($type == 'multiselect') {
1696
-            $multi_display = 'select';
1697
-            if (!empty($val['extra_fields'])) {
1698
-                $multi_display = unserialize($val['extra_fields']);
1699
-            }
1700
-            ?>
1695
+		} else if ($type == 'multiselect') {
1696
+			$multi_display = 'select';
1697
+			if (!empty($val['extra_fields'])) {
1698
+				$multi_display = unserialize($val['extra_fields']);
1699
+			}
1700
+			?>
1701 1701
             <div id="<?php echo $name; ?>_row"
1702 1702
                  class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1703 1703
                 <label>
1704 1704
                     <?php $site_title = __($site_title, 'geodirectory');
1705
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1705
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1706 1706
                     <?php if ($is_required) echo '<span>*</span>'; ?>
1707 1707
                 </label>
1708 1708
                 <input type="hidden" name="gd_field_<?php echo $name; ?>" value="1"/>
@@ -1713,55 +1713,55 @@  discard block
 block discarded – undo
1713 1713
                             data-placeholder="<?php _e('Select', 'geodirectory'); ?>"
1714 1714
                             option-ajaxchosen="false">
1715 1715
                         <?php
1716
-                        } else {
1717
-                            echo '<ul class="gd_multi_choice">';
1718
-                        }
1719
-
1720
-                        $option_values_arr = geodir_string_values_to_options($option_values, true);
1721
-                        $select_options = '';
1722
-                        if (!empty($option_values_arr)) {
1723
-                            foreach ($option_values_arr as $option_row) {
1724
-                                if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
1725
-                                    $option_label = isset($option_row['label']) ? $option_row['label'] : '';
1726
-
1727
-                                    if ($multi_display == 'select') {
1728
-                                        $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
1729
-                                    } else {
1730
-                                        $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
1731
-                                    }
1732
-                                } else {
1733
-                                    $option_label = isset($option_row['label']) ? $option_row['label'] : '';
1734
-                                    $option_value = isset($option_row['value']) ? $option_row['value'] : '';
1735
-                                    $selected = $option_value == $value ? 'selected="selected"' : '';
1736
-                                    $selected = '';
1737
-                                    $checked = '';
1738
-
1739
-                                    if ((!is_array($value) && trim($value) != '') || (is_array($value) && !empty($value))) {
1740
-                                        if (!is_array($value)) {
1741
-                                            $value_array = explode(',', $value);
1742
-                                        } else {
1743
-                                            $value_array = $value;
1744
-                                        }
1745
-
1746
-                                        if (is_array($value_array)) {
1747
-                                            if (in_array($option_value, $value_array)) {
1748
-                                                $selected = 'selected="selected"';
1749
-                                                $checked = 'checked="checked"';
1750
-                                            }
1751
-                                        }
1752
-                                    }
1753
-
1754
-                                    if ($multi_display == 'select') {
1755
-                                        $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
1756
-                                    } else {
1757
-                                        $select_options .= '<li><input name="' . $name . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
1758
-                                    }
1759
-                                }
1760
-                            }
1761
-                        }
1762
-                        echo $select_options;
1763
-
1764
-                        if ($multi_display == 'select') { ?></select></div>
1716
+						} else {
1717
+							echo '<ul class="gd_multi_choice">';
1718
+						}
1719
+
1720
+						$option_values_arr = geodir_string_values_to_options($option_values, true);
1721
+						$select_options = '';
1722
+						if (!empty($option_values_arr)) {
1723
+							foreach ($option_values_arr as $option_row) {
1724
+								if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
1725
+									$option_label = isset($option_row['label']) ? $option_row['label'] : '';
1726
+
1727
+									if ($multi_display == 'select') {
1728
+										$select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
1729
+									} else {
1730
+										$select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
1731
+									}
1732
+								} else {
1733
+									$option_label = isset($option_row['label']) ? $option_row['label'] : '';
1734
+									$option_value = isset($option_row['value']) ? $option_row['value'] : '';
1735
+									$selected = $option_value == $value ? 'selected="selected"' : '';
1736
+									$selected = '';
1737
+									$checked = '';
1738
+
1739
+									if ((!is_array($value) && trim($value) != '') || (is_array($value) && !empty($value))) {
1740
+										if (!is_array($value)) {
1741
+											$value_array = explode(',', $value);
1742
+										} else {
1743
+											$value_array = $value;
1744
+										}
1745
+
1746
+										if (is_array($value_array)) {
1747
+											if (in_array($option_value, $value_array)) {
1748
+												$selected = 'selected="selected"';
1749
+												$checked = 'checked="checked"';
1750
+											}
1751
+										}
1752
+									}
1753
+
1754
+									if ($multi_display == 'select') {
1755
+										$select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
1756
+									} else {
1757
+										$select_options .= '<li><input name="' . $name . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
1758
+									}
1759
+								}
1760
+							}
1761
+						}
1762
+						echo $select_options;
1763
+
1764
+						if ($multi_display == 'select') { ?></select></div>
1765 1765
             <?php } else { ?></ul><?php } ?>
1766 1766
                 <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span>
1767 1767
                 <?php if ($is_required) { ?>
@@ -1769,14 +1769,14 @@  discard block
 block discarded – undo
1769 1769
                 <?php } ?>
1770 1770
             </div>
1771 1771
         <?php
1772
-        } else if ($type == 'html') {
1773
-            ?>
1772
+		} else if ($type == 'html') {
1773
+			?>
1774 1774
 
1775 1775
             <div id="<?php echo $name; ?>_row"
1776 1776
                  class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1777 1777
                 <label>
1778 1778
                     <?php $site_title = __($site_title, 'geodirectory');
1779
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1779
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1780 1780
                     <?php if ($is_required) echo '<span>*</span>'; ?>
1781 1781
                 </label>
1782 1782
 
@@ -1794,34 +1794,34 @@  discard block
 block discarded – undo
1794 1794
             </div>
1795 1795
         <?php } elseif ($type == 'datepicker') {
1796 1796
 
1797
-            if ($extra_fields['date_format'] == '')
1798
-                $extra_fields['date_format'] = 'yy-mm-dd';
1797
+			if ($extra_fields['date_format'] == '')
1798
+				$extra_fields['date_format'] = 'yy-mm-dd';
1799 1799
 
1800 1800
 
1801
-            $search = array('dd', 'mm', 'yy');
1802
-            $replace = array('d', 'm', 'Y');
1801
+			$search = array('dd', 'mm', 'yy');
1802
+			$replace = array('d', 'm', 'Y');
1803 1803
 
1804
-            $date_format = str_replace($search, $replace, $extra_fields['date_format']);
1804
+			$date_format = str_replace($search, $replace, $extra_fields['date_format']);
1805 1805
 
1806
-            if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty
1807
-            if($value && !isset($_REQUEST['backandedit'])) {
1808
-                $time = strtotime($value);
1809
-                $value = date($date_format, $time);
1810
-            }
1806
+			if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty
1807
+			if($value && !isset($_REQUEST['backandedit'])) {
1808
+				$time = strtotime($value);
1809
+				$value = date($date_format, $time);
1810
+			}
1811 1811
 
1812
-            ?>
1812
+			?>
1813 1813
             <script type="text/javascript">
1814 1814
 
1815 1815
                 jQuery(function () {
1816 1816
 
1817 1817
                     jQuery("#<?php echo $name;?>").datepicker({changeMonth: true, changeYear: true <?php
1818
-                    /**
1819
-                     * Used to add extra option to datepicker per custom field.
1820
-                     *
1821
-                     * @since 1.5.7
1822
-                     * @param string $name The custom field name.
1823
-                     */
1824
-                    echo apply_filters("gd_datepicker_extra_{$name}",'');?>});
1818
+					/**
1819
+					 * Used to add extra option to datepicker per custom field.
1820
+					 *
1821
+					 * @since 1.5.7
1822
+					 * @param string $name The custom field name.
1823
+					 */
1824
+					echo apply_filters("gd_datepicker_extra_{$name}",'');?>});
1825 1825
 
1826 1826
                     jQuery("#<?php echo $name;?>").datepicker("option", "dateFormat", '<?php echo $extra_fields['date_format'];?>');
1827 1827
 
@@ -1837,7 +1837,7 @@  discard block
 block discarded – undo
1837 1837
                 <label>
1838 1838
 
1839 1839
                     <?php $site_title = __($site_title, 'geodirectory');
1840
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1840
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1841 1841
                     <?php if ($is_required) echo '<span>*</span>';?>
1842 1842
                 </label>
1843 1843
 
@@ -1852,9 +1852,9 @@  discard block
 block discarded – undo
1852 1852
 
1853 1853
         <?php } elseif ($type == 'time') {
1854 1854
 
1855
-            if ($value != '')
1856
-                $value = date('H:i', strtotime($value));
1857
-            ?>
1855
+			if ($value != '')
1856
+				$value = date('H:i', strtotime($value));
1857
+			?>
1858 1858
             <script type="text/javascript">
1859 1859
                 jQuery(document).ready(function () {
1860 1860
 
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
                 <label>
1871 1871
 
1872 1872
                     <?php $site_title = __($site_title, 'geodirectory');
1873
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1873
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1874 1874
                     <?php if ($is_required) echo '<span>*</span>';?>
1875 1875
                 </label>
1876 1876
                 <input readonly="readonly" field_type="<?php echo $type;?>" name="<?php echo $name;?>"
@@ -1883,110 +1883,110 @@  discard block
 block discarded – undo
1883 1883
             </div>
1884 1884
 
1885 1885
         <?php } elseif ($type == 'taxonomy') {
1886
-            if ($value == $val['default']) {
1887
-                $value = '';
1888
-            } ?>
1886
+			if ($value == $val['default']) {
1887
+				$value = '';
1888
+			} ?>
1889 1889
             <div id="<?php echo $name;?>_row"
1890 1890
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
1891 1891
                 <label>
1892 1892
                     <?php $site_title = __($site_title, 'geodirectory');
1893
-                    echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1893
+					echo (trim($site_title)) ? $site_title : '&nbsp;'; ?>
1894 1894
                     <?php if ($is_required) echo '<span>*</span>';?>
1895 1895
                 </label>
1896 1896
 
1897 1897
                 <div id="<?php echo $name;?>" class="geodir_taxonomy_field" style="float:left; width:70%;">
1898 1898
                     <?php
1899
-                    global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats;
1899
+					global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats;
1900 1900
 
1901
-                    $exclude_cats = array();
1901
+					$exclude_cats = array();
1902 1902
 
1903
-                    if ($is_admin == '1') {
1903
+					if ($is_admin == '1') {
1904 1904
 
1905
-                        $post_type = get_post_type();
1905
+						$post_type = get_post_type();
1906 1906
 
1907
-                        $package_info = array();
1907
+						$package_info = array();
1908 1908
 
1909
-                        $package_info = (array)geodir_post_package_info($package_info, $post, $post_type);
1909
+						$package_info = (array)geodir_post_package_info($package_info, $post, $post_type);
1910 1910
 
1911
-                        if (!empty($package_info)) {
1911
+						if (!empty($package_info)) {
1912 1912
 
1913
-                            if (isset($package_info['cat']) && $package_info['cat'] != '') {
1913
+							if (isset($package_info['cat']) && $package_info['cat'] != '') {
1914 1914
 
1915
-                                $exclude_cats = explode(',', $package_info['cat']);
1915
+								$exclude_cats = explode(',', $package_info['cat']);
1916 1916
 
1917
-                            }
1918
-                        }
1919
-                    }
1917
+							}
1918
+						}
1919
+					}
1920 1920
 
1921
-                    $cat_display = unserialize($val['extra_fields']);
1921
+					$cat_display = unserialize($val['extra_fields']);
1922 1922
 
1923
-                    if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) {
1923
+					if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) {
1924 1924
 
1925
-                        $post_cat = implode(",", $post_cat[$name]);
1925
+						$post_cat = implode(",", $post_cat[$name]);
1926 1926
 
1927
-                    } else {
1928
-                        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
1929
-                            $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true);
1930
-                    }
1927
+					} else {
1928
+						if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
1929
+							$post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true);
1930
+					}
1931 1931
 
1932 1932
 
1933
-                    global $geodir_addon_list;
1934
-                    if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
1933
+					global $geodir_addon_list;
1934
+					if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
1935 1935
 
1936
-                        $catadd_limit = $wpdb->get_var(
1937
-                            $wpdb->prepare(
1938
-                                "SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d",
1939
-                                array($package_id)
1940
-                            )
1941
-                        );
1936
+						$catadd_limit = $wpdb->get_var(
1937
+							$wpdb->prepare(
1938
+								"SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d",
1939
+								array($package_id)
1940
+							)
1941
+						);
1942 1942
 
1943 1943
 
1944
-                    } else {
1945
-                        $catadd_limit = 0;
1946
-                    }
1944
+					} else {
1945
+						$catadd_limit = 0;
1946
+					}
1947 1947
 
1948 1948
 
1949
-                    if ($cat_display != '' && $cat_display != 'ajax_chained') {
1949
+					if ($cat_display != '' && $cat_display != 'ajax_chained') {
1950 1950
 
1951
-                        $required_limit_msg = '';
1952
-                        if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') {
1951
+						$required_limit_msg = '';
1952
+						if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') {
1953 1953
 
1954
-                            $required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory');
1954
+							$required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory');
1955 1955
 
1956
-                        } else {
1957
-                            $required_limit_msg = $required_msg;
1958
-                        }
1956
+						} else {
1957
+							$required_limit_msg = $required_msg;
1958
+						}
1959 1959
 
1960
-                        echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']"  />';
1960
+						echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']"  />';
1961 1961
 
1962 1962
 
1963
-                        if ($cat_display == 'select' || $cat_display == 'multiselect') {
1963
+						if ($cat_display == 'select' || $cat_display == 'multiselect') {
1964 1964
 
1965
-                            $cat_display == '';
1966
-                            $multiple = '';
1967
-                            if ($cat_display == 'multiselect')
1968
-                                $multiple = 'multiple="multiple"';
1965
+							$cat_display == '';
1966
+							$multiple = '';
1967
+							if ($cat_display == 'multiselect')
1968
+								$multiple = 'multiple="multiple"';
1969 1969
 
1970
-                            echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
1970
+							echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
1971 1971
 
1972 1972
 
1973
-                            if ($cat_display == 'select')
1974
-                                echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
1973
+							if ($cat_display == 'select')
1974
+								echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
1975 1975
 
1976
-                        }
1976
+						}
1977 1977
 
1978
-                        echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0);
1978
+						echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0);
1979 1979
 
1980
-                        if ($cat_display == 'select' || $cat_display == 'multiselect')
1981
-                            echo '</select>';
1980
+						if ($cat_display == 'select' || $cat_display == 'multiselect')
1981
+							echo '</select>';
1982 1982
 
1983
-                    } else {
1983
+					} else {
1984 1984
 
1985
-                        echo geodir_custom_taxonomy_walker2($name, $catadd_limit);
1985
+						echo geodir_custom_taxonomy_walker2($name, $catadd_limit);
1986 1986
 
1987
-                    }
1987
+					}
1988 1988
 
1989
-                    ?>
1989
+					?>
1990 1990
                 </div>
1991 1991
 
1992 1992
                 <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span>
@@ -2001,46 +2001,46 @@  discard block
 block discarded – undo
2001 2001
 
2002 2002
 
2003 2003
 
2004
-            // adjust values here
2005
-            $file_id = $name; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
2004
+			// adjust values here
2005
+			$file_id = $name; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
2006 2006
 
2007
-            if ($value != '') {
2007
+			if ($value != '') {
2008 2008
 
2009
-                $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls.
2009
+				$file_value = trim($value, ","); // this will be initial value of the above form field. Image urls.
2010 2010
 
2011
-            } else
2012
-                $file_value = '';
2011
+			} else
2012
+				$file_value = '';
2013 2013
 
2014
-            if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple'])
2015
-                $file_multiple = true; // allow multiple files upload
2016
-            else
2017
-                $file_multiple = false;
2014
+			if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple'])
2015
+				$file_multiple = true; // allow multiple files upload
2016
+			else
2017
+				$file_multiple = false;
2018 2018
 
2019
-            if (isset($extra_fields['image_limit']) && $extra_fields['image_limit'])
2020
-                $file_image_limit = $extra_fields['image_limit'];
2021
-            else
2022
-                $file_image_limit = 1;
2019
+			if (isset($extra_fields['image_limit']) && $extra_fields['image_limit'])
2020
+				$file_image_limit = $extra_fields['image_limit'];
2021
+			else
2022
+				$file_image_limit = 1;
2023 2023
 
2024
-            $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2024
+			$file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2025 2025
 
2026
-            $file_height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2026
+			$file_height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2027 2027
 
2028
-            if (!empty($file_value)) {
2029
-                $curImages = explode(',', $file_value);
2030
-                if (!empty($curImages))
2031
-                    $file_totImg = count($curImages);
2032
-            }
2028
+			if (!empty($file_value)) {
2029
+				$curImages = explode(',', $file_value);
2030
+				if (!empty($curImages))
2031
+					$file_totImg = count($curImages);
2032
+			}
2033 2033
 			
2034 2034
 			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
2035 2035
 			$display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
2036 2036
 
2037
-            ?>
2037
+			?>
2038 2038
             <?php /*?> <h5 class="geodir-form_title"> <?php echo $site_title; ?>
2039 2039
 				 <?php if($file_image_limit!=0 && $file_image_limit==1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('image with this package').')</small>';} ?>
2040 2040
 				 <?php if($file_image_limit!=0 && $file_image_limit>1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('images with this package').')</small>';} ?>
2041 2041
 				 <?php if($file_image_limit==0){echo '<br /><small>('.__('You can upload unlimited images with this package').')</small>';} ?>
2042 2042
 			</h5>   <?php */
2043
-            ?>
2043
+			?>
2044 2044
 
2045 2045
             <div id="<?php echo $name;?>_row"
2046 2046
                  class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>">
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
                 <div id="<?php echo $file_id; ?>dropbox" style="text-align:center;">
2049 2049
                     <label
2050 2050
                         style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory');
2051
-                        echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label>
2051
+						echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label>
2052 2052
                     <input class="geodir-custom-file-upload" field_type="file" type="hidden"
2053 2053
                            name="<?php echo $file_id; ?>" id="<?php echo $file_id; ?>"
2054 2054
                            value="<?php echo esc_attr($file_value); ?>"/>
@@ -2060,17 +2060,17 @@  discard block
 block discarded – undo
2060 2060
 					<?php } ?>
2061 2061
                     <input type="hidden" name="<?php echo $file_id; ?>totImg" id="<?php echo $file_id; ?>totImg"
2062 2062
                            value="<?php if (isset($file_totImg)) {
2063
-                               echo esc_attr($file_totImg);
2064
-                           } else {
2065
-                               echo '0';
2066
-                           } ?>"/>
2063
+							   echo esc_attr($file_totImg);
2064
+						   } else {
2065
+							   echo '0';
2066
+						   } ?>"/>
2067 2067
 
2068 2068
                     <div style="float:left; width:55%;">
2069 2069
                         <div
2070 2070
                             class="plupload-upload-uic hide-if-no-js <?php if ($file_multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
2071 2071
                             id="<?php echo $file_id; ?>plupload-upload-ui" style="float:left; width:30%;">
2072 2072
                             <?php /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */
2073
-                            ?>
2073
+							?>
2074 2074
                             <input id="<?php echo $file_id; ?>plupload-browse-button" type="button"
2075 2075
                                    value="<?php ($file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory') ); ?>"
2076 2076
                                    class="geodir_button" style="margin-top:10px;"/>
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
                             style=" clear:inherit; margin-top:0; margin-left:15px; padding-top:10px; float:left; width:50%;">
2090 2090
                         </div>
2091 2091
                         <?php /*?><span id="upload-msg" ><?php _e('Please drag &amp; drop the images to rearrange the order');?></span><?php */
2092
-                        ?>
2092
+						?>
2093 2093
 
2094 2094
                         <span id="<?php echo $file_id; ?>upload-error" style="display:none"></span>
2095 2095
 
@@ -2103,20 +2103,20 @@  discard block
 block discarded – undo
2103 2103
 
2104 2104
 
2105 2105
         <?php }
2106
-        /**
2107
-         * Called after the custom fields info is output for submitting a post.
2108
-         *
2109
-         * Used dynamic hook type geodir_after_custom_form_field_$name.
2110
-         *
2111
-         * @since 1.0.0
2112
-         * @param string $listing_type The post post type.
2113
-         * @param int $package_id The price package ID for the post.
2114
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
2115
-         * @see 'geodir_before_custom_form_field_$name'
2116
-         */
2117
-        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
2118
-
2119
-    }
2106
+		/**
2107
+		 * Called after the custom fields info is output for submitting a post.
2108
+		 *
2109
+		 * Used dynamic hook type geodir_after_custom_form_field_$name.
2110
+		 *
2111
+		 * @since 1.0.0
2112
+		 * @param string $listing_type The post post type.
2113
+		 * @param int $package_id The price package ID for the post.
2114
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
2115
+		 * @see 'geodir_before_custom_form_field_$name'
2116
+		 */
2117
+		do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
2118
+
2119
+	}
2120 2120
 
2121 2121
 }
2122 2122
 
@@ -2127,31 +2127,31 @@  discard block
 block discarded – undo
2127 2127
 	 *
2128 2128
 	 * @since 1.0.0
2129 2129
 	 * @package GeoDirectory
2130
-     * @global object $wpdb WordPress Database object.
2130
+	 * @global object $wpdb WordPress Database object.
2131 2131
 	 * @param string $key The key you want to look for.
2132 2132
 	 * @param string $value The value of the key you want to look for.
2133 2133
 	 * @param string $geodir_post_type The post type.
2134 2134
 	 * @return bool|mixed Returns field info when available. otherwise returns false.
2135 2135
 	 */
2136 2136
 	function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '')
2137
-    {
2137
+	{
2138 2138
 
2139
-        global $wpdb;
2139
+		global $wpdb;
2140 2140
 
2141
-        $filter = $wpdb->get_row(
2142
-            $wpdb->prepare(
2143
-                "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
2144
-                array($geodir_post_type)
2145
-            )
2146
-        );
2141
+		$filter = $wpdb->get_row(
2142
+			$wpdb->prepare(
2143
+				"SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
2144
+				array($geodir_post_type)
2145
+			)
2146
+		);
2147 2147
 
2148
-        if ($filter) {
2149
-            return $filter;
2150
-        } else {
2151
-            return false;
2152
-        }
2148
+		if ($filter) {
2149
+			return $filter;
2150
+		} else {
2151
+			return false;
2152
+		}
2153 2153
 
2154
-    }
2154
+	}
2155 2155
 }
2156 2156
 
2157 2157
 
@@ -2161,118 +2161,118 @@  discard block
 block discarded – undo
2161 2161
 	 *
2162 2162
 	 * @since 1.0.0
2163 2163
 	 * @since 1.5.7 Custom fields option values added to db translation.
2164
-     *              Changes to display url fields title.
2164
+	 *              Changes to display url fields title.
2165 2165
 	 * @package GeoDirectory
2166
-     * @global object $wpdb WordPress Database object.
2167
-     * @global object $post The current post object.
2168
-     * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
2169
-     *
2166
+	 * @global object $wpdb WordPress Database object.
2167
+	 * @global object $post The current post object.
2168
+	 * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
2169
+	 *
2170 2170
 	 * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
2171 2171
 	 * @return string Returns listing info html.
2172 2172
 	 */
2173 2173
 	function geodir_show_listing_info($fields_location = '') {
2174
-        global $post, $preview, $wpdb, $send_to_friend;
2174
+		global $post, $preview, $wpdb, $send_to_friend;
2175 2175
 
2176
-        $payment_info = array();
2177
-        $package_info = array();
2176
+		$payment_info = array();
2177
+		$package_info = array();
2178 2178
 
2179
-        $package_info = geodir_post_package_info($package_info, $post);
2180
-        $post_package_id = $package_info->pid;
2181
-        $p_type = (geodir_get_current_posttype()) ? geodir_get_current_posttype() : $post->post_type;
2179
+		$package_info = geodir_post_package_info($package_info, $post);
2180
+		$post_package_id = $package_info->pid;
2181
+		$p_type = (geodir_get_current_posttype()) ? geodir_get_current_posttype() : $post->post_type;
2182 2182
 		$send_to_friend = false;
2183 2183
 
2184
-        ob_start();
2185
-        $fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location);
2184
+		ob_start();
2185
+		$fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location);
2186 2186
 
2187
-        if (!empty($fields_info)) {
2188
-            //echo '<div class="geodir-company_info field-group">';
2189
-            $field_set_start = 0;
2187
+		if (!empty($fields_info)) {
2188
+			//echo '<div class="geodir-company_info field-group">';
2189
+			$field_set_start = 0;
2190 2190
 
2191 2191
 
2192
-            if ($fields_location == 'detail')
2192
+			if ($fields_location == 'detail')
2193 2193
 
2194
-                $i = 1;
2195
-            foreach ($fields_info as $type) {
2194
+				$i = 1;
2195
+			foreach ($fields_info as $type) {
2196 2196
 				$type = stripslashes_deep($type); // strip slashes
2197
-                $html = '';
2198
-                $html_var = '';
2199
-                $field_icon = '';
2197
+				$html = '';
2198
+				$html_var = '';
2199
+				$field_icon = '';
2200 2200
 
2201
-                $variables_array = array();
2201
+				$variables_array = array();
2202 2202
 
2203
-                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'))) {
2204
-                    continue;
2205
-                }
2203
+				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'))) {
2204
+					continue;
2205
+				}
2206 2206
 
2207
-                if ($type['type'] != 'fieldset'):
2208
-                    $variables_array['post_id'] = $post->ID;
2209
-                    $variables_array['label'] = __($type['site_title'], 'geodirectory');
2210
-                    $variables_array['value'] = '';
2211
-                    if (isset($post->{$type['htmlvar_name']}))
2212
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
2213
-                endif;
2207
+				if ($type['type'] != 'fieldset'):
2208
+					$variables_array['post_id'] = $post->ID;
2209
+					$variables_array['label'] = __($type['site_title'], 'geodirectory');
2210
+					$variables_array['value'] = '';
2211
+					if (isset($post->{$type['htmlvar_name']}))
2212
+						$variables_array['value'] = $post->{$type['htmlvar_name']};
2213
+				endif;
2214 2214
 
2215
-                //if($type['field_icon'])
2215
+				//if($type['field_icon'])
2216 2216
 
2217
-                if (strpos($type['field_icon'], 'http') !== false) {
2218
-                    $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
2219
-                } elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
2220
-                    $field_icon = '<i class="' . $type['field_icon'] . '"></i>';
2221
-                }
2222
-                //else{$field_icon = $type['field_icon'];}
2217
+				if (strpos($type['field_icon'], 'http') !== false) {
2218
+					$field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
2219
+				} elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
2220
+					$field_icon = '<i class="' . $type['field_icon'] . '"></i>';
2221
+				}
2222
+				//else{$field_icon = $type['field_icon'];}
2223 2223
 
2224 2224
 
2225
-                switch ($type['type']) {
2225
+				switch ($type['type']) {
2226 2226
 
2227
-                    case 'fieldset':
2227
+					case 'fieldset':
2228 2228
 
2229
-                        $fieldset_class = 'fieldset-'.sanitize_title_with_dashes($type['site_title']);
2229
+						$fieldset_class = 'fieldset-'.sanitize_title_with_dashes($type['site_title']);
2230 2230
 
2231
-                        if ($field_set_start == 1) {
2232
-                            echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>';
2233
-                        } else {
2234
-                            echo '<h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>';
2235
-                            $field_set_start = 1;
2236
-                        }
2231
+						if ($field_set_start == 1) {
2232
+							echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>';
2233
+						} else {
2234
+							echo '<h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>';
2235
+							$field_set_start = 1;
2236
+						}
2237 2237
 
2238
-                        break;
2238
+						break;
2239 2239
 
2240
-                    case 'address':
2240
+					case 'address':
2241 2241
 
2242
-                        $html_var = $type['htmlvar_name'] . '_address';
2242
+						$html_var = $type['htmlvar_name'] . '_address';
2243 2243
 
2244
-                        if ($type['extra_fields']) {
2244
+						if ($type['extra_fields']) {
2245 2245
 
2246
-                            $extra_fields = unserialize($type['extra_fields']);
2246
+							$extra_fields = unserialize($type['extra_fields']);
2247 2247
 
2248
-                            $addition_fields = '';
2248
+							$addition_fields = '';
2249 2249
 
2250
-                            if (!empty($extra_fields)) {
2251
-                                /**
2252
-                                 * Filter "show city in address" value.
2253
-                                 *
2254
-                                 * @since 1.0.0
2255
-                                 */
2256
-                                $show_city_in_address = apply_filters('geodir_show_city_in_address', false);
2257
-                                if (isset($extra_fields['show_city']) && $extra_fields['show_city'] && $show_city_in_address) {
2258
-                                    $field = $type['htmlvar_name'] . '_city';
2259
-                                    if ($post->$field) {
2260
-                                        $addition_fields .= ', ' . $post->$field;
2261
-                                    }
2262
-                                }
2250
+							if (!empty($extra_fields)) {
2251
+								/**
2252
+								 * Filter "show city in address" value.
2253
+								 *
2254
+								 * @since 1.0.0
2255
+								 */
2256
+								$show_city_in_address = apply_filters('geodir_show_city_in_address', false);
2257
+								if (isset($extra_fields['show_city']) && $extra_fields['show_city'] && $show_city_in_address) {
2258
+									$field = $type['htmlvar_name'] . '_city';
2259
+									if ($post->$field) {
2260
+										$addition_fields .= ', ' . $post->$field;
2261
+									}
2262
+								}
2263 2263
 
2264 2264
 
2265
-                                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
2266
-                                    $field = $type['htmlvar_name'] . '_zip';
2267
-                                    if ($post->$field) {
2268
-                                        $addition_fields .= ', ' . $post->$field;
2269
-                                    }
2270
-                                }
2265
+								if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
2266
+									$field = $type['htmlvar_name'] . '_zip';
2267
+									if ($post->$field) {
2268
+										$addition_fields .= ', ' . $post->$field;
2269
+									}
2270
+								}
2271 2271
 
2272
-                            }
2272
+							}
2273 2273
 
2274
-                        }
2275
-                        /*if($type['extra_fields'])
2274
+						}
2275
+						/*if($type['extra_fields'])
2276 2276
 						{
2277 2277
 							
2278 2278
 							$extra_fields = unserialize($type['extra_fields']);
@@ -2321,307 +2321,307 @@  discard block
 block discarded – undo
2321 2321
 						
2322 2322
 						}*/
2323 2323
 
2324
-                        if ($post->$html_var):
2325
-
2326
-                            if (strpos($field_icon, 'http') !== false) {
2327
-                                $field_icon_af = '';
2328
-                            } elseif ($field_icon == '') {
2329
-                                $field_icon_af = '<i class="fa fa-home"></i>';
2330
-                            } else {
2331
-                                $field_icon_af = $field_icon;
2332
-                                $field_icon = '';
2333
-                            }
2334
-
2335
-                            $geodir_odd_even = '';
2336
-                            if ($fields_location == 'detail') {
2337
-
2338
-                                $geodir_odd_even = 'geodir_more_info_odd';
2339
-                                if ($i % 2 == 0)
2340
-                                    $geodir_odd_even = 'geodir_more_info_even';
2341
-
2342
-                                $i++;
2343
-                            }
2344
-
2345
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"  itemscope itemtype="http://schema.org/PostalAddress">';
2346
-                            $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af;
2347
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2348
-                            $html .= '</span>';
2349
-                            //print_r($_POST);
2350
-                            if ($preview) {
2351
-                                $html .= stripslashes($post->$html_var) . $addition_fields . '</p></div>';
2352
-                            } else {
2353
-                                if ($post->post_address) {
2354
-                                    $html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>';
2355
-                                }
2356
-                                if ($post->post_city) {
2357
-                                    $html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>';
2358
-                                }
2359
-                                if ($post->post_region) {
2360
-                                    $html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>';
2361
-                                }
2362
-                                if ($post->post_zip) {
2363
-                                    $html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>';
2364
-                                }
2365
-                                if ($post->post_country) {
2366
-                                    $html .= '<span itemprop="addressCountry">' . __($post->post_country, 'geodirectory') . '</span><br>';
2367
-                                }
2368
-                                $html .= '</div>';
2369
-                            }
2370
-
2371
-
2372
-                        endif;
2373
-
2374
-                        $variables_array['value'] = $post->$html_var;
2375
-
2376
-                        break;
2377
-
2378
-                    case 'url':
2379
-
2380
-                        $html_var = $type['htmlvar_name'];
2381
-
2382
-                        if ($post->{$type['htmlvar_name']}):
2383
-
2384
-                            if (strpos($field_icon, 'http') !== false) {
2385
-                                $field_icon_af = '';
2386
-                            } elseif ($field_icon == '') {
2387
-
2388
-                                if ($type['name'] == 'geodir_facebook') {
2389
-                                    $field_icon_af = '<i class="fa fa-facebook-square"></i>';
2390
-                                } elseif ($type['name'] == 'geodir_twitter') {
2391
-                                    $field_icon_af = '<i class="fa fa-twitter-square"></i>';
2392
-                                } else {
2393
-                                    $field_icon_af = '<i class="fa fa-link"></i>';
2394
-                                }
2395
-
2396
-                            } else {
2397
-                                $field_icon_af = $field_icon;
2398
-                                $field_icon = '';
2399
-                            }
2324
+						if ($post->$html_var):
2325
+
2326
+							if (strpos($field_icon, 'http') !== false) {
2327
+								$field_icon_af = '';
2328
+							} elseif ($field_icon == '') {
2329
+								$field_icon_af = '<i class="fa fa-home"></i>';
2330
+							} else {
2331
+								$field_icon_af = $field_icon;
2332
+								$field_icon = '';
2333
+							}
2334
+
2335
+							$geodir_odd_even = '';
2336
+							if ($fields_location == 'detail') {
2337
+
2338
+								$geodir_odd_even = 'geodir_more_info_odd';
2339
+								if ($i % 2 == 0)
2340
+									$geodir_odd_even = 'geodir_more_info_even';
2341
+
2342
+								$i++;
2343
+							}
2344
+
2345
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"  itemscope itemtype="http://schema.org/PostalAddress">';
2346
+							$html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af;
2347
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2348
+							$html .= '</span>';
2349
+							//print_r($_POST);
2350
+							if ($preview) {
2351
+								$html .= stripslashes($post->$html_var) . $addition_fields . '</p></div>';
2352
+							} else {
2353
+								if ($post->post_address) {
2354
+									$html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>';
2355
+								}
2356
+								if ($post->post_city) {
2357
+									$html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>';
2358
+								}
2359
+								if ($post->post_region) {
2360
+									$html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>';
2361
+								}
2362
+								if ($post->post_zip) {
2363
+									$html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>';
2364
+								}
2365
+								if ($post->post_country) {
2366
+									$html .= '<span itemprop="addressCountry">' . __($post->post_country, 'geodirectory') . '</span><br>';
2367
+								}
2368
+								$html .= '</div>';
2369
+							}
2370
+
2371
+
2372
+						endif;
2373
+
2374
+						$variables_array['value'] = $post->$html_var;
2375
+
2376
+						break;
2377
+
2378
+					case 'url':
2379
+
2380
+						$html_var = $type['htmlvar_name'];
2381
+
2382
+						if ($post->{$type['htmlvar_name']}):
2383
+
2384
+							if (strpos($field_icon, 'http') !== false) {
2385
+								$field_icon_af = '';
2386
+							} elseif ($field_icon == '') {
2387
+
2388
+								if ($type['name'] == 'geodir_facebook') {
2389
+									$field_icon_af = '<i class="fa fa-facebook-square"></i>';
2390
+								} elseif ($type['name'] == 'geodir_twitter') {
2391
+									$field_icon_af = '<i class="fa fa-twitter-square"></i>';
2392
+								} else {
2393
+									$field_icon_af = '<i class="fa fa-link"></i>';
2394
+								}
2395
+
2396
+							} else {
2397
+								$field_icon_af = $field_icon;
2398
+								$field_icon = '';
2399
+							}
2400 2400
 							
2401 2401
 							$a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
2402 2402
 
2403 2403
 
2404 2404
 							$website = !empty($a_url['url']) ? $a_url['url'] : '';
2405 2405
 							$title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title'];
2406
-                            if(!empty($type['default_value'])){$title = $type['default_value'];}
2406
+							if(!empty($type['default_value'])){$title = $type['default_value'];}
2407 2407
 							$title = $title != '' ? __(stripslashes($title), 'geodirectory') : '';
2408 2408
 
2409 2409
 
2410
-                            $geodir_odd_even = '';
2411
-                            if ($fields_location == 'detail') {
2410
+							$geodir_odd_even = '';
2411
+							if ($fields_location == 'detail') {
2412 2412
 
2413
-                                $geodir_odd_even = 'geodir_more_info_odd';
2414
-                                if ($i % 2 == 0)
2415
-                                    $geodir_odd_even = 'geodir_more_info_even';
2413
+								$geodir_odd_even = 'geodir_more_info_odd';
2414
+								if ($i % 2 == 0)
2415
+									$geodir_odd_even = 'geodir_more_info_even';
2416 2416
 
2417
-                                $i++;
2418
-                            }
2417
+								$i++;
2418
+							}
2419 2419
 
2420 2420
 
2421
-                            // all search engines that use the nofollow value exclude links that use it from their ranking calculation
2422
-                            $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"';
2423
-                            /**
2424
-                             * Filter custom field website name.
2425
-                             *
2426
-                             * @since 1.0.0
2427
-                             *
2428
-                             * @param string $title Website Title.
2429
-                             * @param string $website Website URL.
2430
-                             * @param int $post->ID Post ID.
2431
-                             */
2432
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['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>';
2421
+							// all search engines that use the nofollow value exclude links that use it from their ranking calculation
2422
+							$rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"';
2423
+							/**
2424
+							 * Filter custom field website name.
2425
+							 *
2426
+							 * @since 1.0.0
2427
+							 *
2428
+							 * @param string $title Website Title.
2429
+							 * @param string $website Website URL.
2430
+							 * @param int $post->ID Post ID.
2431
+							 */
2432
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['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>';
2433 2433
 
2434
-                        endif;
2434
+						endif;
2435 2435
 
2436
-                        break;
2436
+						break;
2437 2437
 
2438
-                    case 'phone':
2438
+					case 'phone':
2439 2439
 
2440
-                        $html_var = $type['htmlvar_name'];
2440
+						$html_var = $type['htmlvar_name'];
2441 2441
 
2442
-                        if ($post->{$type['htmlvar_name']}):
2442
+						if ($post->{$type['htmlvar_name']}):
2443 2443
 
2444
-                            if (strpos($field_icon, 'http') !== false) {
2445
-                                $field_icon_af = '';
2446
-                            } elseif ($field_icon == '') {
2447
-                                $field_icon_af = '<i class="fa fa-phone"></i>';
2448
-                            } else {
2449
-                                $field_icon_af = $field_icon;
2450
-                                $field_icon = '';
2451
-                            }
2444
+							if (strpos($field_icon, 'http') !== false) {
2445
+								$field_icon_af = '';
2446
+							} elseif ($field_icon == '') {
2447
+								$field_icon_af = '<i class="fa fa-phone"></i>';
2448
+							} else {
2449
+								$field_icon_af = $field_icon;
2450
+								$field_icon = '';
2451
+							}
2452 2452
 
2453
-                            $geodir_odd_even = '';
2454
-                            if ($fields_location == 'detail') {
2453
+							$geodir_odd_even = '';
2454
+							if ($fields_location == 'detail') {
2455 2455
 
2456
-                                $geodir_odd_even = 'geodir_more_info_odd';
2457
-                                if ($i % 2 == 0)
2458
-                                    $geodir_odd_even = 'geodir_more_info_even';
2456
+								$geodir_odd_even = 'geodir_more_info_odd';
2457
+								if ($i % 2 == 0)
2458
+									$geodir_odd_even = 'geodir_more_info_even';
2459 2459
 
2460
-                                $i++;
2461
-                            }
2460
+								$i++;
2461
+							}
2462 2462
 
2463
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af .
2464
-                                $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2465
-                            $html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$type['htmlvar_name']}) . '">' . stripslashes($post->{$type['htmlvar_name']}) . '</a></div>';
2463
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af .
2464
+								$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2465
+							$html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$type['htmlvar_name']}) . '">' . stripslashes($post->{$type['htmlvar_name']}) . '</a></div>';
2466 2466
 
2467
-                        endif;
2467
+						endif;
2468 2468
 
2469
-                        break;
2469
+						break;
2470 2470
 
2471
-                    case 'time':
2471
+					case 'time':
2472 2472
 
2473
-                        $html_var = $type['htmlvar_name'];
2473
+						$html_var = $type['htmlvar_name'];
2474 2474
 
2475
-                        if ($post->{$type['htmlvar_name']}):
2475
+						if ($post->{$type['htmlvar_name']}):
2476 2476
 
2477
-                            $value = '';
2478
-                            if ($post->{$type['htmlvar_name']} != '')
2479
-                                //$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
2480
-                                $value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
2477
+							$value = '';
2478
+							if ($post->{$type['htmlvar_name']} != '')
2479
+								//$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
2480
+								$value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
2481 2481
 
2482
-                            if (strpos($field_icon, 'http') !== false) {
2483
-                                $field_icon_af = '';
2484
-                            } elseif ($field_icon == '') {
2485
-                                $field_icon_af = '<i class="fa fa-clock-o"></i>';
2486
-                            } else {
2487
-                                $field_icon_af = $field_icon;
2488
-                                $field_icon = '';
2489
-                            }
2482
+							if (strpos($field_icon, 'http') !== false) {
2483
+								$field_icon_af = '';
2484
+							} elseif ($field_icon == '') {
2485
+								$field_icon_af = '<i class="fa fa-clock-o"></i>';
2486
+							} else {
2487
+								$field_icon_af = $field_icon;
2488
+								$field_icon = '';
2489
+							}
2490 2490
 
2491
-                            $geodir_odd_even = '';
2492
-                            if ($fields_location == 'detail') {
2491
+							$geodir_odd_even = '';
2492
+							if ($fields_location == 'detail') {
2493 2493
 
2494
-                                $geodir_odd_even = 'geodir_more_info_odd';
2495
-                                if ($i % 2 == 0)
2496
-                                    $geodir_odd_even = 'geodir_more_info_even';
2494
+								$geodir_odd_even = 'geodir_more_info_odd';
2495
+								if ($i % 2 == 0)
2496
+									$geodir_odd_even = 'geodir_more_info_even';
2497 2497
 
2498
-                                $i++;
2499
-                            }
2498
+								$i++;
2499
+							}
2500 2500
 
2501
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
2502
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2503
-                            $html .= '</span>' . stripslashes($value) . '</div>';
2501
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
2502
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2503
+							$html .= '</span>' . stripslashes($value) . '</div>';
2504 2504
 
2505
-                        endif;
2505
+						endif;
2506 2506
 
2507
-                        break;
2507
+						break;
2508 2508
 
2509
-                    case 'datepicker':
2509
+					case 'datepicker':
2510 2510
 
2511
-                        if ($post->{$type['htmlvar_name']}):
2511
+						if ($post->{$type['htmlvar_name']}):
2512 2512
 
2513
-                            $date_format = geodir_default_date_format();
2514
-                            if ($type['extra_fields'] != '') {
2515
-                                $date_format = unserialize($type['extra_fields']);
2516
-                                $date_format = $date_format['date_format'];
2517
-                            }
2513
+							$date_format = geodir_default_date_format();
2514
+							if ($type['extra_fields'] != '') {
2515
+								$date_format = unserialize($type['extra_fields']);
2516
+								$date_format = $date_format['date_format'];
2517
+							}
2518 2518
 
2519
-                            $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
2520
-                            $replace = array('d','j','l','m','n','F','Y');//PHP date format
2519
+							$search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
2520
+							$replace = array('d','j','l','m','n','F','Y');//PHP date format
2521 2521
 
2522
-                            $date_format = str_replace($search, $replace, $date_format);
2522
+							$date_format = str_replace($search, $replace, $date_format);
2523 2523
 
2524
-                            $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
2524
+							$post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
2525 2525
 
2526
-                            $value = '';
2527
-                            if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
2528
-                                $value = date($date_format, strtotime($post_htmlvar_value));
2529
-                            }else{
2530
-                                continue;
2531
-                            }
2526
+							$value = '';
2527
+							if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
2528
+								$value = date($date_format, strtotime($post_htmlvar_value));
2529
+							}else{
2530
+								continue;
2531
+							}
2532 2532
 
2533
-                            if (strpos($field_icon, 'http') !== false) {
2534
-                                $field_icon_af = '';
2535
-                            } elseif ($field_icon == '') {
2536
-                                $field_icon_af = '<i class="fa fa-calendar"></i>';
2537
-                            } else {
2538
-                                $field_icon_af = $field_icon;
2539
-                                $field_icon = '';
2540
-                            }
2533
+							if (strpos($field_icon, 'http') !== false) {
2534
+								$field_icon_af = '';
2535
+							} elseif ($field_icon == '') {
2536
+								$field_icon_af = '<i class="fa fa-calendar"></i>';
2537
+							} else {
2538
+								$field_icon_af = $field_icon;
2539
+								$field_icon = '';
2540
+							}
2541 2541
 
2542
-                            $geodir_odd_even = '';
2543
-                            if ($fields_location == 'detail') {
2542
+							$geodir_odd_even = '';
2543
+							if ($fields_location == 'detail') {
2544 2544
 
2545
-                                $geodir_odd_even = 'geodir_more_info_odd';
2546
-                                if ($i % 2 == 0)
2547
-                                    $geodir_odd_even = 'geodir_more_info_even';
2545
+								$geodir_odd_even = 'geodir_more_info_odd';
2546
+								if ($i % 2 == 0)
2547
+									$geodir_odd_even = 'geodir_more_info_even';
2548 2548
 
2549
-                                $i++;
2550
-                            }
2549
+								$i++;
2550
+							}
2551 2551
 
2552
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af;
2553
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2554
-                            $html .= '</span>' . $value . '</div>';
2552
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af;
2553
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2554
+							$html .= '</span>' . $value . '</div>';
2555 2555
 
2556
-                        endif;
2556
+						endif;
2557 2557
 
2558
-                        break;
2558
+						break;
2559 2559
 
2560
-                    case 'text':
2560
+					case 'text':
2561 2561
 
2562
-                        $html_var = $type['htmlvar_name'];
2562
+						$html_var = $type['htmlvar_name'];
2563 2563
 
2564
-                        if (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']} != '' && $type['htmlvar_name'] == 'geodir_timing'):
2564
+						if (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']} != '' && $type['htmlvar_name'] == 'geodir_timing'):
2565 2565
 
2566
-                            if (strpos($field_icon, 'http') !== false) {
2567
-                                $field_icon_af = '';
2568
-                            } elseif ($field_icon == '') {
2569
-                                $field_icon_af = '<i class="fa fa-clock-o"></i>';
2570
-                            } else {
2571
-                                $field_icon_af = $field_icon;
2572
-                                $field_icon = '';
2573
-                            }
2566
+							if (strpos($field_icon, 'http') !== false) {
2567
+								$field_icon_af = '';
2568
+							} elseif ($field_icon == '') {
2569
+								$field_icon_af = '<i class="fa fa-clock-o"></i>';
2570
+							} else {
2571
+								$field_icon_af = $field_icon;
2572
+								$field_icon = '';
2573
+							}
2574 2574
 
2575
-                            $geodir_odd_even = '';
2576
-                            if ($fields_location == 'detail') {
2575
+							$geodir_odd_even = '';
2576
+							if ($fields_location == 'detail') {
2577 2577
 
2578
-                                $geodir_odd_even = 'geodir_more_info_odd';
2579
-                                if ($i % 2 == 0)
2580
-                                    $geodir_odd_even = 'geodir_more_info_even';
2578
+								$geodir_odd_even = 'geodir_more_info_odd';
2579
+								if ($i % 2 == 0)
2580
+									$geodir_odd_even = 'geodir_more_info_even';
2581 2581
 
2582
-                                $i++;
2583
-                            }
2582
+								$i++;
2583
+							}
2584 2584
 
2585
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
2586
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2587
-                            $html .= '</span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
2585
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
2586
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
2587
+							$html .= '</span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
2588 2588
 
2589
-                        elseif (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']}):
2589
+						elseif (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']}):
2590 2590
 
2591
-                            if (strpos($field_icon, 'http') !== false) {
2592
-                                $field_icon_af = '';
2593
-                            } elseif ($field_icon == '') {
2594
-                                $field_icon_af = '';
2595
-                            } else {
2596
-                                $field_icon_af = $field_icon;
2597
-                                $field_icon = '';
2598
-                            }
2591
+							if (strpos($field_icon, 'http') !== false) {
2592
+								$field_icon_af = '';
2593
+							} elseif ($field_icon == '') {
2594
+								$field_icon_af = '';
2595
+							} else {
2596
+								$field_icon_af = $field_icon;
2597
+								$field_icon = '';
2598
+							}
2599 2599
 
2600
-                            $geodir_odd_even = '';
2601
-                            if ($fields_location == 'detail') {
2600
+							$geodir_odd_even = '';
2601
+							if ($fields_location == 'detail') {
2602 2602
 
2603
-                                $geodir_odd_even = 'geodir_more_info_odd';
2604
-                                if ($i % 2 == 0)
2605
-                                    $geodir_odd_even = 'geodir_more_info_even';
2603
+								$geodir_odd_even = 'geodir_more_info_odd';
2604
+								if ($i % 2 == 0)
2605
+									$geodir_odd_even = 'geodir_more_info_even';
2606 2606
 
2607
-                                $i++;
2608
-                            }
2607
+								$i++;
2608
+							}
2609 2609
 
2610
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
2611
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2612
-                            $html .= '</span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
2610
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
2611
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2612
+							$html .= '</span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
2613 2613
 
2614
-                        endif;
2614
+						endif;
2615 2615
 
2616
-                        break;
2616
+						break;
2617 2617
 
2618
-                    case 'radio':
2618
+					case 'radio':
2619 2619
 
2620
-                        $html_var = $type['htmlvar_name'];
2621
-                        $html_val = __($post->{$type['htmlvar_name']}, 'geodirectory');
2622
-                        if ($post->{$type['htmlvar_name']} != ''):
2620
+						$html_var = $type['htmlvar_name'];
2621
+						$html_val = __($post->{$type['htmlvar_name']}, 'geodirectory');
2622
+						if ($post->{$type['htmlvar_name']} != ''):
2623 2623
 
2624
-                            if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
2624
+							if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
2625 2625
 								$html_val = __('No', 'geodirectory');
2626 2626
 							} else if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
2627 2627
 								$html_val = __('Yes', 'geodirectory');
@@ -2639,75 +2639,75 @@  discard block
 block discarded – undo
2639 2639
 								}
2640 2640
 							}
2641 2641
 
2642
-                            if (strpos($field_icon, 'http') !== false) {
2643
-                                $field_icon_af = '';
2644
-                            } elseif ($field_icon == '') {
2645
-                                $field_icon_af = '';
2646
-                            } else {
2647
-                                $field_icon_af = $field_icon;
2648
-                                $field_icon = '';
2649
-                            }
2650
-
2651
-                            $geodir_odd_even = '';
2652
-                            if ($fields_location == 'detail') {
2642
+							if (strpos($field_icon, 'http') !== false) {
2643
+								$field_icon_af = '';
2644
+							} elseif ($field_icon == '') {
2645
+								$field_icon_af = '';
2646
+							} else {
2647
+								$field_icon_af = $field_icon;
2648
+								$field_icon = '';
2649
+							}
2653 2650
 
2654
-                                $geodir_odd_even = 'geodir_more_info_odd';
2655
-                                if ($i % 2 == 0)
2656
-                                    $geodir_odd_even = 'geodir_more_info_even';
2651
+							$geodir_odd_even = '';
2652
+							if ($fields_location == 'detail') {
2657 2653
 
2658
-                                $i++;
2659
-                            }
2654
+								$geodir_odd_even = 'geodir_more_info_odd';
2655
+								if ($i % 2 == 0)
2656
+									$geodir_odd_even = 'geodir_more_info_even';
2660 2657
 
2661
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
2662
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2663
-                            $html .= '</span>' . $html_val . '</div>';
2664
-                        endif;
2658
+								$i++;
2659
+							}
2665 2660
 
2666
-                        break;
2661
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
2662
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2663
+							$html .= '</span>' . $html_val . '</div>';
2664
+						endif;
2667 2665
 
2668
-                    case 'checkbox':
2666
+						break;
2669 2667
 
2670
-                        $html_var = $type['htmlvar_name'];
2668
+					case 'checkbox':
2671 2669
 
2672
-                        if ((int)$post->$html_var == 1):
2670
+						$html_var = $type['htmlvar_name'];
2673 2671
 
2674
-                            if ($post->{$type['htmlvar_name']} == '1'):
2675
-                                $html_val = __('Yes', 'geodirectory');
2676
-                            else:
2677
-                                $html_val = __('No', 'geodirectory');
2678
-                            endif;
2672
+						if ((int)$post->$html_var == 1):
2679 2673
 
2680
-                            if (strpos($field_icon, 'http') !== false) {
2681
-                                $field_icon_af = '';
2682
-                            } elseif ($field_icon == '') {
2683
-                                $field_icon_af = '';
2684
-                            } else {
2685
-                                $field_icon_af = $field_icon;
2686
-                                $field_icon = '';
2687
-                            }
2674
+							if ($post->{$type['htmlvar_name']} == '1'):
2675
+								$html_val = __('Yes', 'geodirectory');
2676
+							else:
2677
+								$html_val = __('No', 'geodirectory');
2678
+							endif;
2679
+
2680
+							if (strpos($field_icon, 'http') !== false) {
2681
+								$field_icon_af = '';
2682
+							} elseif ($field_icon == '') {
2683
+								$field_icon_af = '';
2684
+							} else {
2685
+								$field_icon_af = $field_icon;
2686
+								$field_icon = '';
2687
+							}
2688 2688
 
2689
-                            $geodir_odd_even = '';
2690
-                            if ($fields_location == 'detail') {
2689
+							$geodir_odd_even = '';
2690
+							if ($fields_location == 'detail') {
2691 2691
 
2692
-                                $geodir_odd_even = 'geodir_more_info_odd';
2693
-                                if ($i % 2 == 0)
2694
-                                    $geodir_odd_even = 'geodir_more_info_even';
2692
+								$geodir_odd_even = 'geodir_more_info_odd';
2693
+								if ($i % 2 == 0)
2694
+									$geodir_odd_even = 'geodir_more_info_even';
2695 2695
 
2696
-                                $i++;
2697
-                            }
2696
+								$i++;
2697
+							}
2698 2698
 
2699
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
2700
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2701
-                            $html .= '</span>' . $html_val . '</div>';
2702
-                        endif;
2699
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
2700
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2701
+							$html .= '</span>' . $html_val . '</div>';
2702
+						endif;
2703 2703
 
2704
-                        break;
2704
+						break;
2705 2705
 
2706
-                    case 'select':
2706
+					case 'select':
2707 2707
 
2708
-                        $html_var = $type['htmlvar_name'];
2708
+						$html_var = $type['htmlvar_name'];
2709 2709
 
2710
-                        if ($post->{$type['htmlvar_name']}):
2710
+						if ($post->{$type['htmlvar_name']}):
2711 2711
 							$field_value = __($post->$type['htmlvar_name'], 'geodirectory');
2712 2712
 							
2713 2713
 							if (!empty($type['option_values'])) {
@@ -2722,55 +2722,55 @@  discard block
 block discarded – undo
2722 2722
 								}
2723 2723
 							}
2724 2724
 							
2725
-                            if (strpos($field_icon, 'http') !== false) {
2726
-                                $field_icon_af = '';
2727
-                            } elseif ($field_icon == '') {
2728
-                                $field_icon_af = '';
2729
-                            } else {
2730
-                                $field_icon_af = $field_icon;
2731
-                                $field_icon = '';
2732
-                            }
2725
+							if (strpos($field_icon, 'http') !== false) {
2726
+								$field_icon_af = '';
2727
+							} elseif ($field_icon == '') {
2728
+								$field_icon_af = '';
2729
+							} else {
2730
+								$field_icon_af = $field_icon;
2731
+								$field_icon = '';
2732
+							}
2733 2733
 
2734
-                            $geodir_odd_even = '';
2735
-                            if ($fields_location == 'detail') {
2734
+							$geodir_odd_even = '';
2735
+							if ($fields_location == 'detail') {
2736 2736
 
2737
-                                $geodir_odd_even = 'geodir_more_info_odd';
2738
-                                if ($i % 2 == 0)
2739
-                                    $geodir_odd_even = 'geodir_more_info_even';
2737
+								$geodir_odd_even = 'geodir_more_info_odd';
2738
+								if ($i % 2 == 0)
2739
+									$geodir_odd_even = 'geodir_more_info_even';
2740 2740
 
2741
-                                $i++;
2742
-                            }
2741
+								$i++;
2742
+							}
2743 2743
 
2744
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
2745
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2746
-                            $html .= '</span>' . $field_value . '</div>';
2747
-                        endif;
2744
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
2745
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2746
+							$html .= '</span>' . $field_value . '</div>';
2747
+						endif;
2748 2748
 
2749
-                        break;
2749
+						break;
2750 2750
 
2751 2751
 
2752
-                    case 'multiselect':
2752
+					case 'multiselect':
2753 2753
 
2754
-                        $html_var = $type['htmlvar_name'];
2754
+						$html_var = $type['htmlvar_name'];
2755 2755
 
2756
-                        if (!empty($post->{$type['htmlvar_name']})):
2756
+						if (!empty($post->{$type['htmlvar_name']})):
2757 2757
 
2758
-                            if (is_array($post->{$type['htmlvar_name']})) {
2759
-                                $post->{$type['htmlvar_name']} = implode(', ', $post->{$type['htmlvar_name']});
2760
-                            }
2758
+							if (is_array($post->{$type['htmlvar_name']})) {
2759
+								$post->{$type['htmlvar_name']} = implode(', ', $post->{$type['htmlvar_name']});
2760
+							}
2761 2761
 
2762
-                            if (strpos($field_icon, 'http') !== false) {
2763
-                                $field_icon_af = '';
2764
-                            } elseif ($field_icon == '') {
2765
-                                $field_icon_af = '';
2766
-                            } else {
2767
-                                $field_icon_af = $field_icon;
2768
-                                $field_icon = '';
2769
-                            }
2762
+							if (strpos($field_icon, 'http') !== false) {
2763
+								$field_icon_af = '';
2764
+							} elseif ($field_icon == '') {
2765
+								$field_icon_af = '';
2766
+							} else {
2767
+								$field_icon_af = $field_icon;
2768
+								$field_icon = '';
2769
+							}
2770 2770
 							
2771 2771
 							$field_values = explode(',', trim($post->$type['htmlvar_name'], ","));
2772 2772
 
2773
-                            $option_values = array();
2773
+							$option_values = array();
2774 2774
 							if (!empty($type['option_values'])) {
2775 2775
 								$cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true);
2776 2776
 								
@@ -2781,170 +2781,170 @@  discard block
 block discarded – undo
2781 2781
 										}
2782 2782
 									}
2783 2783
 								}
2784
-                            }
2784
+							}
2785 2785
 							
2786
-                            $geodir_odd_even = '';
2787
-                            if ($fields_location == 'detail') {
2786
+							$geodir_odd_even = '';
2787
+							if ($fields_location == 'detail') {
2788 2788
 
2789
-                                $geodir_odd_even = 'geodir_more_info_odd';
2790
-                                if ($i % 2 == 0)
2791
-                                    $geodir_odd_even = 'geodir_more_info_even';
2789
+								$geodir_odd_even = 'geodir_more_info_odd';
2790
+								if ($i % 2 == 0)
2791
+									$geodir_odd_even = 'geodir_more_info_even';
2792 2792
 
2793
-                                $i++;
2794
-                            }
2793
+								$i++;
2794
+							}
2795 2795
 
2796
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
2797
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2798
-                            $html .= '</span>';
2796
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
2797
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2798
+							$html .= '</span>';
2799 2799
 
2800
-                            if (count($option_values) > 1) {
2801
-                                $html .= '<ul>';
2800
+							if (count($option_values) > 1) {
2801
+								$html .= '<ul>';
2802 2802
                                 
2803 2803
 								foreach ($option_values as $val) {
2804
-                                    $html .= '<li>' . $val . '</li>';
2805
-                                }
2804
+									$html .= '<li>' . $val . '</li>';
2805
+								}
2806 2806
                                 
2807 2807
 								$html .= '</ul>';
2808
-                            } else {
2809
-                                $html .= $post->$type['htmlvar_name'];
2810
-                            }
2811
-
2812
-                            $html .= '</div>';
2813
-                        endif;
2814
-                        break;
2815
-                    case 'email':
2808
+							} else {
2809
+								$html .= $post->$type['htmlvar_name'];
2810
+							}
2811
+
2812
+							$html .= '</div>';
2813
+						endif;
2814
+						break;
2815
+					case 'email':
2816 2816
 						if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
2817 2817
 							continue; // Remove Send Enquiry | Send To Friend from listings page
2818 2818
 						}
2819 2819
                        
2820
-					    if ($type['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$type['htmlvar_name']})) {
2821
-						    $send_to_friend = true;
2820
+						if ($type['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$type['htmlvar_name']})) {
2821
+							$send_to_friend = true;
2822 2822
 							$b_send_inquiry = '';
2823
-                            $b_sendtofriend = '';
2824
-
2825
-                            $html = '';
2826
-                            if (!$preview) {
2827
-                                $b_send_inquiry = 'b_send_inquiry';
2828
-                                $b_sendtofriend = 'b_sendtofriend';
2829
-                                $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>';
2830
-                            }
2831
-
2832
-                            if (strpos($field_icon, 'http') !== false) {
2833
-                                $field_icon_af = '';
2834
-                            } elseif ($field_icon == '') {
2835
-                                $field_icon_af = '<i class="fa fa-envelope"></i>';
2836
-                            } else {
2837
-                                $field_icon_af = $field_icon;
2838
-                                $field_icon = '';
2839
-                            }
2840
-
2841
-                            $geodir_odd_even = '';
2842
-                            if ($fields_location == 'detail') {
2843
-
2844
-                                $geodir_odd_even = 'geodir_more_info_odd';
2845
-                                if ($i % 2 == 0)
2846
-                                    $geodir_odd_even = 'geodir_more_info_even';
2847
-
2848
-                                $i++;
2849
-                            }
2850
-
2851
-                            $html .= '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
2852
-                            $seperator = '';
2853
-                            if ($post->{$type['htmlvar_name']}) {
2854
-                                $html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>';
2855
-                                $seperator = ' | ';
2856
-                            }
2857
-
2858
-                            if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
2859
-                                $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>';
2823
+							$b_sendtofriend = '';
2824
+
2825
+							$html = '';
2826
+							if (!$preview) {
2827
+								$b_send_inquiry = 'b_send_inquiry';
2828
+								$b_sendtofriend = 'b_sendtofriend';
2829
+								$html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>';
2830
+							}
2831
+
2832
+							if (strpos($field_icon, 'http') !== false) {
2833
+								$field_icon_af = '';
2834
+							} elseif ($field_icon == '') {
2835
+								$field_icon_af = '<i class="fa fa-envelope"></i>';
2836
+							} else {
2837
+								$field_icon_af = $field_icon;
2838
+								$field_icon = '';
2839
+							}
2840
+
2841
+							$geodir_odd_even = '';
2842
+							if ($fields_location == 'detail') {
2843
+
2844
+								$geodir_odd_even = 'geodir_more_info_odd';
2845
+								if ($i % 2 == 0)
2846
+									$geodir_odd_even = 'geodir_more_info_even';
2847
+
2848
+								$i++;
2860 2849
 							}
2861 2850
 
2862
-                            $html .= '</span></div>';
2851
+							$html .= '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
2852
+							$seperator = '';
2853
+							if ($post->{$type['htmlvar_name']}) {
2854
+								$html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>';
2855
+								$seperator = ' | ';
2856
+							}
2857
+
2858
+							if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
2859
+								$html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>';
2860
+							}
2863 2861
 
2862
+							$html .= '</span></div>';
2864 2863
 
2865
-                            if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') {
2866
-                                $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>';
2867
-                            } elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
2868
-                                $html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>';
2869
-                            } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
2870
-                                $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>';
2871
-                            }
2872 2864
 
2873
-                            /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
2865
+							if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') {
2866
+								$html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>';
2867
+							} elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
2868
+								$html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>';
2869
+							} elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
2870
+								$html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>';
2871
+							}
2872
+
2873
+							/*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
2874 2874
 
2875
-                        } else {
2875
+						} else {
2876 2876
 
2877
-                            if ($post->{$type['htmlvar_name']}) {
2878
-                                if (strpos($field_icon, 'http') !== false) {
2879
-                                    $field_icon_af = '';
2880
-                                } elseif ($field_icon == '') {
2881
-                                    $field_icon_af = '<i class="fa fa-envelope"></i>';
2882
-                                } else {
2883
-                                    $field_icon_af = $field_icon;
2884
-                                    $field_icon = '';
2885
-                                }
2877
+							if ($post->{$type['htmlvar_name']}) {
2878
+								if (strpos($field_icon, 'http') !== false) {
2879
+									$field_icon_af = '';
2880
+								} elseif ($field_icon == '') {
2881
+									$field_icon_af = '<i class="fa fa-envelope"></i>';
2882
+								} else {
2883
+									$field_icon_af = $field_icon;
2884
+									$field_icon = '';
2885
+								}
2886 2886
 
2887
-                                $geodir_odd_even = '';
2888
-                                if ($fields_location == 'detail') {
2887
+								$geodir_odd_even = '';
2888
+								if ($fields_location == 'detail') {
2889 2889
 
2890
-                                    $geodir_odd_even = 'geodir_more_info_odd';
2891
-                                    if ($i % 2 == 0)
2892
-                                        $geodir_odd_even = 'geodir_more_info_even';
2890
+									$geodir_odd_even = 'geodir_more_info_odd';
2891
+									if ($i % 2 == 0)
2892
+										$geodir_odd_even = 'geodir_more_info_even';
2893 2893
 
2894
-                                    $i++;
2895
-                                }
2894
+									$i++;
2895
+								}
2896 2896
 
2897
-                                $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
2898
-                                $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2899
-                                $html .= '</span><span class="geodir-email-address-output">';
2900
-                                $email = stripslashes($post->{$type['htmlvar_name']}) ;
2901
-                                if($e_split = explode('@',$email)){
2902
-                                    /**
2903
-                                     * Filter email custom field name output.
2904
-                                     *
2905
-                                     * @since 1.5.3
2906
-                                     *
2907
-                                     * @param string $email The email string being output.
2908
-                                     * @param array $type Custom field variables array.
2909
-                                     */
2910
-                                    $email_name = apply_filters('geodir_email_field_name_output',$email,$type);
2911
-                                    $html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
2912
-                                }else{
2913
-                                    $html .=  $email;
2914
-                                }
2915
-                                $html .= '</span></div>';
2916
-                            }
2897
+								$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
2898
+								$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2899
+								$html .= '</span><span class="geodir-email-address-output">';
2900
+								$email = stripslashes($post->{$type['htmlvar_name']}) ;
2901
+								if($e_split = explode('@',$email)){
2902
+									/**
2903
+									 * Filter email custom field name output.
2904
+									 *
2905
+									 * @since 1.5.3
2906
+									 *
2907
+									 * @param string $email The email string being output.
2908
+									 * @param array $type Custom field variables array.
2909
+									 */
2910
+									$email_name = apply_filters('geodir_email_field_name_output',$email,$type);
2911
+									$html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
2912
+								}else{
2913
+									$html .=  $email;
2914
+								}
2915
+								$html .= '</span></div>';
2916
+							}
2917 2917
 
2918
-                        }
2918
+						}
2919 2919
 
2920
-                        break;
2920
+						break;
2921 2921
 
2922 2922
 
2923
-                    case 'file':
2923
+					case 'file':
2924 2924
 
2925
-                        $html_var = $type['htmlvar_name'];
2925
+						$html_var = $type['htmlvar_name'];
2926 2926
 
2927
-                        if (!empty($post->{$type['htmlvar_name']})):
2927
+						if (!empty($post->{$type['htmlvar_name']})):
2928 2928
 
2929
-                            $files = explode(",", $post->{$type['htmlvar_name']});
2930
-                            if (!empty($files)):
2929
+							$files = explode(",", $post->{$type['htmlvar_name']});
2930
+							if (!empty($files)):
2931 2931
 
2932
-                               $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL;
2932
+							   $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL;
2933 2933
 							   $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'] : '';
2934 2934
 								
2935 2935
 								$file_paths = '';
2936
-                                foreach ($files as $file) {
2937
-                                    if (!empty($file)) {
2936
+								foreach ($files as $file) {
2937
+									if (!empty($file)) {
2938 2938
 
2939
-                                       // $filetype = wp_check_filetype($file);
2939
+									   // $filetype = wp_check_filetype($file);
2940 2940
 
2941
-                                        $image_name_arr = explode('/', $file);
2942
-                                        $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
2943
-                                        $filename = end($image_name_arr);
2944
-                                        $img_name_arr = explode('.', $filename);
2941
+										$image_name_arr = explode('/', $file);
2942
+										$curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
2943
+										$filename = end($image_name_arr);
2944
+										$img_name_arr = explode('.', $filename);
2945 2945
 
2946
-                                        $arr_file_type = wp_check_filetype($filename);
2947
-                                        if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
2946
+										$arr_file_type = wp_check_filetype($filename);
2947
+										if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
2948 2948
 											continue;
2949 2949
 										}
2950 2950
 										
@@ -2955,220 +2955,220 @@  discard block
 block discarded – undo
2955 2955
 											continue; // Invalid file type.
2956 2956
 										}
2957 2957
 
2958
-                                        //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
2958
+										//$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
2959 2959
 										$image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
2960 2960
 
2961
-                                        // If the uploaded file is image
2962
-                                        if (in_array($uploaded_file_type, $image_file_types)) {
2963
-                                            $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
2964
-                                            $file_paths .= '<a href="'.$file.'">';
2961
+										// If the uploaded file is image
2962
+										if (in_array($uploaded_file_type, $image_file_types)) {
2963
+											$file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
2964
+											$file_paths .= '<a href="'.$file.'">';
2965 2965
 											$file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
2966 2966
 											$file_paths .= '</a>';
2967
-                                            //$file_paths .= '<img src="'.$file.'"  />';	
2968
-                                            $file_paths .= '</div>';
2969
-                                        } else {
2967
+											//$file_paths .= '<img src="'.$file.'"  />';	
2968
+											$file_paths .= '</div>';
2969
+										} else {
2970 2970
 											$ext_path = '_' . $html_var . '_';
2971
-                                            $filename = explode($ext_path, $filename);
2972
-                                            $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>';
2973
-                                        }
2974
-                                    }
2975
-                                }
2976
-
2977
-                                if (strpos($field_icon, 'http') !== false) {
2978
-                                    $field_icon_af = '';
2979
-                                } elseif ($field_icon == '') {
2980
-                                    $field_icon_af = '';
2981
-                                } else {
2982
-                                    $field_icon_af = $field_icon;
2983
-                                    $field_icon = '';
2984
-                                }
2985
-
2986
-                                $geodir_odd_even = '';
2987
-                                if ($fields_location == 'detail') {
2988
-
2989
-                                    $geodir_odd_even = 'geodir_more_info_odd';
2990
-                                    if ($i % 2 == 0)
2991
-                                        $geodir_odd_even = 'geodir_more_info_even';
2992
-
2993
-                                    $i++;
2994
-                                }
2995
-
2996
-                                $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' geodir-custom-file-box ' . $type['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
2997
-                                $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">';
2998
-                                $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2999
-                                $html .= '</span>';
3000
-                                $html .= $file_paths . '</div></div>';
3001
-
3002
-                            endif;
3003
-                        endif;
3004
-
3005
-                        break;
3006
-
3007
-                    case 'textarea':
3008
-                        $html_var = $type['htmlvar_name'];
3009
-
3010
-                        if (!empty($post->{$type['htmlvar_name']})) {
3011
-
3012
-                            if (strpos($field_icon, 'http') !== false) {
3013
-                                $field_icon_af = '';
3014
-                            } elseif ($field_icon == '') {
3015
-                                $field_icon_af = '';
3016
-                            } else {
3017
-                                $field_icon_af = $field_icon;
3018
-                                $field_icon = '';
3019
-                            }
3020
-
3021
-                            $geodir_odd_even = '';
3022
-                            if ($fields_location == 'detail') {
3023
-
3024
-                                $geodir_odd_even = 'geodir_more_info_odd';
3025
-                                if ($i % 2 == 0)
3026
-                                    $geodir_odd_even = 'geodir_more_info_even';
3027
-
3028
-                                $i++;
3029
-                            }
3030
-
3031
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
3032
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
3033
-                            $html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
3034
-
3035
-                        }
3036
-                        break;
3037
-
3038
-                    case 'html':
3039
-                        if (!empty($post->{$type['htmlvar_name']})) {
3040
-
3041
-                            if (strpos($field_icon, 'http') !== false) {
3042
-                                $field_icon_af = '';
3043
-                            } elseif ($field_icon == '') {
3044
-                                $field_icon_af = '';
3045
-                            } else {
3046
-                                $field_icon_af = $field_icon;
3047
-                                $field_icon = '';
3048
-                            }
3049
-
3050
-                            $geodir_odd_even = '';
3051
-                            if ($fields_location == 'detail') {
3052
-
3053
-                                $geodir_odd_even = 'geodir_more_info_odd';
3054
-                                if ($i % 2 == 0)
3055
-                                    $geodir_odd_even = 'geodir_more_info_even';
3056
-
3057
-                                $i++;
3058
-                            }
3059
-
3060
-                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
3061
-                            $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
3062
-                            $html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
3063
-
3064
-                        }
3065
-                        break;
3066
-                    case 'taxonomy': {
3067
-                        $html_var = $type['htmlvar_name'];
3068
-                        if ($html_var == $post->post_type . 'category' && !empty($post->$html_var)) {
3069
-                            $post_taxonomy = $post->post_type . 'category';
3070
-                            $field_value = $post->$html_var;
3071
-                            $links = array();
3072
-                            $terms = array();
3073
-                            $termsOrdered = array();
3074
-                            if (!is_array($field_value)) {
3075
-                                $field_value = explode(",", trim($field_value, ","));
3076
-                            }
3077
-
3078
-                            $field_value = array_unique($field_value);
3079
-
3080
-                            if (!empty($field_value)) {
3081
-                                foreach ($field_value as $term) {
3082
-                                    $term = trim($term);
3083
-
3084
-                                    if ($term != '') {
3085
-                                        $term = get_term_by('id', $term, $html_var);
3086
-                                        if (is_object($term)) {
3087
-                                            $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>";
3088
-                                            $terms[] = $term;
3089
-                                        }
3090
-                                    }
3091
-                                }
3092
-                                if (!empty($links)) {
3093
-                                    // order alphabetically
3094
-                                    asort($links);
3095
-                                    foreach (array_keys($links) as $key) {
3096
-                                        $termsOrdered[$key] = $terms[$key];
3097
-                                    }
3098
-                                    $terms = $termsOrdered;
3099
-                                }
3100
-                            }
3101
-                            $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
3102
-
3103
-                            if ($html_value != '') {
3104
-                                if (strpos($field_icon, 'http') !== false) {
3105
-                                    $field_icon_af = '';
3106
-                                } else if ($field_icon == '') {
3107
-                                    $field_icon_af = '';
3108
-                                } else {
3109
-                                    $field_icon_af = $field_icon;
3110
-                                    $field_icon = '';
3111
-                                }
3112
-
3113
-                                $geodir_odd_even = '';
3114
-                                if ($fields_location == 'detail') {
3115
-                                    $geodir_odd_even = 'geodir_more_info_odd';
3116
-                                    if ($i % 2 == 0) {
3117
-                                        $geodir_odd_even = 'geodir_more_info_even';
3118
-                                    }
3119
-                                    $i++;
3120
-                                }
3121
-
3122
-                                $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af;
3123
-                                $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
3124
-                                $html .= '</span> ' . $html_value . '</div>';
3125
-                            }
3126
-                        }
3127
-                    }
3128
-                        break;
3129
-
3130
-                }
3131
-
3132
-                if ($html):
3133
-
3134
-                    /**
3135
-                     * Called before a custom fields is output on the frontend.
3136
-                     *
3137
-                     * @since 1.0.0
3138
-                     * @param string $html_var The HTML variable name for the field.
3139
-                     */
3140
-                    do_action("geodir_before_show_{$html_var}");
3141
-                    /**
3142
-                     * Filter custom field output.
3143
-                     *
3144
-                     * @since 1.0.0
3145
-                     *
3146
-                     * @param string $html_var The HTML variable name for the field.
3147
-                     * @param string $html Custom field unfiltered HTML.
3148
-                     * @param array $variables_array Custom field variables array.
3149
-                     */
3150
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
3151
-
3152
-                    /**
3153
-                     * Called after a custom fields is output on the frontend.
3154
-                     *
3155
-                     * @since 1.0.0
3156
-                     * @param string $html_var The HTML variable name for the field.
3157
-                     */
3158
-                    do_action("geodir_after_show_{$html_var}");
3159
-
3160
-                endif;
3161
-
3162
-            }
3163
-
3164
-            //echo '</div>';
3165
-
3166
-        }
3167
-
3168
-
3169
-        return $html = ob_get_clean();
3170
-
3171
-    }
2971
+											$filename = explode($ext_path, $filename);
2972
+											$file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>';
2973
+										}
2974
+									}
2975
+								}
2976
+
2977
+								if (strpos($field_icon, 'http') !== false) {
2978
+									$field_icon_af = '';
2979
+								} elseif ($field_icon == '') {
2980
+									$field_icon_af = '';
2981
+								} else {
2982
+									$field_icon_af = $field_icon;
2983
+									$field_icon = '';
2984
+								}
2985
+
2986
+								$geodir_odd_even = '';
2987
+								if ($fields_location == 'detail') {
2988
+
2989
+									$geodir_odd_even = 'geodir_more_info_odd';
2990
+									if ($i % 2 == 0)
2991
+										$geodir_odd_even = 'geodir_more_info_even';
2992
+
2993
+									$i++;
2994
+								}
2995
+
2996
+								$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' geodir-custom-file-box ' . $type['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
2997
+								$html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">';
2998
+								$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
2999
+								$html .= '</span>';
3000
+								$html .= $file_paths . '</div></div>';
3001
+
3002
+							endif;
3003
+						endif;
3004
+
3005
+						break;
3006
+
3007
+					case 'textarea':
3008
+						$html_var = $type['htmlvar_name'];
3009
+
3010
+						if (!empty($post->{$type['htmlvar_name']})) {
3011
+
3012
+							if (strpos($field_icon, 'http') !== false) {
3013
+								$field_icon_af = '';
3014
+							} elseif ($field_icon == '') {
3015
+								$field_icon_af = '';
3016
+							} else {
3017
+								$field_icon_af = $field_icon;
3018
+								$field_icon = '';
3019
+							}
3020
+
3021
+							$geodir_odd_even = '';
3022
+							if ($fields_location == 'detail') {
3023
+
3024
+								$geodir_odd_even = 'geodir_more_info_odd';
3025
+								if ($i % 2 == 0)
3026
+									$geodir_odd_even = 'geodir_more_info_even';
3027
+
3028
+								$i++;
3029
+							}
3030
+
3031
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
3032
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
3033
+							$html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
3034
+
3035
+						}
3036
+						break;
3037
+
3038
+					case 'html':
3039
+						if (!empty($post->{$type['htmlvar_name']})) {
3040
+
3041
+							if (strpos($field_icon, 'http') !== false) {
3042
+								$field_icon_af = '';
3043
+							} elseif ($field_icon == '') {
3044
+								$field_icon_af = '';
3045
+							} else {
3046
+								$field_icon_af = $field_icon;
3047
+								$field_icon = '';
3048
+							}
3049
+
3050
+							$geodir_odd_even = '';
3051
+							if ($fields_location == 'detail') {
3052
+
3053
+								$geodir_odd_even = 'geodir_more_info_odd';
3054
+								if ($i % 2 == 0)
3055
+									$geodir_odd_even = 'geodir_more_info_even';
3056
+
3057
+								$i++;
3058
+							}
3059
+
3060
+							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
3061
+							$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
3062
+							$html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
3063
+
3064
+						}
3065
+						break;
3066
+					case 'taxonomy': {
3067
+						$html_var = $type['htmlvar_name'];
3068
+						if ($html_var == $post->post_type . 'category' && !empty($post->$html_var)) {
3069
+							$post_taxonomy = $post->post_type . 'category';
3070
+							$field_value = $post->$html_var;
3071
+							$links = array();
3072
+							$terms = array();
3073
+							$termsOrdered = array();
3074
+							if (!is_array($field_value)) {
3075
+								$field_value = explode(",", trim($field_value, ","));
3076
+							}
3077
+
3078
+							$field_value = array_unique($field_value);
3079
+
3080
+							if (!empty($field_value)) {
3081
+								foreach ($field_value as $term) {
3082
+									$term = trim($term);
3083
+
3084
+									if ($term != '') {
3085
+										$term = get_term_by('id', $term, $html_var);
3086
+										if (is_object($term)) {
3087
+											$links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>";
3088
+											$terms[] = $term;
3089
+										}
3090
+									}
3091
+								}
3092
+								if (!empty($links)) {
3093
+									// order alphabetically
3094
+									asort($links);
3095
+									foreach (array_keys($links) as $key) {
3096
+										$termsOrdered[$key] = $terms[$key];
3097
+									}
3098
+									$terms = $termsOrdered;
3099
+								}
3100
+							}
3101
+							$html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
3102
+
3103
+							if ($html_value != '') {
3104
+								if (strpos($field_icon, 'http') !== false) {
3105
+									$field_icon_af = '';
3106
+								} else if ($field_icon == '') {
3107
+									$field_icon_af = '';
3108
+								} else {
3109
+									$field_icon_af = $field_icon;
3110
+									$field_icon = '';
3111
+								}
3112
+
3113
+								$geodir_odd_even = '';
3114
+								if ($fields_location == 'detail') {
3115
+									$geodir_odd_even = 'geodir_more_info_odd';
3116
+									if ($i % 2 == 0) {
3117
+										$geodir_odd_even = 'geodir_more_info_even';
3118
+									}
3119
+									$i++;
3120
+								}
3121
+
3122
+								$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af;
3123
+								$html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : '';
3124
+								$html .= '</span> ' . $html_value . '</div>';
3125
+							}
3126
+						}
3127
+					}
3128
+						break;
3129
+
3130
+				}
3131
+
3132
+				if ($html):
3133
+
3134
+					/**
3135
+					 * Called before a custom fields is output on the frontend.
3136
+					 *
3137
+					 * @since 1.0.0
3138
+					 * @param string $html_var The HTML variable name for the field.
3139
+					 */
3140
+					do_action("geodir_before_show_{$html_var}");
3141
+					/**
3142
+					 * Filter custom field output.
3143
+					 *
3144
+					 * @since 1.0.0
3145
+					 *
3146
+					 * @param string $html_var The HTML variable name for the field.
3147
+					 * @param string $html Custom field unfiltered HTML.
3148
+					 * @param array $variables_array Custom field variables array.
3149
+					 */
3150
+					if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
3151
+
3152
+					/**
3153
+					 * Called after a custom fields is output on the frontend.
3154
+					 *
3155
+					 * @since 1.0.0
3156
+					 * @param string $html_var The HTML variable name for the field.
3157
+					 */
3158
+					do_action("geodir_after_show_{$html_var}");
3159
+
3160
+				endif;
3161
+
3162
+			}
3163
+
3164
+			//echo '</div>';
3165
+
3166
+		}
3167
+
3168
+
3169
+		return $html = ob_get_clean();
3170
+
3171
+	}
3172 3172
 }
3173 3173
 
3174 3174
 if (!function_exists('geodir_default_date_format')) {
@@ -3180,12 +3180,12 @@  discard block
 block discarded – undo
3180 3180
 	 * @return mixed|string|void Returns default date format.
3181 3181
 	 */
3182 3182
 	function geodir_default_date_format()
3183
-    {
3184
-        if ($format = get_option('date_format'))
3185
-            return $format;
3186
-        else
3187
-            return 'dd-mm-yy';
3188
-    }
3183
+	{
3184
+		if ($format = get_option('date_format'))
3185
+			return $format;
3186
+		else
3187
+			return 'dd-mm-yy';
3188
+	}
3189 3189
 }
3190 3190
 
3191 3191
 if (!function_exists('geodir_get_formated_date')) {
@@ -3198,9 +3198,9 @@  discard block
 block discarded – undo
3198 3198
 	 * @return bool|int|string Returns formatted date.
3199 3199
 	 */
3200 3200
 	function geodir_get_formated_date($date)
3201
-    {
3202
-        return mysql2date(get_option('date_format'), $date);
3203
-    }
3201
+	{
3202
+		return mysql2date(get_option('date_format'), $date);
3203
+	}
3204 3204
 }
3205 3205
 
3206 3206
 if (!function_exists('geodir_get_formated_time')) {
@@ -3213,9 +3213,9 @@  discard block
 block discarded – undo
3213 3213
 	 * @return bool|int|string Returns formatted time.
3214 3214
 	 */
3215 3215
 	function geodir_get_formated_time($time)
3216
-    {
3217
-        return mysql2date(get_option('time_format'), $time, $translate = true);
3218
-    }
3216
+	{
3217
+		return mysql2date(get_option('time_format'), $time, $translate = true);
3218
+	}
3219 3219
 }
3220 3220
 
3221 3221
 
@@ -3226,56 +3226,56 @@  discard block
 block discarded – undo
3226 3226
 	 * @since 1.0.0
3227 3227
 	 * @since 1.4.7 Added `$extra_fields` parameter.
3228 3228
 	 * @package GeoDirectory
3229
-     * @global object $wpdb WordPress Database object.
3230
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
3231
-     * @global object $current_user Current user object.
3229
+	 * @global object $wpdb WordPress Database object.
3230
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
3231
+	 * @global object $current_user Current user object.
3232 3232
 	 * @param int $post_id
3233 3233
 	 * @param string $field_id
3234 3234
 	 * @param array $post_image
3235 3235
 	 * @param array $extra_fields Array of extra fields.
3236 3236
 	 */
3237 3237
 	function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array())
3238
-    {
3238
+	{
3239 3239
 
3240
-        global $wpdb, $plugin_prefix, $current_user;
3240
+		global $wpdb, $plugin_prefix, $current_user;
3241 3241
 
3242
-        $post_type = get_post_type($post_id);
3243
-        //echo $field_id; exit;
3244
-        $table = $plugin_prefix . $post_type . '_detail';
3242
+		$post_type = get_post_type($post_id);
3243
+		//echo $field_id; exit;
3244
+		$table = $plugin_prefix . $post_type . '_detail';
3245 3245
 
3246
-        $postcurr_images = array();
3247
-        $postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
3248
-        $file_urls = '';
3246
+		$postcurr_images = array();
3247
+		$postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
3248
+		$file_urls = '';
3249 3249
 
3250
-        if (!empty($post_image)) {
3250
+		if (!empty($post_image)) {
3251 3251
 
3252
-            $invalid_files = array();
3252
+			$invalid_files = array();
3253 3253
 
3254
-            //Get and remove all old images of post from database to set by new order
3255
-            $geodir_uploaddir = '';
3256
-            $uploads = wp_upload_dir();
3257
-            $uploads_dir = $uploads['path'];
3254
+			//Get and remove all old images of post from database to set by new order
3255
+			$geodir_uploaddir = '';
3256
+			$uploads = wp_upload_dir();
3257
+			$uploads_dir = $uploads['path'];
3258 3258
 
3259
-            $geodir_uploadpath = $uploads['path'];
3260
-            $geodir_uploadurl = $uploads['url'];
3261
-            $sub_dir = $uploads['subdir'];
3259
+			$geodir_uploadpath = $uploads['path'];
3260
+			$geodir_uploadurl = $uploads['url'];
3261
+			$sub_dir = $uploads['subdir'];
3262 3262
 			
3263 3263
 			$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'] : '';
3264 3264
 
3265
-            for ($m = 0; $m < count($post_image); $m++) {
3265
+			for ($m = 0; $m < count($post_image); $m++) {
3266 3266
 
3267
-                /* --------- start ------- */
3267
+				/* --------- start ------- */
3268 3268
 
3269
-                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)))) {
3269
+				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)))) {
3270 3270
 
3271 3271
 
3272
-                    $curr_img_url = $post_image[$m];
3273
-                    $image_name_arr = explode('/', $curr_img_url);
3274
-                    $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
3275
-                    $filename = end($image_name_arr);
3276
-                    $img_name_arr = explode('.', $filename);
3272
+					$curr_img_url = $post_image[$m];
3273
+					$image_name_arr = explode('/', $curr_img_url);
3274
+					$curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
3275
+					$filename = end($image_name_arr);
3276
+					$img_name_arr = explode('.', $filename);
3277 3277
 
3278
-                    $arr_file_type = wp_check_filetype($filename);
3278
+					$arr_file_type = wp_check_filetype($filename);
3279 3279
 					
3280 3280
 					if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
3281 3281
 						continue;
@@ -3288,8 +3288,8 @@  discard block
 block discarded – undo
3288 3288
 						continue; // Invalid file type.
3289 3289
 					}
3290 3290
 
3291
-                    // Set an array containing a list of acceptable formats
3292
-                    //$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');
3291
+					// Set an array containing a list of acceptable formats
3292
+					//$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');
3293 3293
 
3294 3294
 					if (!function_exists('wp_handle_upload'))
3295 3295
 						require_once(ABSPATH . 'wp-admin/includes/file.php');
@@ -3319,29 +3319,29 @@  discard block
 block discarded – undo
3319 3319
 					if (!empty($uploaded_file))
3320 3320
 						$file_urls = $geodir_uploadurl . '/' . $new_name;
3321 3321
 
3322
-                } else {
3323
-                    $file_urls = $post_image[$m];
3324
-                }
3325
-            }
3322
+				} else {
3323
+					$file_urls = $post_image[$m];
3324
+				}
3325
+			}
3326 3326
 
3327 3327
 
3328
-        }
3328
+		}
3329 3329
 
3330
-        //Remove all old attachments and temp images
3331
-        if (!empty($postcurr_images)) {
3330
+		//Remove all old attachments and temp images
3331
+		if (!empty($postcurr_images)) {
3332 3332
 
3333
-            if ($file_urls != $postcurr_images) {
3334
-                $invalid_files[] = (object)array('src' => $postcurr_images);
3335
-                $invalid_files = (object)$invalid_files;
3336
-            }
3337
-        }
3333
+			if ($file_urls != $postcurr_images) {
3334
+				$invalid_files[] = (object)array('src' => $postcurr_images);
3335
+				$invalid_files = (object)$invalid_files;
3336
+			}
3337
+		}
3338 3338
 
3339
-        geodir_save_post_meta($post_id, $field_id, $file_urls);
3339
+		geodir_save_post_meta($post_id, $field_id, $file_urls);
3340 3340
 
3341
-        if (!empty($invalid_files))
3342
-            geodir_remove_attachments($invalid_files);
3341
+		if (!empty($invalid_files))
3342
+			geodir_remove_attachments($invalid_files);
3343 3343
 
3344
-    }
3344
+	}
3345 3345
 }
3346 3346
 
3347 3347
 
@@ -3356,18 +3356,18 @@  discard block
 block discarded – undo
3356 3356
  */
3357 3357
 function geodir_custom_upload_mimes($existing_mimes = array())
3358 3358
 {
3359
-    $existing_mimes['wif'] = 'text/plain';
3360
-    $existing_mimes['jpg|jpeg'] = 'image/jpeg';
3361
-    $existing_mimes['gif'] = 'image/gif';
3362
-    $existing_mimes['png'] = 'image/png';
3363
-    $existing_mimes['pdf'] = 'application/pdf';
3364
-    $existing_mimes['txt'] = 'text/text';
3365
-    $existing_mimes['csv'] = 'application/octet-stream';
3366
-    $existing_mimes['doc'] = 'application/msword';
3367
-    $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
3368
-    $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
3369
-    $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
3370
-    return $existing_mimes;
3359
+	$existing_mimes['wif'] = 'text/plain';
3360
+	$existing_mimes['jpg|jpeg'] = 'image/jpeg';
3361
+	$existing_mimes['gif'] = 'image/gif';
3362
+	$existing_mimes['png'] = 'image/png';
3363
+	$existing_mimes['pdf'] = 'application/pdf';
3364
+	$existing_mimes['txt'] = 'text/text';
3365
+	$existing_mimes['csv'] = 'application/octet-stream';
3366
+	$existing_mimes['doc'] = 'application/msword';
3367
+	$existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
3368
+	$existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
3369
+	$existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
3370
+	return $existing_mimes;
3371 3371
 }
3372 3372
 
3373 3373
 if (!function_exists('geodir_plupload_action')) {
@@ -3377,55 +3377,55 @@  discard block
 block discarded – undo
3377 3377
 	 *
3378 3378
 	 * @since 1.0.0
3379 3379
 	 * @package GeoDirectory
3380
-     * @global object $current_user Current user object.
3380
+	 * @global object $current_user Current user object.
3381 3381
 	 * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'.
3382 3382
 	 * @return mixed Returns upload directory details as an array.
3383 3383
 	 */
3384 3384
 	function geodir_upload_dir($upload)
3385
-    {
3386
-        global $current_user;
3387
-        $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
3388
-        $upload['path'] = $upload['basedir'] . $upload['subdir'];
3389
-        $upload['url'] = $upload['baseurl'] . $upload['subdir'];
3390
-        return $upload;
3391
-    }
3392
-
3393
-    /**
3394
-     * Handles place file and image upload.
3395
-     *
3396
-     * @since 1.0.0
3397
-     * @package GeoDirectory
3398
-     */
3399
-    function geodir_plupload_action()
3400
-    {
3401
-        // check ajax noonce
3402
-        $imgid = $_POST["imgid"];
3403
-
3404
-        check_ajax_referer($imgid . 'pluploadan');
3405
-
3406
-        // handle custom file uploaddir
3407
-        add_filter('upload_dir', 'geodir_upload_dir');
3408
-
3409
-        // change file orinetation if needed
3410
-        $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
3411
-
3412
-        // handle file upload
3413
-        $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
3414
-        // remove handle custom file uploaddir
3415
-        remove_filter('upload_dir', 'geodir_upload_dir');
3416
-
3417
-        if(!isset($status['url']) && isset($status['error'])){
3418
-            print_r($status);
3419
-        }
3420
-
3421
-        // send the uploaded file url in response
3422
-        if (isset($status['url'])) {
3423
-            echo $status['url'];
3424
-        } else {
3425
-            echo 'x';
3426
-        }
3427
-        exit;
3428
-    }
3385
+	{
3386
+		global $current_user;
3387
+		$upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
3388
+		$upload['path'] = $upload['basedir'] . $upload['subdir'];
3389
+		$upload['url'] = $upload['baseurl'] . $upload['subdir'];
3390
+		return $upload;
3391
+	}
3392
+
3393
+	/**
3394
+	 * Handles place file and image upload.
3395
+	 *
3396
+	 * @since 1.0.0
3397
+	 * @package GeoDirectory
3398
+	 */
3399
+	function geodir_plupload_action()
3400
+	{
3401
+		// check ajax noonce
3402
+		$imgid = $_POST["imgid"];
3403
+
3404
+		check_ajax_referer($imgid . 'pluploadan');
3405
+
3406
+		// handle custom file uploaddir
3407
+		add_filter('upload_dir', 'geodir_upload_dir');
3408
+
3409
+		// change file orinetation if needed
3410
+		$fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
3411
+
3412
+		// handle file upload
3413
+		$status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
3414
+		// remove handle custom file uploaddir
3415
+		remove_filter('upload_dir', 'geodir_upload_dir');
3416
+
3417
+		if(!isset($status['url']) && isset($status['error'])){
3418
+			print_r($status);
3419
+		}
3420
+
3421
+		// send the uploaded file url in response
3422
+		if (isset($status['url'])) {
3423
+			echo $status['url'];
3424
+		} else {
3425
+			echo 'x';
3426
+		}
3427
+		exit;
3428
+	}
3429 3429
 }
3430 3430
 
3431 3431
 /**
@@ -3440,17 +3440,17 @@  discard block
 block discarded – undo
3440 3440
  */
3441 3441
 function geodir_get_video($post_id)
3442 3442
 {
3443
-    global $wpdb, $plugin_prefix;
3443
+	global $wpdb, $plugin_prefix;
3444 3444
 
3445
-    $post_type = get_post_type($post_id);
3445
+	$post_type = get_post_type($post_id);
3446 3446
 
3447
-    $table = $plugin_prefix . $post_type . '_detail';
3447
+	$table = $plugin_prefix . $post_type . '_detail';
3448 3448
 
3449
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
3449
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
3450 3450
 
3451
-    if ($results) {
3452
-        return $results[0]->geodir_video;
3453
-    }
3451
+	if ($results) {
3452
+		return $results[0]->geodir_video;
3453
+	}
3454 3454
 
3455 3455
 }
3456 3456
 
@@ -3466,17 +3466,17 @@  discard block
 block discarded – undo
3466 3466
  */
3467 3467
 function geodir_get_special_offers($post_id)
3468 3468
 {
3469
-    global $wpdb, $plugin_prefix;
3469
+	global $wpdb, $plugin_prefix;
3470 3470
 
3471
-    $post_type = get_post_type($post_id);
3471
+	$post_type = get_post_type($post_id);
3472 3472
 
3473
-    $table = $plugin_prefix . $post_type . '_detail';
3473
+	$table = $plugin_prefix . $post_type . '_detail';
3474 3474
 
3475
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
3475
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
3476 3476
 
3477
-    if ($results) {
3478
-        return $results[0]->geodir_special_offers;
3479
-    }
3477
+	if ($results) {
3478
+		return $results[0]->geodir_special_offers;
3479
+	}
3480 3480
 
3481 3481
 }
3482 3482
 
@@ -3489,17 +3489,17 @@  discard block
 block discarded – undo
3489 3489
 	 * @return mixed|void Returns max upload file size.
3490 3490
 	 */
3491 3491
 	function geodir_max_upload_size()
3492
-    {
3493
-        $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
3494
-
3495
-        if ($max_filesize > 0 && $max_filesize < 1) {
3496
-            $max_filesize = (int)($max_filesize * 1024) . 'kb';
3497
-        } else {
3498
-            $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
3499
-        }
3500
-        /** Filter documented in geodirectory-functions/general_functions.php **/
3501
-        return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
3502
-    }
3492
+	{
3493
+		$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
3494
+
3495
+		if ($max_filesize > 0 && $max_filesize < 1) {
3496
+			$max_filesize = (int)($max_filesize * 1024) . 'kb';
3497
+		} else {
3498
+			$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
3499
+		}
3500
+		/** Filter documented in geodirectory-functions/general_functions.php **/
3501
+		return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
3502
+	}
3503 3503
 }
3504 3504
 
3505 3505
 
@@ -3517,33 +3517,33 @@  discard block
 block discarded – undo
3517 3517
  */
3518 3518
 function geodir_add_custom_sort_options($fields, $post_type)
3519 3519
 {
3520
-    global $wpdb;
3520
+	global $wpdb;
3521 3521
 
3522
-    if ($post_type != '') {
3522
+	if ($post_type != '') {
3523 3523
 
3524
-        $all_postypes = geodir_get_posttypes();
3524
+		$all_postypes = geodir_get_posttypes();
3525 3525
 
3526
-        if (in_array($post_type, $all_postypes)) {
3526
+		if (in_array($post_type, $all_postypes)) {
3527 3527
 
3528
-            $custom_fields = $wpdb->get_results(
3529
-                $wpdb->prepare(
3530
-                    "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",
3531
-                    array($post_type)
3532
-                ), 'ARRAY_A'
3533
-            );
3528
+			$custom_fields = $wpdb->get_results(
3529
+				$wpdb->prepare(
3530
+					"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",
3531
+					array($post_type)
3532
+				), 'ARRAY_A'
3533
+			);
3534 3534
 
3535
-            if (!empty($custom_fields)) {
3535
+			if (!empty($custom_fields)) {
3536 3536
 
3537
-                foreach ($custom_fields as $val) {
3538
-                    $fields[] = $val;
3539
-                }
3540
-            }
3537
+				foreach ($custom_fields as $val) {
3538
+					$fields[] = $val;
3539
+				}
3540
+			}
3541 3541
 
3542
-        }
3542
+		}
3543 3543
 
3544
-    }
3544
+	}
3545 3545
 
3546
-    return $fields;
3546
+	return $fields;
3547 3547
 }
3548 3548
 
3549 3549
 
@@ -3559,66 +3559,66 @@  discard block
 block discarded – undo
3559 3559
 function geodir_get_custom_sort_options($post_type = '')
3560 3560
 {
3561 3561
 
3562
-    global $wpdb;
3563
-
3564
-    if ($post_type != '') {
3565
-
3566
-        $all_postypes = geodir_get_posttypes();
3567
-
3568
-        if (!in_array($post_type, $all_postypes))
3569
-            return false;
3570
-
3571
-        $fields = array();
3572
-
3573
-        $fields[] = array(
3574
-            'post_type' => $post_type,
3575
-            'data_type' => '',
3576
-            'field_type' => 'random',
3577
-            'site_title' => 'Random',
3578
-            'htmlvar_name' => 'post_title'
3579
-        );
3580
-
3581
-        $fields[] = array(
3582
-            'post_type' => $post_type,
3583
-            'data_type' => '',
3584
-            'field_type' => 'datetime',
3585
-            'site_title' => __('Add date', 'geodirectory'),
3586
-            'htmlvar_name' => 'post_date'
3587
-        );
3588
-        $fields[] = array(
3589
-            'post_type' => $post_type,
3590
-            'data_type' => '',
3591
-            'field_type' => 'bigint',
3592
-            'site_title' => __('Review', 'geodirectory'),
3593
-            'htmlvar_name' => 'comment_count'
3594
-        );
3595
-        $fields[] = array(
3596
-            'post_type' => $post_type,
3597
-            'data_type' => '',
3598
-            'field_type' => 'float',
3599
-            'site_title' => __('Rating', 'geodirectory'),
3600
-            'htmlvar_name' => 'overall_rating'
3601
-        );
3602
-        $fields[] = array(
3603
-            'post_type' => $post_type,
3604
-            'data_type' => '',
3605
-            'field_type' => 'text',
3606
-            'site_title' => __('Title', 'geodirectory'),
3607
-            'htmlvar_name' => 'post_title'
3608
-        );
3609
-
3610
-        /**
3611
-         * Hook to add custom sort options.
3612
-         *
3613
-         * @since 1.0.0
3614
-         * @param array $fields Unmodified sort options array.
3615
-         * @param string $post_type Post type.
3616
-         */
3617
-        return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
3618
-
3619
-    }
3620
-
3621
-    return false;
3562
+	global $wpdb;
3563
+
3564
+	if ($post_type != '') {
3565
+
3566
+		$all_postypes = geodir_get_posttypes();
3567
+
3568
+		if (!in_array($post_type, $all_postypes))
3569
+			return false;
3570
+
3571
+		$fields = array();
3572
+
3573
+		$fields[] = array(
3574
+			'post_type' => $post_type,
3575
+			'data_type' => '',
3576
+			'field_type' => 'random',
3577
+			'site_title' => 'Random',
3578
+			'htmlvar_name' => 'post_title'
3579
+		);
3580
+
3581
+		$fields[] = array(
3582
+			'post_type' => $post_type,
3583
+			'data_type' => '',
3584
+			'field_type' => 'datetime',
3585
+			'site_title' => __('Add date', 'geodirectory'),
3586
+			'htmlvar_name' => 'post_date'
3587
+		);
3588
+		$fields[] = array(
3589
+			'post_type' => $post_type,
3590
+			'data_type' => '',
3591
+			'field_type' => 'bigint',
3592
+			'site_title' => __('Review', 'geodirectory'),
3593
+			'htmlvar_name' => 'comment_count'
3594
+		);
3595
+		$fields[] = array(
3596
+			'post_type' => $post_type,
3597
+			'data_type' => '',
3598
+			'field_type' => 'float',
3599
+			'site_title' => __('Rating', 'geodirectory'),
3600
+			'htmlvar_name' => 'overall_rating'
3601
+		);
3602
+		$fields[] = array(
3603
+			'post_type' => $post_type,
3604
+			'data_type' => '',
3605
+			'field_type' => 'text',
3606
+			'site_title' => __('Title', 'geodirectory'),
3607
+			'htmlvar_name' => 'post_title'
3608
+		);
3609
+
3610
+		/**
3611
+		 * Hook to add custom sort options.
3612
+		 *
3613
+		 * @since 1.0.0
3614
+		 * @param array $fields Unmodified sort options array.
3615
+		 * @param string $post_type Post type.
3616
+		 */
3617
+		return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
3618
+
3619
+	}
3620
+
3621
+	return false;
3622 3622
 }
3623 3623
 
3624 3624
 
@@ -3634,29 +3634,29 @@  discard block
 block discarded – undo
3634 3634
 function godir_set_sort_field_order($field_ids = array())
3635 3635
 {
3636 3636
 
3637
-    global $wpdb;
3637
+	global $wpdb;
3638 3638
 
3639
-    $count = 0;
3640
-    if (!empty($field_ids)):
3641
-        foreach ($field_ids as $id) {
3639
+	$count = 0;
3640
+	if (!empty($field_ids)):
3641
+		foreach ($field_ids as $id) {
3642 3642
 
3643
-            $cf = trim($id, '_');
3643
+			$cf = trim($id, '_');
3644 3644
 
3645
-            $post_meta_info = $wpdb->query(
3646
-                $wpdb->prepare(
3647
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
3645
+			$post_meta_info = $wpdb->query(
3646
+				$wpdb->prepare(
3647
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
3648 3648
 															sort_order=%d 
3649 3649
 															where id= %d",
3650
-                    array($count, $cf)
3651
-                )
3652
-            );
3653
-            $count++;
3654
-        }
3655
-
3656
-        return $field_ids;
3657
-    else:
3658
-        return false;
3659
-    endif;
3650
+					array($count, $cf)
3651
+				)
3652
+			);
3653
+			$count++;
3654
+		}
3655
+
3656
+		return $field_ids;
3657
+	else:
3658
+		return false;
3659
+	endif;
3660 3660
 }
3661 3661
 
3662 3662
 
@@ -3666,85 +3666,85 @@  discard block
 block discarded – undo
3666 3666
 	 *
3667 3667
 	 * @since 1.0.0
3668 3668
 	 * @package GeoDirectory
3669
-     * @global object $wpdb WordPress Database object.
3670
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
3669
+	 * @global object $wpdb WordPress Database object.
3670
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
3671 3671
 	 * @param array $request_field {
3672
-     *    Attributes of the Request field.
3673
-     *
3674
-     *    @type string $action Ajax action name.
3675
-     *    @type string $manage_field_type Manage field type Default "sorting_options".
3676
-     *    @type string $create_field Do you want to create this field?.
3677
-     *    @type string $field_ins_upd Field created or updated?.
3678
-     *    @type string $_wpnonce Nonce value.
3679
-     *    @type string $listing_type The Post type.
3680
-     *    @type string $field_type Field Type.
3681
-     *    @type string $field_id Field ID.
3682
-     *    @type string $data_type Data Type.
3683
-     *    @type string $htmlvar_name HTML variable name.
3684
-     *    @type string $site_title Section title which you wish to display in frontend.
3685
-     *    @type string $is_default Is this default sorting?.
3686
-     *    @type string $is_active If not active then the field will not be displayed anywhere.
3687
-     *    @type string $sort_order Sort Order.
3688
-     *
3689
-     * }
3672
+	 *    Attributes of the Request field.
3673
+	 *
3674
+	 *    @type string $action Ajax action name.
3675
+	 *    @type string $manage_field_type Manage field type Default "sorting_options".
3676
+	 *    @type string $create_field Do you want to create this field?.
3677
+	 *    @type string $field_ins_upd Field created or updated?.
3678
+	 *    @type string $_wpnonce Nonce value.
3679
+	 *    @type string $listing_type The Post type.
3680
+	 *    @type string $field_type Field Type.
3681
+	 *    @type string $field_id Field ID.
3682
+	 *    @type string $data_type Data Type.
3683
+	 *    @type string $htmlvar_name HTML variable name.
3684
+	 *    @type string $site_title Section title which you wish to display in frontend.
3685
+	 *    @type string $is_default Is this default sorting?.
3686
+	 *    @type string $is_active If not active then the field will not be displayed anywhere.
3687
+	 *    @type string $sort_order Sort Order.
3688
+	 *
3689
+	 * }
3690 3690
 	 * @param bool $default Not yet implemented.
3691 3691
 	 * @return int Returns the last affected db table row id.
3692 3692
 	 */
3693 3693
 	function geodir_custom_sort_field_save($request_field = array(), $default = false)
3694
-    {
3694
+	{
3695 3695
 
3696
-        global $wpdb, $plugin_prefix;
3696
+		global $wpdb, $plugin_prefix;
3697 3697
 
3698
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
3698
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
3699 3699
 
3700
-        $cf = trim($result_str, '_');
3700
+		$cf = trim($result_str, '_');
3701 3701
 
3702
-        /*-------- check dublicate validation --------*/
3702
+		/*-------- check dublicate validation --------*/
3703 3703
 
3704
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
3705
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
3704
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
3705
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
3706 3706
 
3707
-        $post_type = $request_field['listing_type'];
3708
-        $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
3709
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
3710
-        $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
3711
-        $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
3712
-        $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
3713
-        $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
3714
-        $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
3715
-        $asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
3716
-        $desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
3717
-        $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
3718
-        $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
3707
+		$post_type = $request_field['listing_type'];
3708
+		$data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
3709
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
3710
+		$site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
3711
+		$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
3712
+		$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
3713
+		$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
3714
+		$is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
3715
+		$asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
3716
+		$desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
3717
+		$asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
3718
+		$desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
3719 3719
 
3720
-        $default_order = '';
3721
-        if ($is_default != '') {
3722
-            $default_order = $is_default;
3723
-            $is_default = '1';
3724
-        }
3720
+		$default_order = '';
3721
+		if ($is_default != '') {
3722
+			$default_order = $is_default;
3723
+			$is_default = '1';
3724
+		}
3725 3725
 
3726 3726
 
3727
-        $check_html_variable = $wpdb->get_var(
3728
-            $wpdb->prepare(
3729
-                "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
3730
-                array($cehhtmlvar_name, $post_type, $field_type)
3731
-            )
3732
-        );
3727
+		$check_html_variable = $wpdb->get_var(
3728
+			$wpdb->prepare(
3729
+				"select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
3730
+				array($cehhtmlvar_name, $post_type, $field_type)
3731
+			)
3732
+		);
3733 3733
 
3734
-        if ($is_default == 1) {
3734
+		if ($is_default == 1) {
3735 3735
 
3736
-            $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
3736
+			$wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
3737 3737
 
3738
-        }
3738
+		}
3739 3739
 
3740 3740
 
3741
-        if (!$check_html_variable) {
3741
+		if (!$check_html_variable) {
3742 3742
 
3743
-            $wpdb->query(
3743
+			$wpdb->query(
3744 3744
 
3745
-                $wpdb->prepare(
3745
+				$wpdb->prepare(
3746 3746
 
3747
-                    "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
3747
+					"insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
3748 3748
 				post_type = %s,
3749 3749
 				data_type = %s,
3750 3750
 				field_type = %s,
@@ -3759,23 +3759,23 @@  discard block
 block discarded – undo
3759 3759
 				asc_title = %s,
3760 3760
 				desc_title = %s",
3761 3761
 
3762
-                    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)
3763
-                )
3762
+					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)
3763
+				)
3764 3764
 
3765
-            );
3765
+			);
3766 3766
 
3767 3767
 
3768
-            $lastid = $wpdb->insert_id;
3768
+			$lastid = $wpdb->insert_id;
3769 3769
 
3770
-            $lastid = trim($lastid);
3770
+			$lastid = trim($lastid);
3771 3771
 
3772
-        } else {
3772
+		} else {
3773 3773
 
3774
-            $wpdb->query(
3774
+			$wpdb->query(
3775 3775
 
3776
-                $wpdb->prepare(
3776
+				$wpdb->prepare(
3777 3777
 
3778
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
3778
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
3779 3779
 				post_type = %s,
3780 3780
 				data_type = %s,
3781 3781
 				field_type = %s,
@@ -3791,19 +3791,19 @@  discard block
 block discarded – undo
3791 3791
 				desc_title = %s
3792 3792
 				where id = %d",
3793 3793
 
3794
-                    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)
3795
-                )
3794
+					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)
3795
+				)
3796 3796
 
3797
-            );
3797
+			);
3798 3798
 
3799
-            $lastid = trim($cf);
3799
+			$lastid = trim($cf);
3800 3800
 
3801
-        }
3801
+		}
3802 3802
 
3803 3803
 
3804
-        return (int)$lastid;
3804
+		return (int)$lastid;
3805 3805
 
3806
-    }
3806
+	}
3807 3807
 }
3808 3808
 
3809 3809
 
@@ -3812,26 +3812,26 @@  discard block
 block discarded – undo
3812 3812
 	 * Delete a custom sort field using field id.
3813 3813
 	 * @since 1.0.0
3814 3814
 	 * @package GeoDirectory
3815
-     * @global object $wpdb WordPress Database object.
3816
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
3815
+	 * @global object $wpdb WordPress Database object.
3816
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
3817 3817
 	 * @param string $field_id The field ID.
3818 3818
 	 * @return int|string Returns field id when successful deletion, else returns 0.
3819 3819
 	 */
3820 3820
 	function geodir_custom_sort_field_delete($field_id = '')
3821
-    {
3821
+	{
3822 3822
 
3823
-        global $wpdb, $plugin_prefix;
3824
-        if ($field_id != '') {
3825
-            $cf = trim($field_id, '_');
3823
+		global $wpdb, $plugin_prefix;
3824
+		if ($field_id != '') {
3825
+			$cf = trim($field_id, '_');
3826 3826
 
3827
-            $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
3827
+			$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
3828 3828
 
3829
-            return $field_id;
3829
+			return $field_id;
3830 3830
 
3831
-        } else
3832
-            return 0;
3831
+		} else
3832
+			return 0;
3833 3833
 
3834
-    }
3834
+	}
3835 3835
 }
3836 3836
 
3837 3837
 
@@ -3841,65 +3841,65 @@  discard block
 block discarded – undo
3841 3841
 	 *
3842 3842
 	 * @since 1.0.0
3843 3843
 	 * @package GeoDirectory
3844
-     * @global object $wpdb WordPress Database object.
3844
+	 * @global object $wpdb WordPress Database object.
3845 3845
 	 * @param string $field_type The form field type.
3846 3846
 	 * @param object|int $result_str The custom field results object or row id.
3847 3847
 	 * @param string $field_ins_upd When set to "submit" displays form.
3848 3848
 	 * @param bool $default when set to true field will be for admin use only.
3849 3849
 	 */
3850 3850
 	function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false)
3851
-    {
3852
-        global $wpdb;
3853
-        $cf = $result_str;
3854
-        if (!is_object($cf)) {
3855
-            $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
3856
-        } else {
3857
-            $field_info = $cf;
3858
-            $result_str = $cf->id;
3859
-        }
3851
+	{
3852
+		global $wpdb;
3853
+		$cf = $result_str;
3854
+		if (!is_object($cf)) {
3855
+			$field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
3856
+		} else {
3857
+			$field_info = $cf;
3858
+			$result_str = $cf->id;
3859
+		}
3860 3860
         
3861
-        $field_info = stripslashes_deep($field_info); // strip slashes
3861
+		$field_info = stripslashes_deep($field_info); // strip slashes
3862 3862
 
3863
-        if (!isset($field_info->post_type)) {
3864
-            $post_type = sanitize_text_field($_REQUEST['listing_type']);
3865
-        } else {
3866
-            $post_type = $field_info->post_type;
3867
-        }
3863
+		if (!isset($field_info->post_type)) {
3864
+			$post_type = sanitize_text_field($_REQUEST['listing_type']);
3865
+		} else {
3866
+			$post_type = $field_info->post_type;
3867
+		}
3868 3868
 
3869
-        $field_types = explode('-_-', $field_type);
3870
-        $field_type = $field_types[0];
3871
-        $htmlvar_name = isset($field_types[1]) ? $field_types[1] : '';
3869
+		$field_types = explode('-_-', $field_type);
3870
+		$field_type = $field_types[0];
3871
+		$htmlvar_name = isset($field_types[1]) ? $field_types[1] : '';
3872 3872
 
3873
-        $site_title = '';
3874
-        if ($site_title == '')
3875
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
3873
+		$site_title = '';
3874
+		if ($site_title == '')
3875
+			$site_title = isset($field_info->site_title) ? $field_info->site_title : '';
3876 3876
 
3877
-        if ($site_title == '') {
3878
-            $fields = geodir_get_custom_sort_options($post_type);
3877
+		if ($site_title == '') {
3878
+			$fields = geodir_get_custom_sort_options($post_type);
3879 3879
 
3880
-            foreach ($fields as $val) {
3881
-                $val = stripslashes_deep($val); // strip slashes
3880
+			foreach ($fields as $val) {
3881
+				$val = stripslashes_deep($val); // strip slashes
3882 3882
                 
3883
-                if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
3884
-                    $site_title = isset($val['site_title']) ? $val['site_title'] : '';
3885
-                }
3886
-            }
3887
-        }
3883
+				if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
3884
+					$site_title = isset($val['site_title']) ? $val['site_title'] : '';
3885
+				}
3886
+			}
3887
+		}
3888 3888
 
3889
-        if ($htmlvar_name == '')
3890
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
3889
+		if ($htmlvar_name == '')
3890
+			$htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
3891 3891
 
3892
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
3892
+		$nonce = wp_create_nonce('custom_fields_' . $result_str);
3893 3893
         
3894
-        ?>
3894
+		?>
3895 3895
         <li class="text" id="licontainer_<?php echo $result_str;?>">
3896 3896
             <div class="title title<?php echo $result_str;?> gt-fieldset"
3897 3897
                  title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory');?>"
3898 3898
                  ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
3899 3899
                 <?php
3900 3900
 
3901
-                $nonce = wp_create_nonce('custom_fields_' . $result_str);
3902
-                ?>
3901
+				$nonce = wp_create_nonce('custom_fields_' . $result_str);
3902
+				?>
3903 3903
 
3904 3904
                 <div title="<?php _e('Click to remove field', 'geodirectory');?>"
3905 3905
                      onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
@@ -3912,17 +3912,17 @@  discard block
 block discarded – undo
3912 3912
 
3913 3913
             <div id="field_frm<?php echo $result_str;?>" class="field_frm"
3914 3914
                  style="display:<?php if ($field_ins_upd == 'submit') {
3915
-                     echo 'block;';
3916
-                 } else {
3917
-                     echo 'none;';
3918
-                 } ?>">
3915
+					 echo 'block;';
3916
+				 } else {
3917
+					 echo 'none;';
3918
+				 } ?>">
3919 3919
                 <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
3920 3920
                 <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/>
3921 3921
                 <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/>
3922 3922
                 <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/>
3923 3923
                 <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
3924
-                    echo $field_info->data_type;
3925
-                }?>"/>
3924
+					echo $field_info->data_type;
3925
+				}?>"/>
3926 3926
                 <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/>
3927 3927
 
3928 3928
 
@@ -3937,19 +3937,19 @@  discard block
 block discarded – undo
3937 3937
                             <td>
3938 3938
                                 <input type="checkbox" name="asc" id="asc"
3939 3939
                                        value="1" <?php if (isset($field_info->sort_asc) && $field_info->sort_asc == '1') {
3940
-                                    echo 'checked="checked"';
3941
-                                } ?>/>
3940
+									echo 'checked="checked"';
3941
+								} ?>/>
3942 3942
 
3943 3943
                                 <input type="text" name="asc_title" id="asc_title"
3944 3944
                                        placeholder="<?php esc_attr_e('Ascending title', 'geodirectory'); ?>"
3945 3945
                                        value="<?php if (isset($field_info->asc_title)) {
3946
-                                           echo esc_attr($field_info->asc_title);
3947
-                                       } ?>" style="width:45%;"/>
3946
+										   echo esc_attr($field_info->asc_title);
3947
+									   } ?>" style="width:45%;"/>
3948 3948
 
3949 3949
                                 <input type="radio" name="is_default"
3950 3950
                                        value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
3951
-                                    echo 'checked="checked"';
3952
-                                } ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
3951
+									echo 'checked="checked"';
3952
+								} ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
3953 3953
 
3954 3954
                                 <br/>
3955 3955
                                 <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?></span>
@@ -3961,18 +3961,18 @@  discard block
 block discarded – undo
3961 3961
                             <td>
3962 3962
                                 <input type="checkbox" name="desc" id="desc"
3963 3963
                                        value="1" <?php if (isset($field_info->sort_desc) && $field_info->sort_desc == '1') {
3964
-                                    echo 'checked="checked"';
3965
-                                } ?>/>
3964
+									echo 'checked="checked"';
3965
+								} ?>/>
3966 3966
 
3967 3967
                                 <input type="text" name="desc_title" id="desc_title"
3968 3968
                                        placeholder="<?php esc_attr_e('Descending title', 'geodirectory'); ?>"
3969 3969
                                        value="<?php if (isset($field_info->desc_title)) {
3970
-                                           echo esc_attr($field_info->desc_title);
3971
-                                       } ?>" style="width:45%;"/>
3970
+										   echo esc_attr($field_info->desc_title);
3971
+									   } ?>" style="width:45%;"/>
3972 3972
                                 <input type="radio" name="is_default"
3973 3973
                                        value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
3974
-                                    echo 'checked="checked"';
3975
-                                } ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
3974
+									echo 'checked="checked"';
3975
+								} ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
3976 3976
                                 <br/>
3977 3977
                                 <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?></span>
3978 3978
                             </td>
@@ -3995,8 +3995,8 @@  discard block
 block discarded – undo
3995 3995
                             <td align="left">
3996 3996
                                 <input type="checkbox" name="is_default"
3997 3997
                                        value="<?php echo $field_type; ?>"  <?php if (isset($field_info->is_default) && $field_info->is_default == '1') {
3998
-                                    echo 'checked="checked"';
3999
-                                } ?>/>
3998
+									echo 'checked="checked"';
3999
+								} ?>/>
4000 4000
                                 <br/>
4001 4001
                                 <span><?php _e('If field is checked then the field will be use as default sort.', 'geodirectory'); ?></span>
4002 4002
                             </td>
@@ -4010,12 +4010,12 @@  discard block
 block discarded – undo
4010 4010
                             <select name="is_active" id="is_active">
4011 4011
                                 <option
4012 4012
                                     value="1" <?php if (isset($field_info->is_active) && $field_info->is_active == '1') {
4013
-                                    echo 'selected="selected"';
4014
-                                }?>><?php _e('Yes', 'geodirectory');?></option>
4013
+									echo 'selected="selected"';
4014
+								}?>><?php _e('Yes', 'geodirectory');?></option>
4015 4015
                                 <option
4016 4016
                                     value="0" <?php if (isset($field_info->is_active) && $field_info->is_active == '0') {
4017
-                                    echo 'selected="selected"';
4018
-                                }?>><?php _e('No', 'geodirectory');?></option>
4017
+									echo 'selected="selected"';
4018
+								}?>><?php _e('No', 'geodirectory');?></option>
4019 4019
                             </select>
4020 4020
                             <br/>
4021 4021
                             <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory');?></span>
@@ -4026,8 +4026,8 @@  discard block
 block discarded – undo
4026 4026
                         <td><strong><?php _e('Display order :', 'geodirectory');?></strong></td>
4027 4027
                         <td align="left"><input type="text" readonly="readonly" name="sort_order" id="sort_order"
4028 4028
                                                 value="<?php if (isset($field_info->sort_order)) {
4029
-                                                    echo esc_attr($field_info->sort_order);
4030
-                                                }?>" size="50"/>
4029
+													echo esc_attr($field_info->sort_order);
4030
+												}?>" size="50"/>
4031 4031
                             <br/>
4032 4032
                             <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory');?></span>
4033 4033
                         </td>
@@ -4050,7 +4050,7 @@  discard block
 block discarded – undo
4050 4050
             </div>
4051 4051
         </li> <?php
4052 4052
 
4053
-    }
4053
+	}
4054 4054
 }
4055 4055
 
4056 4056
 if (!function_exists('check_field_visibility')) {
@@ -4059,29 +4059,29 @@  discard block
 block discarded – undo
4059 4059
 	 *
4060 4060
 	 * @since 1.0.0
4061 4061
 	 * @package GeoDirectory
4062
-     * @global object $wpdb WordPress Database object.
4063
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
4062
+	 * @global object $wpdb WordPress Database object.
4063
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
4064 4064
 	 * @param int|string $package_id The package ID.
4065 4065
 	 * @param string $field_name The field name.
4066 4066
 	 * @param string $post_type Optional. The wordpress post type.
4067 4067
 	 * @return bool Returns true when field visible, otherwise false.
4068 4068
 	 */
4069 4069
 	function check_field_visibility($package_id, $field_name, $post_type)
4070
-    {
4071
-        global $wpdb, $geodir_addon_list;
4072
-        if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
4073
-            return true;
4074
-        }
4075
-        if (!$package_id || !$field_name || !$post_type) {
4076
-            return true;
4077
-        }
4078
-        $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));
4079
-
4080
-        if ($wpdb->get_var($sql)) {
4081
-            return true;
4082
-        }
4083
-        return false;
4084
-    }
4070
+	{
4071
+		global $wpdb, $geodir_addon_list;
4072
+		if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
4073
+			return true;
4074
+		}
4075
+		if (!$package_id || !$field_name || !$post_type) {
4076
+			return true;
4077
+		}
4078
+		$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));
4079
+
4080
+		if ($wpdb->get_var($sql)) {
4081
+			return true;
4082
+		}
4083
+		return false;
4084
+	}
4085 4085
 }
4086 4086
 
4087 4087
 /**
@@ -4096,43 +4096,43 @@  discard block
 block discarded – undo
4096 4096
  */
4097 4097
 function geodir_string_to_options($input = '', $translated = false)
4098 4098
 {
4099
-    $return = array();
4100
-    if ($input != '') {
4101
-        $input = trim($input);
4102
-        $input = rtrim($input, ",");
4103
-        $input = ltrim($input, ",");
4104
-        $input = trim($input);
4105
-    }
4106
-
4107
-    $input_arr = explode(',', $input);
4108
-
4109
-    if (!empty($input_arr)) {
4110
-        foreach ($input_arr as $input_str) {
4111
-            $input_str = trim($input_str);
4112
-
4113
-            if (strpos($input_str, "/") !== false) {
4114
-                $input_str = explode("/", $input_str, 2);
4115
-                $label = trim($input_str[0]);
4116
-                if ($translated && $label != '') {
4099
+	$return = array();
4100
+	if ($input != '') {
4101
+		$input = trim($input);
4102
+		$input = rtrim($input, ",");
4103
+		$input = ltrim($input, ",");
4104
+		$input = trim($input);
4105
+	}
4106
+
4107
+	$input_arr = explode(',', $input);
4108
+
4109
+	if (!empty($input_arr)) {
4110
+		foreach ($input_arr as $input_str) {
4111
+			$input_str = trim($input_str);
4112
+
4113
+			if (strpos($input_str, "/") !== false) {
4114
+				$input_str = explode("/", $input_str, 2);
4115
+				$label = trim($input_str[0]);
4116
+				if ($translated && $label != '') {
4117 4117
 					$label = __($label, 'geodirectory');
4118 4118
 				}
4119 4119
 				$label = ucfirst($label);
4120
-                $value = trim($input_str[1]);
4121
-            } else {
4122
-                if ($translated && $input_str != '') {
4120
+				$value = trim($input_str[1]);
4121
+			} else {
4122
+				if ($translated && $input_str != '') {
4123 4123
 					$input_str = __($input_str, 'geodirectory');
4124 4124
 				}
4125 4125
 				$label = ucfirst($input_str);
4126
-                $value = $input_str;
4127
-            }
4126
+				$value = $input_str;
4127
+			}
4128 4128
 
4129
-            if ($label != '') {
4130
-                $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
4131
-            }
4132
-        }
4133
-    }
4129
+			if ($label != '') {
4130
+				$return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
4131
+			}
4132
+		}
4133
+	}
4134 4134
 
4135
-    return $return;
4135
+	return $return;
4136 4136
 }
4137 4137
 
4138 4138
 /**
@@ -4147,51 +4147,51 @@  discard block
 block discarded – undo
4147 4147
  */
4148 4148
 function geodir_string_values_to_options($option_values = '', $translated = false)
4149 4149
 {
4150
-    $options = array();
4151
-    if ($option_values == '') {
4152
-        return NULL;
4153
-    }
4154
-
4155
-    if (strpos($option_values, "{/optgroup}") !== false) {
4156
-        $option_values_arr = explode("{/optgroup}", $option_values);
4157
-
4158
-        foreach ($option_values_arr as $optgroup) {
4159
-            if (strpos($optgroup, "{optgroup}") !== false) {
4160
-                $optgroup_arr = explode("{optgroup}", $optgroup);
4161
-
4162
-                $count = 0;
4163
-                foreach ($optgroup_arr as $optgroup_str) {
4164
-                    $count++;
4165
-                    $optgroup_str = trim($optgroup_str);
4166
-
4167
-                    $optgroup_label = '';
4168
-                    if (strpos($optgroup_str, "|") !== false) {
4169
-                        $optgroup_str_arr = explode("|", $optgroup_str, 2);
4170
-                        $optgroup_label = trim($optgroup_str_arr[0]);
4150
+	$options = array();
4151
+	if ($option_values == '') {
4152
+		return NULL;
4153
+	}
4154
+
4155
+	if (strpos($option_values, "{/optgroup}") !== false) {
4156
+		$option_values_arr = explode("{/optgroup}", $option_values);
4157
+
4158
+		foreach ($option_values_arr as $optgroup) {
4159
+			if (strpos($optgroup, "{optgroup}") !== false) {
4160
+				$optgroup_arr = explode("{optgroup}", $optgroup);
4161
+
4162
+				$count = 0;
4163
+				foreach ($optgroup_arr as $optgroup_str) {
4164
+					$count++;
4165
+					$optgroup_str = trim($optgroup_str);
4166
+
4167
+					$optgroup_label = '';
4168
+					if (strpos($optgroup_str, "|") !== false) {
4169
+						$optgroup_str_arr = explode("|", $optgroup_str, 2);
4170
+						$optgroup_label = trim($optgroup_str_arr[0]);
4171 4171
 						if ($translated && $optgroup_label != '') {
4172 4172
 							$optgroup_label = __($optgroup_label, 'geodirectory');
4173 4173
 						}
4174
-                        $optgroup_label = ucfirst($optgroup_label);
4175
-                        $optgroup_str = $optgroup_str_arr[1];
4176
-                    }
4177
-
4178
-                    $optgroup3 = geodir_string_to_options($optgroup_str, $translated);
4179
-
4180
-                    if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
4181
-                        $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
4182
-                        $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
4183
-                        $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
4184
-                    }
4185
-                    $options = array_merge($options, $optgroup3);
4186
-                }
4187
-            } else {
4188
-                $optgroup1 = geodir_string_to_options($optgroup, $translated);
4189
-                $options = array_merge($options, $optgroup1);
4190
-            }
4191
-        }
4192
-    } else {
4193
-        $options = geodir_string_to_options($option_values, $translated);
4194
-    }
4195
-
4196
-    return $options;
4174
+						$optgroup_label = ucfirst($optgroup_label);
4175
+						$optgroup_str = $optgroup_str_arr[1];
4176
+					}
4177
+
4178
+					$optgroup3 = geodir_string_to_options($optgroup_str, $translated);
4179
+
4180
+					if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
4181
+						$optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
4182
+						$optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
4183
+						$optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
4184
+					}
4185
+					$options = array_merge($options, $optgroup3);
4186
+				}
4187
+			} else {
4188
+				$optgroup1 = geodir_string_to_options($optgroup, $translated);
4189
+				$options = array_merge($options, $optgroup1);
4190
+			}
4191
+		}
4192
+	} else {
4193
+		$options = geodir_string_to_options($option_values, $translated);
4194
+	}
4195
+
4196
+	return $options;
4197 4197
 }
4198 4198
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/custom_functions.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@
 block discarded – undo
153 153
  * @param array $package_info Package info array.
154 154
  * @param object|string $post The post object.
155 155
  * @param string $post_type The post type.
156
- * @return object Returns filtered package info as an object.
156
+ * @return string Returns filtered package info as an object.
157 157
  */
158 158
 function geodir_post_package_info($package_info, $post = '', $post_type = '')
159 159
 {
Please login to merge, or discard this patch.
Braces   +61 added lines, -50 removed lines patch added patch discarded remove patch
@@ -526,13 +526,15 @@  discard block
 block discarded – undo
526 526
 
527 527
         $all_postypes = geodir_get_posttypes();
528 528
 
529
-        if (!in_array($post_type, $all_postypes))
530
-            return false;
529
+        if (!in_array($post_type, $all_postypes)) {
530
+                    return false;
531
+        }
531 532
 
532 533
         $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
533 534
 
534
-        if (!empty($sort_field_info))
535
-            return $sort_field_info;
535
+        if (!empty($sort_field_info)) {
536
+                    return $sort_field_info;
537
+        }
536 538
 
537 539
     }
538 540
 
@@ -554,8 +556,9 @@  discard block
 block discarded – undo
554 556
     if ($post_type != '') {
555 557
         $all_postypes = geodir_get_posttypes();
556 558
 
557
-        if (!in_array($post_type, $all_postypes))
558
-            return false;
559
+        if (!in_array($post_type, $all_postypes)) {
560
+                    return false;
561
+        }
559 562
 
560 563
         $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561 564
         /**
@@ -593,7 +596,9 @@  discard block
 block discarded – undo
593 596
 
594 597
     $sort_by = '';
595 598
 
596
-    if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
599
+    if (isset($_REQUEST['sort_by'])) {
600
+    	$sort_by = $_REQUEST['sort_by'];
601
+    }
597 602
 
598 603
     $gd_post_type = geodir_get_current_posttype();
599 604
 
@@ -621,8 +626,9 @@  discard block
 block discarded – undo
621 626
             if ($sort->sort_asc) {
622 627
                 $key = $sort->htmlvar_name . '_asc';
623 628
                 $label = $sort->site_title;
624
-                if ($sort->asc_title)
625
-                    $label = $sort->asc_title;
629
+                if ($sort->asc_title) {
630
+                                    $label = $sort->asc_title;
631
+                }
626 632
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627 633
                 $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628 634
             }
@@ -630,8 +636,9 @@  discard block
 block discarded – undo
630 636
             if ($sort->sort_desc) {
631 637
                 $key = $sort->htmlvar_name . '_desc';
632 638
                 $label = $sort->site_title;
633
-                if ($sort->desc_title)
634
-                    $label = $sort->desc_title;
639
+                if ($sort->desc_title) {
640
+                                    $label = $sort->desc_title;
641
+                }
635 642
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636 643
                 $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637 644
             }
@@ -648,7 +655,10 @@  discard block
 block discarded – undo
648 655
             <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;">
649 656
 
650 657
                 <option
651
-                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
658
+                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') {
659
+	echo 'selected="selected"';
660
+}
661
+?>><?php _e('Sort By', 'geodirectory');?></option><?php
652 662
 
653 663
                 echo $sort_field_options;?>
654 664
 
@@ -721,8 +731,9 @@  discard block
 block discarded – undo
721 731
         if (isset($_REQUEST['backandedit'])) {
722 732
             $post = (object)$gd_session->get('listing');
723 733
             $post_type = $post->listing_type;
724
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725
-                $post_id = $_REQUEST['pid'];
734
+            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
735
+                            $post_id = $_REQUEST['pid'];
736
+            }
726 737
         } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
727 738
             $post = geodir_get_post_info($_REQUEST['pid']);
728 739
             $post_type = $post->post_type;
@@ -735,25 +746,29 @@  discard block
 block discarded – undo
735 746
         if ($relate_to == 'category') {
736 747
 
737 748
             $category_taxonomy = $post_type . $relate_to;
738
-            if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '')
739
-                $category = explode(',', trim($post->$category_taxonomy, ','));
749
+            if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '') {
750
+                            $category = explode(',', trim($post->$category_taxonomy, ','));
751
+            }
740 752
 
741 753
         } elseif ($relate_to == 'tags') {
742 754
 
743 755
             $category_taxonomy = $post_type . '_' . $relate_to;
744
-            if ($post->post_tags != '')
745
-                $category = explode(',', trim($post->post_tags, ','));
756
+            if ($post->post_tags != '') {
757
+                            $category = explode(',', trim($post->post_tags, ','));
758
+            }
746 759
             $tax_field = 'name';
747 760
         }
748 761
 
749 762
         /* --- return false in invalid request --- */
750
-        if (empty($category))
751
-            return false;
763
+        if (empty($category)) {
764
+                    return false;
765
+        }
752 766
 
753 767
         $all_postypes = geodir_get_posttypes();
754 768
 
755
-        if (!in_array($post_type, $all_postypes))
756
-            return false;
769
+        if (!in_array($post_type, $all_postypes)) {
770
+                    return false;
771
+        }
757 772
 
758 773
         /* --- return false in invalid request --- */
759 774
 
@@ -911,8 +926,9 @@  discard block
 block discarded – undo
911 926
 function geodir_get_map_default_language()
912 927
 {
913 928
     $geodir_default_map_language = get_option('geodir_default_map_language');
914
-    if (empty($geodir_default_map_language))
915
-        $geodir_default_map_language = 'en';
929
+    if (empty($geodir_default_map_language)) {
930
+            $geodir_default_map_language = 'en';
931
+    }
916 932
     /**
917 933
      * Filter default map language.
918 934
      *
@@ -1090,42 +1106,33 @@  discard block
 block discarded – undo
1090 1106
     if(geodir_is_page('home')){
1091 1107
         $gd_page = 'home';
1092 1108
         $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093
-    }
1094
-    elseif(geodir_is_page('detail')){
1109
+    } elseif(geodir_is_page('detail')){
1095 1110
         $gd_page = 'detail';
1096 1111
         $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097
-    }
1098
-    elseif(geodir_is_page('pt')){
1112
+    } elseif(geodir_is_page('pt')){
1099 1113
         $gd_page = 'pt';
1100 1114
         $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101
-    }
1102
-    elseif(geodir_is_page('listing')){
1115
+    } elseif(geodir_is_page('listing')){
1103 1116
         $gd_page = 'listing';
1104 1117
         $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105
-    }
1106
-    elseif(geodir_is_page('location')){
1118
+    } elseif(geodir_is_page('location')){
1107 1119
         $gd_page = 'location';
1108 1120
         $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109 1121
         $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1110 1122
 
1111
-    }
1112
-    elseif(geodir_is_page('search')){
1123
+    } elseif(geodir_is_page('search')){
1113 1124
         $gd_page = 'search';
1114 1125
         $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115
-    }
1116
-    elseif(geodir_is_page('add-listing')){
1126
+    } elseif(geodir_is_page('add-listing')){
1117 1127
         $gd_page = 'add-listing';
1118 1128
         $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119
-    }
1120
-    elseif(geodir_is_page('author')){
1129
+    } elseif(geodir_is_page('author')){
1121 1130
         $gd_page = 'author';
1122 1131
         $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123
-    }
1124
-    elseif(geodir_is_page('login')){
1132
+    } elseif(geodir_is_page('login')){
1125 1133
         $gd_page = 'login';
1126 1134
         $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127
-    }
1128
-    elseif(geodir_is_page('listing-success')){
1135
+    } elseif(geodir_is_page('listing-success')){
1129 1136
         $gd_page = 'listing-success';
1130 1137
         $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131 1138
     }
@@ -1333,8 +1340,9 @@  discard block
 block discarded – undo
1333 1340
     $tabs_array = geodir_detail_page_tabs_array();
1334 1341
     if (!empty($tabs_excluded)) {
1335 1342
         foreach ($tabs_excluded as $tab) {
1336
-            if (array_key_exists($tab, $tabs_array))
1337
-                unset($tabs_array[$tab]);
1343
+            if (array_key_exists($tab, $tabs_array)) {
1344
+                            unset($tabs_array[$tab]);
1345
+            }
1338 1346
         }
1339 1347
     }
1340 1348
     return $tabs_array;
@@ -1375,8 +1383,9 @@  discard block
 block discarded – undo
1375 1383
         $video = geodir_get_video($post->ID);
1376 1384
         $special_offers = geodir_get_special_offers($post->ID);
1377 1385
         $related_listing_array = array();
1378
-        if (get_option('geodir_add_related_listing_posttypes'))
1379
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1386
+        if (get_option('geodir_add_related_listing_posttypes')) {
1387
+                    $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1388
+        }
1380 1389
 
1381 1390
         $related_listing = '';
1382 1391
         if (in_array($post->post_type, $related_listing_array)) {
@@ -1425,11 +1434,13 @@  discard block
 block discarded – undo
1425 1434
         $video = isset($post->geodir_video) ? $post->geodir_video : '';
1426 1435
         $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1427 1436
 
1428
-        if (isset($post->post_images))
1429
-            $post->post_images = trim($post->post_images, ",");
1437
+        if (isset($post->post_images)) {
1438
+                    $post->post_images = trim($post->post_images, ",");
1439
+        }
1430 1440
 
1431
-        if (isset($post->post_images) && !empty($post->post_images))
1432
-            $post_images = explode(",", $post->post_images);
1441
+        if (isset($post->post_images) && !empty($post->post_images)) {
1442
+                    $post_images = explode(",", $post->post_images);
1443
+        }
1433 1444
 
1434 1445
         $thumb_image = '';
1435 1446
         if (!empty($post_images)) {
Please login to merge, or discard this patch.
Indentation   +1362 added lines, -1362 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Custom functions
4
- *
5
- * @since 1.0.0
6
- * @package GeoDirectory
7
- */
3
+	 * Custom functions
4
+	 *
5
+	 * @since 1.0.0
6
+	 * @package GeoDirectory
7
+	 */
8 8
 
9 9
 /**
10 10
  * Front end listing view template selection.
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * @global object $gd_session GeoDirectory Session object.
18 18
  */
19 19
 function geodir_list_view_select() {
20
-    global $gd_session;
20
+	global $gd_session;
21 21
 	?>
22 22
     <script type="text/javascript">
23 23
 	function geodir_list_view_select(list) {
@@ -86,63 +86,63 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function geodir_max_excerpt($charlength)
88 88
 {
89
-    global $post;
90
-    if ($charlength == '0') {
91
-        return;
92
-    }
93
-    $out = '';
89
+	global $post;
90
+	if ($charlength == '0') {
91
+		return;
92
+	}
93
+	$out = '';
94 94
 	
95 95
 	$temp_post = $post;
96 96
 	$excerpt = get_the_excerpt();
97 97
 
98
-    $charlength++;
99
-    $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
100
-    if (mb_strlen($excerpt) > $charlength) {
101
-        if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
102
-            $excut = -(mb_strlen($excerpt_more));
103
-            $subex = mb_substr($excerpt, 0, $excut);
104
-            if ($charlength > 0 && mb_strlen($subex) > $charlength) {
105
-                $subex = mb_substr($subex, 0, $charlength);
106
-            }
107
-            $out .= $subex;
108
-        } else {
109
-            $subex = mb_substr($excerpt, 0, $charlength - 5);
110
-            $exwords = explode(' ', $subex);
111
-            $excut = -(mb_strlen($exwords[count($exwords) - 1]));
112
-            if ($excut < 0) {
113
-                $out .= mb_substr($subex, 0, $excut);
114
-            } else {
115
-                $out .= $subex;
116
-            }
117
-        }
118
-        $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
119
-        /**
120
-         * Filter excerpt read more text.
121
-         *
122
-         * @since 1.0.0
123
-         */
124
-        $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
125
-        $out .= '</a>';
126
-
127
-    } else {
128
-        if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129
-            $excut = -(mb_strlen($excerpt_more));
130
-            $out .= mb_substr($excerpt, 0, $excut);
131
-            $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
132
-            /**
133
-             * Filter excerpt read more text.
134
-             *
135
-             * @since 1.0.0
136
-             */
137
-            $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
138
-            $out .= '</a>';
139
-        } else {
140
-            $out .= $excerpt;
141
-        }
142
-    }
98
+	$charlength++;
99
+	$excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
100
+	if (mb_strlen($excerpt) > $charlength) {
101
+		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
102
+			$excut = -(mb_strlen($excerpt_more));
103
+			$subex = mb_substr($excerpt, 0, $excut);
104
+			if ($charlength > 0 && mb_strlen($subex) > $charlength) {
105
+				$subex = mb_substr($subex, 0, $charlength);
106
+			}
107
+			$out .= $subex;
108
+		} else {
109
+			$subex = mb_substr($excerpt, 0, $charlength - 5);
110
+			$exwords = explode(' ', $subex);
111
+			$excut = -(mb_strlen($exwords[count($exwords) - 1]));
112
+			if ($excut < 0) {
113
+				$out .= mb_substr($subex, 0, $excut);
114
+			} else {
115
+				$out .= $subex;
116
+			}
117
+		}
118
+		$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
119
+		/**
120
+		 * Filter excerpt read more text.
121
+		 *
122
+		 * @since 1.0.0
123
+		 */
124
+		$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
125
+		$out .= '</a>';
126
+
127
+	} else {
128
+		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129
+			$excut = -(mb_strlen($excerpt_more));
130
+			$out .= mb_substr($excerpt, 0, $excut);
131
+			$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
132
+			/**
133
+			 * Filter excerpt read more text.
134
+			 *
135
+			 * @since 1.0.0
136
+			 */
137
+			$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
138
+			$out .= '</a>';
139
+		} else {
140
+			$out .= $excerpt;
141
+		}
142
+	}
143 143
 	$post = $temp_post;
144 144
 
145
-    return $out;
145
+	return $out;
146 146
 }
147 147
 
148 148
 /**
@@ -157,34 +157,34 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function geodir_post_package_info($package_info, $post = '', $post_type = '')
159 159
 {
160
-    $package_info['pid'] = 0;
161
-    $package_info['days'] = 0;
162
-    $package_info['amount'] = 0;
163
-    $package_info['is_featured'] = 0;
164
-    $package_info['image_limit'] = '';
165
-    $package_info['google_analytics'] = 1;
166
-    $package_info['sendtofriend'] = 1;
167
-
168
-    /**
169
-     * Filter listing package info.
170
-     *
171
-     * @since 1.0.0
172
-     * @param array $package_info {
173
-     *    Attributes of the package_info.
174
-     *
175
-     *    @type int $pid Package ID. Default 0.
176
-     *    @type int $days Package validity in Days. Default 0.
177
-     *    @type int $amount Package amount. Default 0.
178
-     *    @type int $is_featured Is this featured package? Default 0.
179
-     *    @type string $image_limit Image limit for this package. Default "".
180
-     *    @type int $google_analytics Add analytics to this package. Default 1.
181
-     *    @type int $sendtofriend Send to friend. Default 1.
182
-     *
183
-     * }
184
-     * @param object|string $post The post object.
185
-     * @param string $post_type The post type.
186
-     */
187
-    return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
160
+	$package_info['pid'] = 0;
161
+	$package_info['days'] = 0;
162
+	$package_info['amount'] = 0;
163
+	$package_info['is_featured'] = 0;
164
+	$package_info['image_limit'] = '';
165
+	$package_info['google_analytics'] = 1;
166
+	$package_info['sendtofriend'] = 1;
167
+
168
+	/**
169
+	 * Filter listing package info.
170
+	 *
171
+	 * @since 1.0.0
172
+	 * @param array $package_info {
173
+	 *    Attributes of the package_info.
174
+	 *
175
+	 *    @type int $pid Package ID. Default 0.
176
+	 *    @type int $days Package validity in Days. Default 0.
177
+	 *    @type int $amount Package amount. Default 0.
178
+	 *    @type int $is_featured Is this featured package? Default 0.
179
+	 *    @type string $image_limit Image limit for this package. Default "".
180
+	 *    @type int $google_analytics Add analytics to this package. Default 1.
181
+	 *    @type int $sendtofriend Send to friend. Default 1.
182
+	 *
183
+	 * }
184
+	 * @param object|string $post The post object.
185
+	 * @param string $post_type The post type.
186
+	 */
187
+	return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
188 188
 
189 189
 }
190 190
 
@@ -212,127 +212,127 @@  discard block
 block discarded – undo
212 212
  */
213 213
 function geodir_send_inquiry($request)
214 214
 {
215
-    global $wpdb;
215
+	global $wpdb;
216 216
 
217
-    // strip slashes from text
218
-    $request = !empty($request) ? stripslashes_deep($request) : $request;
217
+	// strip slashes from text
218
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
219 219
 
220
-    $yourname = $request['inq_name'];
221
-    $youremail = $request['inq_email'];
222
-    $inq_phone = $request['inq_phone'];
223
-    $frnd_comments = $request['inq_msg'];
224
-    $pid = $request['pid'];
220
+	$yourname = $request['inq_name'];
221
+	$youremail = $request['inq_email'];
222
+	$inq_phone = $request['inq_phone'];
223
+	$frnd_comments = $request['inq_msg'];
224
+	$pid = $request['pid'];
225 225
 
226
-    $author_id = '';
227
-    $post_title = '';
226
+	$author_id = '';
227
+	$post_title = '';
228 228
 
229
-    if ($request['pid']) {
229
+	if ($request['pid']) {
230 230
 
231
-        $productinfosql = $wpdb->prepare(
232
-            "select ID,post_author,post_title from $wpdb->posts where ID =%d",
233
-            array($request['pid'])
234
-        );
235
-        $productinfo = $wpdb->get_row($productinfosql);
231
+		$productinfosql = $wpdb->prepare(
232
+			"select ID,post_author,post_title from $wpdb->posts where ID =%d",
233
+			array($request['pid'])
234
+		);
235
+		$productinfo = $wpdb->get_row($productinfosql);
236 236
 
237
-        $author_id = $productinfo->post_author;
238
-        $post_title = $productinfo->post_title;
239
-    }
237
+		$author_id = $productinfo->post_author;
238
+		$post_title = $productinfo->post_title;
239
+	}
240 240
 
241
-    $post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>';
241
+	$post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>';
242 242
 
243
-    $user_info = get_userdata($author_id);
244
-    $to_email = geodir_get_post_meta($pid, 'geodir_email', true);
245
-    $to_name = geodir_get_client_name($author_id);
243
+	$user_info = get_userdata($author_id);
244
+	$to_email = geodir_get_post_meta($pid, 'geodir_email', true);
245
+	$to_name = geodir_get_client_name($author_id);
246 246
 
247
-    if ($to_email == '') {
248
-        $to_email = get_option('admin_email');
249
-    }
247
+	if ($to_email == '') {
248
+		$to_email = get_option('admin_email');
249
+	}
250 250
 
251
-    /**
252
-     * Called after the send enquiry var have been set but before the email has been sent.
253
-     *
254
-     * @since 1.0.0
255
-     * @param array $request {
256
-     *    The submitted form fields as an array.
257
-     *
258
-     *    @type string $sendact Enquiry type. Default "send_inqury".
259
-     *    @type string $pid Post ID.
260
-     *    @type string $inq_name Sender name.
261
-     *    @type string $inq_email Sender mail.
262
-     *    @type string $inq_phone Sender phone.
263
-     *    @type string $inq_msg Email message.
264
-     *
265
-     * }
266
-     * @param string $type The form type, default: `Enquiry`.
267
-     */
268
-    do_action('geodir_after_send_enquiry', $request, 'Enquiry');
269
-
270
-    $client_message = $frnd_comments;
271
-    $client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
272
-    /**
273
-     * Filter client message text.
274
-     *
275
-     * @since 1.0.0
276
-     * @param string $client_message Client message text.
277
-     */
278
-    $client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
279
-
280
-    /**
281
-     * Called before the send enquiry email is sent.
282
-     *
283
-     * @since 1.0.0
284
-     * @param array $request {
285
-     *    The submitted form fields as an array.
286
-     *
287
-     *    @type string $sendact Enquiry type. Default "send_inqury".
288
-     *    @type string $pid Post ID.
289
-     *    @type string $inq_name Sender name.
290
-     *    @type string $inq_email Sender mail.
291
-     *    @type string $inq_phone Sender phone.
292
-     *    @type string $inq_msg Email message.
293
-     *
294
-     * }
295
-     */
296
-    do_action('geodir_before_send_enquiry_email', $request);
297
-    if ($to_email) {
298
-        // strip slashes message
299
-        $client_message = stripslashes_deep($client_message);
300
-
301
-        geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
302
-    }
251
+	/**
252
+	 * Called after the send enquiry var have been set but before the email has been sent.
253
+	 *
254
+	 * @since 1.0.0
255
+	 * @param array $request {
256
+	 *    The submitted form fields as an array.
257
+	 *
258
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
259
+	 *    @type string $pid Post ID.
260
+	 *    @type string $inq_name Sender name.
261
+	 *    @type string $inq_email Sender mail.
262
+	 *    @type string $inq_phone Sender phone.
263
+	 *    @type string $inq_msg Email message.
264
+	 *
265
+	 * }
266
+	 * @param string $type The form type, default: `Enquiry`.
267
+	 */
268
+	do_action('geodir_after_send_enquiry', $request, 'Enquiry');
303 269
 
304
-    /**
305
-     * Called after the send enquiry email is sent.
306
-     *
307
-     * @since 1.0.0
308
-     * @param array $request {
309
-     *    The submitted form fields as an array.
310
-     *
311
-     *    @type string $sendact Enquiry type. Default "send_inqury".
312
-     *    @type string $pid Post ID.
313
-     *    @type string $inq_name Sender name.
314
-     *    @type string $inq_email Sender mail.
315
-     *    @type string $inq_phone Sender phone.
316
-     *    @type string $inq_msg Email message.
317
-     *
318
-     * }
319
-     */
320
-    do_action('geodir_after_send_enquiry_email', $request);
321
-    $url = get_permalink($pid);
322
-    if (strstr($url, '?')) {
323
-        $url = $url . "&send_inquiry=success";
324
-    } else {
325
-        $url = $url . "?send_inquiry=success";
326
-    }
327
-    /**
328
-     * Filter redirect url after the send enquiry email is sent.
329
-     *
330
-     * @since 1.0.0
331
-     * @param string $url Redirect url.
332
-     */
333
-    $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
334
-    wp_redirect($url);
335
-    gd_die();
270
+	$client_message = $frnd_comments;
271
+	$client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
272
+	/**
273
+	 * Filter client message text.
274
+	 *
275
+	 * @since 1.0.0
276
+	 * @param string $client_message Client message text.
277
+	 */
278
+	$client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
279
+
280
+	/**
281
+	 * Called before the send enquiry email is sent.
282
+	 *
283
+	 * @since 1.0.0
284
+	 * @param array $request {
285
+	 *    The submitted form fields as an array.
286
+	 *
287
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
288
+	 *    @type string $pid Post ID.
289
+	 *    @type string $inq_name Sender name.
290
+	 *    @type string $inq_email Sender mail.
291
+	 *    @type string $inq_phone Sender phone.
292
+	 *    @type string $inq_msg Email message.
293
+	 *
294
+	 * }
295
+	 */
296
+	do_action('geodir_before_send_enquiry_email', $request);
297
+	if ($to_email) {
298
+		// strip slashes message
299
+		$client_message = stripslashes_deep($client_message);
300
+
301
+		geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
302
+	}
303
+
304
+	/**
305
+	 * Called after the send enquiry email is sent.
306
+	 *
307
+	 * @since 1.0.0
308
+	 * @param array $request {
309
+	 *    The submitted form fields as an array.
310
+	 *
311
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
312
+	 *    @type string $pid Post ID.
313
+	 *    @type string $inq_name Sender name.
314
+	 *    @type string $inq_email Sender mail.
315
+	 *    @type string $inq_phone Sender phone.
316
+	 *    @type string $inq_msg Email message.
317
+	 *
318
+	 * }
319
+	 */
320
+	do_action('geodir_after_send_enquiry_email', $request);
321
+	$url = get_permalink($pid);
322
+	if (strstr($url, '?')) {
323
+		$url = $url . "&send_inquiry=success";
324
+	} else {
325
+		$url = $url . "?send_inquiry=success";
326
+	}
327
+	/**
328
+	 * Filter redirect url after the send enquiry email is sent.
329
+	 *
330
+	 * @since 1.0.0
331
+	 * @param string $url Redirect url.
332
+	 */
333
+	$url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
334
+	wp_redirect($url);
335
+	gd_die();
336 336
 
337 337
 }
338 338
 
@@ -361,85 +361,85 @@  discard block
 block discarded – undo
361 361
  */
362 362
 function geodir_send_friend($request)
363 363
 {
364
-    global $wpdb;
365
-
366
-    // strip slashes from text
367
-    $request = !empty($request) ? stripslashes_deep($request) : $request;
368
-
369
-    $yourname = $request['yourname'];
370
-    $youremail = $request['youremail'];
371
-    $frnd_subject = $request['frnd_subject'];
372
-    $frnd_comments = $request['frnd_comments'];
373
-    $pid = $request['pid'];
374
-    $to_email = $request['to_email'];
375
-    $to_name = $request['to_name'];
376
-    if ($request['pid']) {
377
-        $productinfosql = $wpdb->prepare(
378
-            "select ID,post_title from $wpdb->posts where ID =%d",
379
-            array($request['pid'])
380
-        );
381
-        $productinfo = $wpdb->get_results($productinfosql);
382
-        foreach ($productinfo as $productinfoObj) {
383
-            $post_title = $productinfoObj->post_title;
384
-        }
385
-    }
364
+	global $wpdb;
365
+
366
+	// strip slashes from text
367
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
368
+
369
+	$yourname = $request['yourname'];
370
+	$youremail = $request['youremail'];
371
+	$frnd_subject = $request['frnd_subject'];
372
+	$frnd_comments = $request['frnd_comments'];
373
+	$pid = $request['pid'];
374
+	$to_email = $request['to_email'];
375
+	$to_name = $request['to_name'];
376
+	if ($request['pid']) {
377
+		$productinfosql = $wpdb->prepare(
378
+			"select ID,post_title from $wpdb->posts where ID =%d",
379
+			array($request['pid'])
380
+		);
381
+		$productinfo = $wpdb->get_results($productinfosql);
382
+		foreach ($productinfo as $productinfoObj) {
383
+			$post_title = $productinfoObj->post_title;
384
+		}
385
+	}
386 386
 
387
-    /**
388
-     * Called before the send to friend email is sent.
389
-     *
390
-     * @since 1.0.0
391
-     * @param array $request {
392
-     *    The submitted form fields as an array.
393
-     *
394
-     *    @type string $sendact Enquiry type. Default "email_frnd".
395
-     *    @type string $pid Post ID.
396
-     *    @type string $to_name Friend name.
397
-     *    @type string $to_email Friend email.
398
-     *    @type string $yourname Sender name.
399
-     *    @type string $youremail Sender email.
400
-     *    @type string $frnd_subject Email subject.
401
-     *    @type string $frnd_comments Email Message.
402
-     *
403
-     * }
404
-     */
405
-    do_action('geodir_before_send_to_friend_email', $request);
406
-    geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
407
-
408
-    /**
409
-     * Called after the send to friend email is sent.
410
-     *
411
-     * @since 1.0.0
412
-     * @param array $request {
413
-     *    The submitted form fields as an array.
414
-     *
415
-     *    @type string $sendact Enquiry type. Default "email_frnd".
416
-     *    @type string $pid Post ID.
417
-     *    @type string $to_name Friend name.
418
-     *    @type string $to_email Friend email.
419
-     *    @type string $yourname Sender name.
420
-     *    @type string $youremail Sender email.
421
-     *    @type string $frnd_subject Email subject.
422
-     *    @type string $frnd_comments Email Message.
423
-     *
424
-     * }
425
-     */
426
-    do_action('geodir_after_send_to_friend_email', $request);
427
-
428
-    $url = get_permalink($pid);
429
-    if (strstr($url, '?')) {
430
-        $url = $url . "&sendtofrnd=success";
431
-    } else {
432
-        $url = $url . "?sendtofrnd=success";
433
-    }
434
-    /**
435
-     * Filter redirect url after the send to friend email is sent.
436
-     *
437
-     * @since 1.0.0
438
-     * @param string $url Redirect url.
439
-     */
440
-    $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
441
-    wp_redirect($url);
442
-    gd_die();
387
+	/**
388
+	 * Called before the send to friend email is sent.
389
+	 *
390
+	 * @since 1.0.0
391
+	 * @param array $request {
392
+	 *    The submitted form fields as an array.
393
+	 *
394
+	 *    @type string $sendact Enquiry type. Default "email_frnd".
395
+	 *    @type string $pid Post ID.
396
+	 *    @type string $to_name Friend name.
397
+	 *    @type string $to_email Friend email.
398
+	 *    @type string $yourname Sender name.
399
+	 *    @type string $youremail Sender email.
400
+	 *    @type string $frnd_subject Email subject.
401
+	 *    @type string $frnd_comments Email Message.
402
+	 *
403
+	 * }
404
+	 */
405
+	do_action('geodir_before_send_to_friend_email', $request);
406
+	geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
407
+
408
+	/**
409
+	 * Called after the send to friend email is sent.
410
+	 *
411
+	 * @since 1.0.0
412
+	 * @param array $request {
413
+	 *    The submitted form fields as an array.
414
+	 *
415
+	 *    @type string $sendact Enquiry type. Default "email_frnd".
416
+	 *    @type string $pid Post ID.
417
+	 *    @type string $to_name Friend name.
418
+	 *    @type string $to_email Friend email.
419
+	 *    @type string $yourname Sender name.
420
+	 *    @type string $youremail Sender email.
421
+	 *    @type string $frnd_subject Email subject.
422
+	 *    @type string $frnd_comments Email Message.
423
+	 *
424
+	 * }
425
+	 */
426
+	do_action('geodir_after_send_to_friend_email', $request);
427
+
428
+	$url = get_permalink($pid);
429
+	if (strstr($url, '?')) {
430
+		$url = $url . "&sendtofrnd=success";
431
+	} else {
432
+		$url = $url . "?sendtofrnd=success";
433
+	}
434
+	/**
435
+	 * Filter redirect url after the send to friend email is sent.
436
+	 *
437
+	 * @since 1.0.0
438
+	 * @param string $url Redirect url.
439
+	 */
440
+	$url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
441
+	wp_redirect($url);
442
+	gd_die();
443 443
 }
444 444
 
445 445
 /**
@@ -453,28 +453,28 @@  discard block
 block discarded – undo
453 453
  */
454 454
 function geodir_before_tab_content($hash_key)
455 455
 {
456
-    switch ($hash_key) {
457
-        case 'post_info' :
458
-            echo '<div class="geodir-company_info field-group">';
459
-            break;
460
-        case 'post_images' :
461
-            /**
462
-             * Filter post gallery HTML id.
463
-             *
464
-             * @since 1.0.0
465
-             */
466
-            echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
467
-            break;
468
-        case 'reviews' :
469
-            echo '<div id="reviews-wrap" class="clearfix"> ';
470
-            break;
471
-        case 'post_video':
472
-            echo ' <div id="post_video-wrap" class="clearfix">';
473
-            break;
474
-        case 'special_offers':
475
-            echo '<div id="special_offers-wrap" class="clearfix">';
476
-            break;
477
-    }
456
+	switch ($hash_key) {
457
+		case 'post_info' :
458
+			echo '<div class="geodir-company_info field-group">';
459
+			break;
460
+		case 'post_images' :
461
+			/**
462
+			 * Filter post gallery HTML id.
463
+			 *
464
+			 * @since 1.0.0
465
+			 */
466
+			echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
467
+			break;
468
+		case 'reviews' :
469
+			echo '<div id="reviews-wrap" class="clearfix"> ';
470
+			break;
471
+		case 'post_video':
472
+			echo ' <div id="post_video-wrap" class="clearfix">';
473
+			break;
474
+		case 'special_offers':
475
+			echo '<div id="special_offers-wrap" class="clearfix">';
476
+			break;
477
+	}
478 478
 }
479 479
 
480 480
 /**
@@ -488,23 +488,23 @@  discard block
 block discarded – undo
488 488
  */
489 489
 function geodir_after_tab_content($hash_key)
490 490
 {
491
-    switch ($hash_key) {
492
-        case 'post_info' :
493
-            echo '</div>';
494
-            break;
495
-        case 'post_images' :
496
-            echo '</div>';
497
-            break;
498
-        case 'reviews' :
499
-            echo '</div>';
500
-            break;
501
-        case 'post_video':
502
-            echo '</div>';
503
-            break;
504
-        case 'special_offers':
505
-            echo '</div>';
506
-            break;
507
-    }
491
+	switch ($hash_key) {
492
+		case 'post_info' :
493
+			echo '</div>';
494
+			break;
495
+		case 'post_images' :
496
+			echo '</div>';
497
+			break;
498
+		case 'reviews' :
499
+			echo '</div>';
500
+			break;
501
+		case 'post_video':
502
+			echo '</div>';
503
+			break;
504
+		case 'special_offers':
505
+			echo '</div>';
506
+			break;
507
+	}
508 508
 }
509 509
 
510 510
 
@@ -520,21 +520,21 @@  discard block
 block discarded – undo
520 520
 function geodir_get_posts_default_sort($post_type)
521 521
 {
522 522
 
523
-    global $wpdb;
523
+	global $wpdb;
524 524
 
525
-    if ($post_type != '') {
525
+	if ($post_type != '') {
526 526
 
527
-        $all_postypes = geodir_get_posttypes();
527
+		$all_postypes = geodir_get_posttypes();
528 528
 
529
-        if (!in_array($post_type, $all_postypes))
530
-            return false;
529
+		if (!in_array($post_type, $all_postypes))
530
+			return false;
531 531
 
532
-        $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
532
+		$sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
533 533
 
534
-        if (!empty($sort_field_info))
535
-            return $sort_field_info;
534
+		if (!empty($sort_field_info))
535
+			return $sort_field_info;
536 536
 
537
-    }
537
+	}
538 538
 
539 539
 }
540 540
 
@@ -549,24 +549,24 @@  discard block
 block discarded – undo
549 549
  * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false.
550 550
  */
551 551
 function geodir_get_sort_options($post_type) {
552
-    global $wpdb;
553
-
554
-    if ($post_type != '') {
555
-        $all_postypes = geodir_get_posttypes();
556
-
557
-        if (!in_array($post_type, $all_postypes))
558
-            return false;
559
-
560
-        $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561
-        /**
562
-         * Filter post sort options.
563
-         *
564
-         * @since 1.0.0
565
-         * @param array $sort_field_info Unfiltered sort field array.
566
-         * @param string $post_type Post type.
567
-         */
568
-        return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
569
-    }
552
+	global $wpdb;
553
+
554
+	if ($post_type != '') {
555
+		$all_postypes = geodir_get_posttypes();
556
+
557
+		if (!in_array($post_type, $all_postypes))
558
+			return false;
559
+
560
+		$sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561
+		/**
562
+		 * Filter post sort options.
563
+		 *
564
+		 * @since 1.0.0
565
+		 * @param array $sort_field_info Unfiltered sort field array.
566
+		 * @param string $post_type Post type.
567
+		 */
568
+		return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
569
+	}
570 570
 
571 571
 }
572 572
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
  */
581 581
 function geodir_display_sort_options()
582 582
 {
583
-    global $wp_query;
583
+	global $wp_query;
584 584
 	
585 585
 	/**
586 586
 	 * On search pages there should be no sort options, sorting is done by search criteria.
@@ -591,57 +591,57 @@  discard block
 block discarded – undo
591 591
 		return;
592 592
 	}
593 593
 
594
-    $sort_by = '';
594
+	$sort_by = '';
595 595
 
596
-    if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
596
+	if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
597 597
 
598
-    $gd_post_type = geodir_get_current_posttype();
598
+	$gd_post_type = geodir_get_current_posttype();
599 599
 
600
-    $sort_options = geodir_get_sort_options($gd_post_type);
600
+	$sort_options = geodir_get_sort_options($gd_post_type);
601 601
 
602 602
 
603
-    $sort_field_options = '';
603
+	$sort_field_options = '';
604 604
 
605
-    if (!empty($sort_options)) {
606
-        foreach ($sort_options as $sort) {
605
+	if (!empty($sort_options)) {
606
+		foreach ($sort_options as $sort) {
607 607
 			$sort = stripslashes_deep($sort); // strip slashes
608 608
 
609
-            $label = __($sort->site_title, 'geodirectory');
609
+			$label = __($sort->site_title, 'geodirectory');
610 610
 
611
-            if ($sort->field_type == 'random') {
612
-                $key = $sort->field_type;
613
-                ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
615
-            }
611
+			if ($sort->field_type == 'random') {
612
+				$key = $sort->field_type;
613
+				($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
615
+			}
616 616
 
617
-            if ($sort->htmlvar_name == 'comment_count') {
618
-                $sort->htmlvar_name = 'rating_count';
619
-            }
617
+			if ($sort->htmlvar_name == 'comment_count') {
618
+				$sort->htmlvar_name = 'rating_count';
619
+			}
620 620
 
621
-            if ($sort->sort_asc) {
622
-                $key = $sort->htmlvar_name . '_asc';
623
-                $label = $sort->site_title;
624
-                if ($sort->asc_title)
625
-                    $label = $sort->asc_title;
626
-                ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628
-            }
621
+			if ($sort->sort_asc) {
622
+				$key = $sort->htmlvar_name . '_asc';
623
+				$label = $sort->site_title;
624
+				if ($sort->asc_title)
625
+					$label = $sort->asc_title;
626
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628
+			}
629 629
 
630
-            if ($sort->sort_desc) {
631
-                $key = $sort->htmlvar_name . '_desc';
632
-                $label = $sort->site_title;
633
-                if ($sort->desc_title)
634
-                    $label = $sort->desc_title;
635
-                ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637
-            }
630
+			if ($sort->sort_desc) {
631
+				$key = $sort->htmlvar_name . '_desc';
632
+				$label = $sort->site_title;
633
+				if ($sort->desc_title)
634
+					$label = $sort->desc_title;
635
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637
+			}
638 638
 
639
-        }
640
-    }
639
+		}
640
+	}
641 641
 
642
-    if ($sort_field_options != '') {
642
+	if ($sort_field_options != '') {
643 643
 
644
-        ?>
644
+		?>
645 645
 
646 646
         <div class="geodir-tax-sort">
647 647
 
@@ -650,14 +650,14 @@  discard block
 block discarded – undo
650 650
                 <option
651 651
                     value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
652 652
 
653
-                echo $sort_field_options;?>
653
+				echo $sort_field_options;?>
654 654
 
655 655
             </select>
656 656
 
657 657
         </div>
658 658
     <?php
659 659
 
660
-    }
660
+	}
661 661
 
662 662
 }
663 663
 
@@ -677,10 +677,10 @@  discard block
 block discarded – undo
677 677
 function geodir_advance_customfields_heading($title, $field_type)
678 678
 {
679 679
 
680
-    if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
681
-        $title = '';
682
-    }
683
-    return $title;
680
+	if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
681
+		$title = '';
682
+	}
683
+	return $title;
684 684
 }
685 685
 
686 686
 
@@ -697,69 +697,69 @@  discard block
 block discarded – undo
697 697
  * @return string Returns related posts html.
698 698
  */
699 699
 function geodir_related_posts_display($request) {
700
-    if (!empty($request)) {
701
-        $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : '';
702
-        $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : '';
703
-
704
-        $title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
705
-        $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5';
706
-        $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category';
707
-        $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf';
708
-        $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0';
709
-        $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : '';
710
-        $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest';
711
-        $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : '';
712
-
713
-        global $wpdb, $post, $gd_session;
714
-        $origi_post = $post;
715
-        $post_type = '';
716
-        $post_id = '';
717
-        $category_taxonomy = '';
718
-        $tax_field = 'id';
719
-        $category = array();
720
-
721
-        if (isset($_REQUEST['backandedit'])) {
722
-            $post = (object)$gd_session->get('listing');
723
-            $post_type = $post->listing_type;
724
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725
-                $post_id = $_REQUEST['pid'];
726
-        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
727
-            $post = geodir_get_post_info($_REQUEST['pid']);
728
-            $post_type = $post->post_type;
729
-            $post_id = $_REQUEST['pid'];
730
-        } elseif (isset($post->post_type) && $post->post_type != '') {
731
-            $post_type = $post->post_type;
732
-            $post_id = $post->ID;
733
-        }
700
+	if (!empty($request)) {
701
+		$before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : '';
702
+		$after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : '';
703
+
704
+		$title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
705
+		$post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5';
706
+		$relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category';
707
+		$layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf';
708
+		$add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0';
709
+		$listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : '';
710
+		$list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest';
711
+		$character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : '';
712
+
713
+		global $wpdb, $post, $gd_session;
714
+		$origi_post = $post;
715
+		$post_type = '';
716
+		$post_id = '';
717
+		$category_taxonomy = '';
718
+		$tax_field = 'id';
719
+		$category = array();
720
+
721
+		if (isset($_REQUEST['backandedit'])) {
722
+			$post = (object)$gd_session->get('listing');
723
+			$post_type = $post->listing_type;
724
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725
+				$post_id = $_REQUEST['pid'];
726
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
727
+			$post = geodir_get_post_info($_REQUEST['pid']);
728
+			$post_type = $post->post_type;
729
+			$post_id = $_REQUEST['pid'];
730
+		} elseif (isset($post->post_type) && $post->post_type != '') {
731
+			$post_type = $post->post_type;
732
+			$post_id = $post->ID;
733
+		}
734 734
 
735
-        if ($relate_to == 'category') {
735
+		if ($relate_to == 'category') {
736 736
 
737
-            $category_taxonomy = $post_type . $relate_to;
738
-            if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '')
739
-                $category = explode(',', trim($post->$category_taxonomy, ','));
737
+			$category_taxonomy = $post_type . $relate_to;
738
+			if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '')
739
+				$category = explode(',', trim($post->$category_taxonomy, ','));
740 740
 
741
-        } elseif ($relate_to == 'tags') {
741
+		} elseif ($relate_to == 'tags') {
742 742
 
743
-            $category_taxonomy = $post_type . '_' . $relate_to;
744
-            if ($post->post_tags != '')
745
-                $category = explode(',', trim($post->post_tags, ','));
746
-            $tax_field = 'name';
747
-        }
743
+			$category_taxonomy = $post_type . '_' . $relate_to;
744
+			if ($post->post_tags != '')
745
+				$category = explode(',', trim($post->post_tags, ','));
746
+			$tax_field = 'name';
747
+		}
748 748
 
749
-        /* --- return false in invalid request --- */
750
-        if (empty($category))
751
-            return false;
749
+		/* --- return false in invalid request --- */
750
+		if (empty($category))
751
+			return false;
752 752
 
753
-        $all_postypes = geodir_get_posttypes();
753
+		$all_postypes = geodir_get_posttypes();
754 754
 
755
-        if (!in_array($post_type, $all_postypes))
756
-            return false;
755
+		if (!in_array($post_type, $all_postypes))
756
+			return false;
757 757
 
758
-        /* --- return false in invalid request --- */
758
+		/* --- return false in invalid request --- */
759 759
 
760
-       $location_url = '';
761
-        if ($add_location_filter != '0') {
762
-            $location_url = array();
760
+	   $location_url = '';
761
+		if ($add_location_filter != '0') {
762
+			$location_url = array();
763 763
 			$geodir_show_location_url = get_option('geodir_show_location_url');
764 764
 			
765 765
 			$gd_city = get_query_var('gd_city');
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 			if ($gd_city) {
768 768
 				$gd_country = get_query_var('gd_country');
769 769
 				$gd_region = get_query_var('gd_region');
770
-            } else {
771
-                $location = geodir_get_default_location();
770
+			} else {
771
+				$location = geodir_get_default_location();
772 772
 				
773 773
 				$gd_country = isset($location->country_slug) ? $location->country_slug : '';
774 774
 				$gd_region = isset($location->region_slug) ? $location->region_slug : '';
775 775
 				$gd_city = isset($location->city_slug) ? $location->city_slug : '';
776
-            }
776
+			}
777 777
 			
778 778
 			if ($geodir_show_location_url == 'all') {
779 779
 				$location_url[] = $gd_country;
@@ -786,92 +786,92 @@  discard block
 block discarded – undo
786 786
 			
787 787
 			$location_url[] = $gd_city;
788 788
 
789
-            $location_url = implode('/', $location_url);
790
-        }
789
+			$location_url = implode('/', $location_url);
790
+		}
791 791
 
792 792
 
793
-        if (!empty($category)) {
794
-            global $geodir_add_location_url;
795
-            $geodir_add_location_url = '0';
796
-            if ($add_location_filter != '0') {
797
-                $geodir_add_location_url = '1';
798
-            }
799
-            $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
800
-            $geodir_add_location_url = NULL;
801
-        }
802
-        ob_start();
803
-        ?>
793
+		if (!empty($category)) {
794
+			global $geodir_add_location_url;
795
+			$geodir_add_location_url = '0';
796
+			if ($add_location_filter != '0') {
797
+				$geodir_add_location_url = '1';
798
+			}
799
+			$viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
800
+			$geodir_add_location_url = NULL;
801
+		}
802
+		ob_start();
803
+		?>
804 804
 
805 805
 
806 806
         <div class="geodir_locations geodir_location_listing">
807 807
 
808 808
             <?php
809
-            if (isset($request['is_widget']) && $request['is_widget'] == '1') {
810
-                /** geodir_before_title filter Documented in geodirectory_widgets.php */
811
-                $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
812
-                /** geodir_after_title filter Documented in geodirectory_widgets.php */
813
-                $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
814
-                ?>
809
+			if (isset($request['is_widget']) && $request['is_widget'] == '1') {
810
+				/** geodir_before_title filter Documented in geodirectory_widgets.php */
811
+				$before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
812
+				/** geodir_after_title filter Documented in geodirectory_widgets.php */
813
+				$after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
814
+				?>
815 815
                 <div class="location_list_heading clearfix">
816 816
                     <?php echo $before_title . $title . $after_title; ?>
817 817
                 </div>
818 818
             <?php
819
-            }
820
-            $query_args = array(
821
-                'posts_per_page' => $post_number,
822
-                'is_geodir_loop' => true,
823
-                'gd_location' => ($add_location_filter) ? true : false,
824
-                'post_type' => $post_type,
825
-                'order_by' => $list_sort,
826
-                'post__not_in' => array($post_id),
827
-                'excerpt_length' => $character_count,
828
-            );
819
+			}
820
+			$query_args = array(
821
+				'posts_per_page' => $post_number,
822
+				'is_geodir_loop' => true,
823
+				'gd_location' => ($add_location_filter) ? true : false,
824
+				'post_type' => $post_type,
825
+				'order_by' => $list_sort,
826
+				'post__not_in' => array($post_id),
827
+				'excerpt_length' => $character_count,
828
+			);
829 829
 
830
-            $tax_query = array('taxonomy' => $category_taxonomy,
831
-                'field' => $tax_field,
832
-                'terms' => $category
833
-            );
830
+			$tax_query = array('taxonomy' => $category_taxonomy,
831
+				'field' => $tax_field,
832
+				'terms' => $category
833
+			);
834 834
 
835
-            $query_args['tax_query'] = array($tax_query);
835
+			$query_args['tax_query'] = array($tax_query);
836 836
 
837 837
 
838
-            global $gridview_columns, $post;
838
+			global $gridview_columns, $post;
839 839
 
840 840
 
841
-            query_posts($query_args);
841
+			query_posts($query_args);
842 842
 
843
-            if (strstr($layout, 'gridview')) {
844
-                $listing_view_exp = explode('_', $layout);
845
-                $gridview_columns = $layout;
846
-                $layout = $listing_view_exp[0];
847
-            } else if ($layout == 'list') {
848
-                $gridview_columns = '';
849
-            }
850
-            $related_posts = true;
851
-
852
-            /**
853
-             * Filters related listing listview template.
854
-             *
855
-             * @since 1.0.0
856
-             */
857
-            $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
858
-
859
-            /**
860
-             * Includes related listing listview template.
861
-             *
862
-             * @since 1.0.0
863
-             */
864
-            include($template);
865
-
866
-            wp_reset_query();
867
-            $post = $origi_post;
868
-            ?>
843
+			if (strstr($layout, 'gridview')) {
844
+				$listing_view_exp = explode('_', $layout);
845
+				$gridview_columns = $layout;
846
+				$layout = $listing_view_exp[0];
847
+			} else if ($layout == 'list') {
848
+				$gridview_columns = '';
849
+			}
850
+			$related_posts = true;
851
+
852
+			/**
853
+			 * Filters related listing listview template.
854
+			 *
855
+			 * @since 1.0.0
856
+			 */
857
+			$template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
858
+
859
+			/**
860
+			 * Includes related listing listview template.
861
+			 *
862
+			 * @since 1.0.0
863
+			 */
864
+			include($template);
865
+
866
+			wp_reset_query();
867
+			$post = $origi_post;
868
+			?>
869 869
 
870 870
         </div>
871 871
         <?php
872
-        return $html = ob_get_clean();
872
+		return $html = ob_get_clean();
873 873
 
874
-    }
874
+	}
875 875
 
876 876
 }
877 877
 
@@ -887,17 +887,17 @@  discard block
 block discarded – undo
887 887
  */
888 888
 function geodir_category_count_script()
889 889
 {
890
-    global $geodir_post_category_str;
890
+	global $geodir_post_category_str;
891 891
 
892
-    if (!empty($geodir_post_category_str)) {
893
-        $geodir_post_category_str = serialize($geodir_post_category_str);
894
-    }
892
+	if (!empty($geodir_post_category_str)) {
893
+		$geodir_post_category_str = serialize($geodir_post_category_str);
894
+	}
895 895
 
896
-    $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
897
-    $script = "var post_category_array = " . json_encode($all_var) . ';';
898
-    echo '<script>';
899
-    echo $script;
900
-    echo '</script>';
896
+	$all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
897
+	$script = "var post_category_array = " . json_encode($all_var) . ';';
898
+	echo '<script>';
899
+	echo $script;
900
+	echo '</script>';
901 901
 
902 902
 }
903 903
 
@@ -910,16 +910,16 @@  discard block
 block discarded – undo
910 910
  */
911 911
 function geodir_get_map_default_language()
912 912
 {
913
-    $geodir_default_map_language = get_option('geodir_default_map_language');
914
-    if (empty($geodir_default_map_language))
915
-        $geodir_default_map_language = 'en';
916
-    /**
917
-     * Filter default map language.
918
-     *
919
-     * @since 1.0.0
920
-     * @param string $geodir_default_map_language Default map language.
921
-     */
922
-    return apply_filters('geodir_default_map_language', $geodir_default_map_language);
913
+	$geodir_default_map_language = get_option('geodir_default_map_language');
914
+	if (empty($geodir_default_map_language))
915
+		$geodir_default_map_language = 'en';
916
+	/**
917
+	 * Filter default map language.
918
+	 *
919
+	 * @since 1.0.0
920
+	 * @param string $geodir_default_map_language Default map language.
921
+	 */
922
+	return apply_filters('geodir_default_map_language', $geodir_default_map_language);
923 923
 }
924 924
 
925 925
 
@@ -936,12 +936,12 @@  discard block
 block discarded – undo
936 936
  */
937 937
 function geodir_add_meta_keywords()
938 938
 {
939
-    global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
939
+	global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
940 940
 
941
-    $is_geodir_page = geodir_is_geodir_page();
942
-    if (!$is_geodir_page) {
943
-        return;
944
-    }// if non GD page, bail
941
+	$is_geodir_page = geodir_is_geodir_page();
942
+	if (!$is_geodir_page) {
943
+		return;
944
+	}// if non GD page, bail
945 945
 
946 946
 	$use_gd_meta = true;
947 947
 	if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
@@ -956,182 +956,182 @@  discard block
 block discarded – undo
956 956
 		return;
957 957
 	}// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active.
958 958
 
959
-    $current_term = $wp_query->get_queried_object();
959
+	$current_term = $wp_query->get_queried_object();
960 960
 
961
-    $all_postypes = geodir_get_posttypes();
961
+	$all_postypes = geodir_get_posttypes();
962 962
 
963
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
963
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
964 964
 
965
-    $meta_desc = '';
966
-    $meta_key = '';
967
-    if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
968
-        /**
969
-         * Filter SEO meta location description.
970
-         *
971
-         * @since 1.0.0
972
-         */
973
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
974
-        $meta_desc .= '';
975
-    }
976
-    if (have_posts() && is_single() OR is_page()) {
977
-        while (have_posts()) {
978
-            the_post();
979
-
980
-            if (has_excerpt()) {
981
-                $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
982
-                if (empty($out_excerpt)) {
983
-                    $out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
984
-                }
985
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
986
-            } else {
987
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
988
-                $out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
989
-                if (empty($out_excerpt)) {
990
-                    $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
991
-                }
992
-                $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
993
-            }
965
+	$meta_desc = '';
966
+	$meta_key = '';
967
+	if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
968
+		/**
969
+		 * Filter SEO meta location description.
970
+		 *
971
+		 * @since 1.0.0
972
+		 */
973
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', '');
974
+		$meta_desc .= '';
975
+	}
976
+	if (have_posts() && is_single() OR is_page()) {
977
+		while (have_posts()) {
978
+			the_post();
979
+
980
+			if (has_excerpt()) {
981
+				$out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
982
+				if (empty($out_excerpt)) {
983
+					$out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
984
+				}
985
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
986
+			} else {
987
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
988
+				$out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
989
+				if (empty($out_excerpt)) {
990
+					$out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
991
+				}
992
+				$out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
993
+			}
994 994
 
995
-            $meta_desc .= $out_excerpt;
996
-        }
997
-    } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
998
-        if (is_category()) {
999
-            $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1000
-        } elseif (is_tag()) {
1001
-            $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1002
-        }
1003
-    } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1004
-        $meta_desc .= isset($current_term->description) ? $current_term->description : '';
1005
-    }
995
+			$meta_desc .= $out_excerpt;
996
+		}
997
+	} elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
998
+		if (is_category()) {
999
+			$meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1000
+		} elseif (is_tag()) {
1001
+			$meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1002
+		}
1003
+	} elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1004
+		$meta_desc .= isset($current_term->description) ? $current_term->description : '';
1005
+	}
1006 1006
 
1007 1007
 
1008
-    $geodir_post_type = geodir_get_current_posttype();
1009
-    $geodir_post_type_info = get_post_type_object($geodir_post_type);
1010
-    $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1011
-
1012
-    $category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1013
-    $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1014
-
1015
-    $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1016
-    $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1017
-
1018
-    $geodir_is_search = geodir_is_page('search') ? true : false;
1019
-    $geodir_is_location = geodir_is_page('location') ? true : false;
1020
-    $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1021
-    $godir_location_terms = geodir_get_current_location_terms('query_vars');
1022
-    $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1023
-    $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1024
-    $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1025
-    $replace_location = __('Everywhere', 'geodirectory');
1026
-    $location_id = NULL;
1027
-    if ($geodir_location_manager) {
1028
-        $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1029
-        $location_id = (int)$wpdb->get_var($sql);
1030
-        $location_type = geodir_what_is_current_location();
1031
-        if ($location_type == 'city') {
1032
-            $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1033
-        } elseif ($location_type == 'region') {
1034
-            $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1035
-        } elseif ($location_type == 'country') {
1036
-            $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1037
-            $replace_location = __($replace_location, 'geodirectory');
1038
-        }
1039
-        $country = get_query_var('gd_country');
1040
-        $region = get_query_var('gd_region');
1041
-        $city = get_query_var('gd_city');
1042
-        $current_location = '';
1043
-        if ($country != '') {
1044
-            $current_location = get_actual_location_name('country', $country, true);
1045
-        }
1046
-        if ($region != '') {
1047
-            $current_location = get_actual_location_name('region', $region);
1048
-        }
1049
-        if ($city != '') {
1050
-            $current_location = get_actual_location_name('city', $city);
1051
-        }
1052
-        $replace_location = $current_location != '' ? $current_location : $replace_location;
1053
-    }
1008
+	$geodir_post_type = geodir_get_current_posttype();
1009
+	$geodir_post_type_info = get_post_type_object($geodir_post_type);
1010
+	$geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1011
+
1012
+	$category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1013
+	$tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1014
+
1015
+	$geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1016
+	$geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1017
+
1018
+	$geodir_is_search = geodir_is_page('search') ? true : false;
1019
+	$geodir_is_location = geodir_is_page('location') ? true : false;
1020
+	$geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1021
+	$godir_location_terms = geodir_get_current_location_terms('query_vars');
1022
+	$gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1023
+	$gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1024
+	$gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1025
+	$replace_location = __('Everywhere', 'geodirectory');
1026
+	$location_id = NULL;
1027
+	if ($geodir_location_manager) {
1028
+		$sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1029
+		$location_id = (int)$wpdb->get_var($sql);
1030
+		$location_type = geodir_what_is_current_location();
1031
+		if ($location_type == 'city') {
1032
+			$replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1033
+		} elseif ($location_type == 'region') {
1034
+			$replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1035
+		} elseif ($location_type == 'country') {
1036
+			$replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1037
+			$replace_location = __($replace_location, 'geodirectory');
1038
+		}
1039
+		$country = get_query_var('gd_country');
1040
+		$region = get_query_var('gd_region');
1041
+		$city = get_query_var('gd_city');
1042
+		$current_location = '';
1043
+		if ($country != '') {
1044
+			$current_location = get_actual_location_name('country', $country, true);
1045
+		}
1046
+		if ($region != '') {
1047
+			$current_location = get_actual_location_name('region', $region);
1048
+		}
1049
+		if ($city != '') {
1050
+			$current_location = get_actual_location_name('city', $city);
1051
+		}
1052
+		$replace_location = $current_location != '' ? $current_location : $replace_location;
1053
+	}
1054 1054
 
1055
-    $geodir_meta_keys = '';
1056
-    $geodir_meta_desc = '';
1057
-    if ($is_geodir_page && !empty($geodir_post_type_info)) {
1058
-        if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1059
-            $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1060
-
1061
-            $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1062
-            $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1063
-
1064
-            if ($geodir_is_category) {
1065
-                $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1066
-                if (isset($category->term_id) && !empty($category->term_id)) {
1067
-                    $category_id = $category->term_id;
1068
-                    $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1069
-                    if ($location_id) {
1070
-                        $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1071
-                        $cat_loc_option = get_option($option_name);
1072
-
1073
-                        $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1074
-                        if (!$gd_cat_loc_default) {
1075
-                            $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1076
-                            $option = get_option($option_name);
1077
-                            $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1078
-                        }
1079
-                    }
1080
-                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1081
-                }
1082
-            } else if ($geodir_is_tag) {
1083
-                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1084
-            }
1085
-        }
1086
-    }
1055
+	$geodir_meta_keys = '';
1056
+	$geodir_meta_desc = '';
1057
+	if ($is_geodir_page && !empty($geodir_post_type_info)) {
1058
+		if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1059
+			$geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1060
+
1061
+			$geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1062
+			$geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1063
+
1064
+			if ($geodir_is_category) {
1065
+				$category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1066
+				if (isset($category->term_id) && !empty($category->term_id)) {
1067
+					$category_id = $category->term_id;
1068
+					$category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1069
+					if ($location_id) {
1070
+						$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1071
+						$cat_loc_option = get_option($option_name);
1072
+
1073
+						$gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1074
+						if (!$gd_cat_loc_default) {
1075
+							$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1076
+							$option = get_option($option_name);
1077
+							$category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1078
+						}
1079
+					}
1080
+					$geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1081
+				}
1082
+			} else if ($geodir_is_tag) {
1083
+				$geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1084
+			}
1085
+		}
1086
+	}
1087 1087
 
1088 1088
 
1089
-    $gd_page = '';
1090
-    if(geodir_is_page('home')){
1091
-        $gd_page = 'home';
1092
-        $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093
-    }
1094
-    elseif(geodir_is_page('detail')){
1095
-        $gd_page = 'detail';
1096
-        $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097
-    }
1098
-    elseif(geodir_is_page('pt')){
1099
-        $gd_page = 'pt';
1100
-        $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101
-    }
1102
-    elseif(geodir_is_page('listing')){
1103
-        $gd_page = 'listing';
1104
-        $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105
-    }
1106
-    elseif(geodir_is_page('location')){
1107
-        $gd_page = 'location';
1108
-        $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1089
+	$gd_page = '';
1090
+	if(geodir_is_page('home')){
1091
+		$gd_page = 'home';
1092
+		$meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093
+	}
1094
+	elseif(geodir_is_page('detail')){
1095
+		$gd_page = 'detail';
1096
+		$meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097
+	}
1098
+	elseif(geodir_is_page('pt')){
1099
+		$gd_page = 'pt';
1100
+		$meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101
+	}
1102
+	elseif(geodir_is_page('listing')){
1103
+		$gd_page = 'listing';
1104
+		$meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105
+	}
1106
+	elseif(geodir_is_page('location')){
1107
+		$gd_page = 'location';
1108
+		$meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1110 1110
 
1111
-    }
1112
-    elseif(geodir_is_page('search')){
1113
-        $gd_page = 'search';
1114
-        $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115
-    }
1116
-    elseif(geodir_is_page('add-listing')){
1117
-        $gd_page = 'add-listing';
1118
-        $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119
-    }
1120
-    elseif(geodir_is_page('author')){
1121
-        $gd_page = 'author';
1122
-        $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123
-    }
1124
-    elseif(geodir_is_page('login')){
1125
-        $gd_page = 'login';
1126
-        $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127
-    }
1128
-    elseif(geodir_is_page('listing-success')){
1129
-        $gd_page = 'listing-success';
1130
-        $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131
-    }
1111
+	}
1112
+	elseif(geodir_is_page('search')){
1113
+		$gd_page = 'search';
1114
+		$meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115
+	}
1116
+	elseif(geodir_is_page('add-listing')){
1117
+		$gd_page = 'add-listing';
1118
+		$meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119
+	}
1120
+	elseif(geodir_is_page('author')){
1121
+		$gd_page = 'author';
1122
+		$meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123
+	}
1124
+	elseif(geodir_is_page('login')){
1125
+		$gd_page = 'login';
1126
+		$meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127
+	}
1128
+	elseif(geodir_is_page('listing-success')){
1129
+		$gd_page = 'listing-success';
1130
+		$meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131
+	}
1132 1132
 
1133 1133
 
1134
-    /*
1134
+	/*
1135 1135
     $geodir_meta_desc = $geodir_meta_desc != '' ? $geodir_meta_desc : $meta_desc;
1136 1136
     if ($geodir_meta_desc != '') {
1137 1137
         $geodir_meta_desc = strip_tags($geodir_meta_desc);
@@ -1144,74 +1144,74 @@  discard block
 block discarded – undo
1144 1144
     */
1145 1145
 
1146 1146
 
1147
-    if ($meta_desc) {
1148
-        $meta_desc = stripslashes_deep($meta_desc);
1149
-        /**
1150
-         * Filter page description to replace variables.
1151
-         *
1152
-         * @since 1.5.4
1153
-         * @param string $title The page description including variables.
1154
-         * @param string $gd_page The GeoDirectory page type if any.
1155
-         */
1156
-        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1157
-
1158
-        /**
1159
-         * Filter SEO meta description.
1160
-         *
1161
-         * @since 1.0.0
1162
-         * @param string $meta_desc Meta description content.
1163
-         */
1164
-        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1165
-    }
1147
+	if ($meta_desc) {
1148
+		$meta_desc = stripslashes_deep($meta_desc);
1149
+		/**
1150
+		 * Filter page description to replace variables.
1151
+		 *
1152
+		 * @since 1.5.4
1153
+		 * @param string $title The page description including variables.
1154
+		 * @param string $gd_page The GeoDirectory page type if any.
1155
+		 */
1156
+		$meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1157
+
1158
+		/**
1159
+		 * Filter SEO meta description.
1160
+		 *
1161
+		 * @since 1.0.0
1162
+		 * @param string $meta_desc Meta description content.
1163
+		 */
1164
+		echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1165
+	}
1166 1166
 
1167
-    // meta keywords
1168
-    if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1169
-        $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1170
-        $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1171
-
1172
-        $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1173
-    } else {
1174
-        $posttags = get_the_tags();
1175
-        if ($posttags) {
1176
-            foreach ($posttags as $tag) {
1177
-                $meta_key .= $tag->name . ' ';
1178
-            }
1179
-        } else {
1180
-            $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1181
-            $xt = 1;
1167
+	// meta keywords
1168
+	if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1169
+		$place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1170
+		$place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1171
+
1172
+		$meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1173
+	} else {
1174
+		$posttags = get_the_tags();
1175
+		if ($posttags) {
1176
+			foreach ($posttags as $tag) {
1177
+				$meta_key .= $tag->name . ' ';
1178
+			}
1179
+		} else {
1180
+			$tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1181
+			$xt = 1;
1182 1182
 
1183
-            foreach ($tags as $tag) {
1184
-                if ($xt <= 20) {
1185
-                    $meta_key .= $tag->name . ", ";
1186
-                }
1183
+			foreach ($tags as $tag) {
1184
+				if ($xt <= 20) {
1185
+					$meta_key .= $tag->name . ", ";
1186
+				}
1187 1187
 
1188
-                $xt++;
1189
-            }
1190
-        }
1191
-    }
1188
+				$xt++;
1189
+			}
1190
+		}
1191
+	}
1192 1192
 
1193
-    $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1194
-    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1195
-    if ($geodir_meta_keys != '') {
1196
-        $geodir_meta_keys = strip_tags($geodir_meta_keys);
1197
-        $geodir_meta_keys = esc_html($geodir_meta_keys);
1198
-        $geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1199
-        $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1200
-        $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1193
+	$meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1194
+	$geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1195
+	if ($geodir_meta_keys != '') {
1196
+		$geodir_meta_keys = strip_tags($geodir_meta_keys);
1197
+		$geodir_meta_keys = esc_html($geodir_meta_keys);
1198
+		$geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1199
+		$geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1200
+		$geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1201 1201
 
1202
-        $meta_key = rtrim(trim($geodir_meta_keys), ",");
1203
-    }
1202
+		$meta_key = rtrim(trim($geodir_meta_keys), ",");
1203
+	}
1204 1204
 
1205
-    if ($meta_key) {
1206
-        $meta_key = stripslashes_deep($meta_key);
1207
-        /**
1208
-         * Filter SEO meta keywords.
1209
-         *
1210
-         * @since 1.0.0
1211
-         * @param string $meta_desc Meta keywords.
1212
-         */
1213
-        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1214
-    }
1205
+	if ($meta_key) {
1206
+		$meta_key = stripslashes_deep($meta_key);
1207
+		/**
1208
+		 * Filter SEO meta keywords.
1209
+		 *
1210
+		 * @since 1.0.0
1211
+		 * @param string $meta_desc Meta keywords.
1212
+		 */
1213
+		echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1214
+	}
1215 1215
 
1216 1216
 }
1217 1217
 
@@ -1226,14 +1226,14 @@  discard block
 block discarded – undo
1226 1226
  */
1227 1227
 function geodir_detail_page_tabs_key_value_array()
1228 1228
 {
1229
-    $geodir_detail_page_tabs_key_value_array = array();
1229
+	$geodir_detail_page_tabs_key_value_array = array();
1230 1230
 
1231
-    $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1231
+	$geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1232 1232
 
1233
-    foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1234
-        $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1235
-    }
1236
-    return $geodir_detail_page_tabs_key_value_array;
1233
+	foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1234
+		$geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1235
+	}
1236
+	return $geodir_detail_page_tabs_key_value_array;
1237 1237
 }
1238 1238
 
1239 1239
 /**
@@ -1246,73 +1246,73 @@  discard block
 block discarded – undo
1246 1246
 function geodir_detail_page_tabs_array()
1247 1247
 {
1248 1248
 
1249
-    $arr_tabs = array();
1250
-    /**
1251
-     * Filter detail page tab display.
1252
-     *
1253
-     * @since 1.0.0
1254
-     */
1255
-    $arr_tabs['post_profile'] = array(
1256
-        'heading_text' => __('Profile', 'geodirectory'),
1257
-        'is_active_tab' => true,
1258
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1259
-        'tab_content' => ''
1260
-    );
1261
-    $arr_tabs['post_info'] = array(
1262
-        'heading_text' => __('More Info', 'geodirectory'),
1263
-        'is_active_tab' => false,
1264
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1265
-        'tab_content' => ''
1266
-    );
1267
-
1268
-    $arr_tabs['post_images'] = array(
1269
-        'heading_text' => __('Photo', 'geodirectory'),
1270
-        'is_active_tab' => false,
1271
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1272
-        'tab_content' => ''
1273
-    );
1274
-
1275
-    $arr_tabs['post_video'] = array(
1276
-        'heading_text' => __('Video', 'geodirectory'),
1277
-        'is_active_tab' => false,
1278
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1279
-        'tab_content' => ''
1280
-    );
1281
-
1282
-    $arr_tabs['special_offers'] = array(
1283
-        'heading_text' => __('Special Offers', 'geodirectory'),
1284
-        'is_active_tab' => false,
1285
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1286
-        'tab_content' => ''
1287
-    );
1288
-
1289
-    $arr_tabs['post_map'] = array(
1290
-        'heading_text' => __('Map', 'geodirectory'),
1291
-        'is_active_tab' => false,
1292
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1293
-        'tab_content' => ''
1294
-    );
1295
-
1296
-    $arr_tabs['reviews'] = array(
1297
-        'heading_text' => __('Reviews', 'geodirectory'),
1298
-        'is_active_tab' => false,
1299
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1300
-        'tab_content' => 'review display'
1301
-    );
1302
-
1303
-    $arr_tabs['related_listing'] = array(
1304
-        'heading_text' => __('Related Listing', 'geodirectory'),
1305
-        'is_active_tab' => false,
1306
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1307
-        'tab_content' => ''
1308
-    );
1309
-
1310
-    /**
1311
-     * Filter the tabs array.
1312
-     *
1313
-     * @since 1.0.0
1314
-     */
1315
-    return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1249
+	$arr_tabs = array();
1250
+	/**
1251
+	 * Filter detail page tab display.
1252
+	 *
1253
+	 * @since 1.0.0
1254
+	 */
1255
+	$arr_tabs['post_profile'] = array(
1256
+		'heading_text' => __('Profile', 'geodirectory'),
1257
+		'is_active_tab' => true,
1258
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1259
+		'tab_content' => ''
1260
+	);
1261
+	$arr_tabs['post_info'] = array(
1262
+		'heading_text' => __('More Info', 'geodirectory'),
1263
+		'is_active_tab' => false,
1264
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1265
+		'tab_content' => ''
1266
+	);
1267
+
1268
+	$arr_tabs['post_images'] = array(
1269
+		'heading_text' => __('Photo', 'geodirectory'),
1270
+		'is_active_tab' => false,
1271
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1272
+		'tab_content' => ''
1273
+	);
1274
+
1275
+	$arr_tabs['post_video'] = array(
1276
+		'heading_text' => __('Video', 'geodirectory'),
1277
+		'is_active_tab' => false,
1278
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1279
+		'tab_content' => ''
1280
+	);
1281
+
1282
+	$arr_tabs['special_offers'] = array(
1283
+		'heading_text' => __('Special Offers', 'geodirectory'),
1284
+		'is_active_tab' => false,
1285
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1286
+		'tab_content' => ''
1287
+	);
1288
+
1289
+	$arr_tabs['post_map'] = array(
1290
+		'heading_text' => __('Map', 'geodirectory'),
1291
+		'is_active_tab' => false,
1292
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1293
+		'tab_content' => ''
1294
+	);
1295
+
1296
+	$arr_tabs['reviews'] = array(
1297
+		'heading_text' => __('Reviews', 'geodirectory'),
1298
+		'is_active_tab' => false,
1299
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1300
+		'tab_content' => 'review display'
1301
+	);
1302
+
1303
+	$arr_tabs['related_listing'] = array(
1304
+		'heading_text' => __('Related Listing', 'geodirectory'),
1305
+		'is_active_tab' => false,
1306
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1307
+		'tab_content' => ''
1308
+	);
1309
+
1310
+	/**
1311
+	 * Filter the tabs array.
1312
+	 *
1313
+	 * @since 1.0.0
1314
+	 */
1315
+	return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1316 1316
 
1317 1317
 
1318 1318
 }
@@ -1327,15 +1327,15 @@  discard block
 block discarded – undo
1327 1327
  */
1328 1328
 function geodir_detail_page_tabs_list()
1329 1329
 {
1330
-    $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1331
-    $tabs_array = geodir_detail_page_tabs_array();
1332
-    if (!empty($tabs_excluded)) {
1333
-        foreach ($tabs_excluded as $tab) {
1334
-            if (array_key_exists($tab, $tabs_array))
1335
-                unset($tabs_array[$tab]);
1336
-        }
1337
-    }
1338
-    return $tabs_array;
1330
+	$tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1331
+	$tabs_array = geodir_detail_page_tabs_array();
1332
+	if (!empty($tabs_excluded)) {
1333
+		foreach ($tabs_excluded as $tab) {
1334
+			if (array_key_exists($tab, $tabs_array))
1335
+				unset($tabs_array[$tab]);
1336
+		}
1337
+	}
1338
+	return $tabs_array;
1339 1339
 }
1340 1340
 
1341 1341
 
@@ -1353,145 +1353,145 @@  discard block
 block discarded – undo
1353 1353
  */
1354 1354
 function geodir_show_detail_page_tabs()
1355 1355
 {
1356
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1356
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1357 1357
 
1358
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1360
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1358
+	$post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
+	$request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1360
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1361 1361
 
1362
-    if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1363
-        $post = geodir_get_post_info($request_post_id);
1364
-        setup_postdata($post);
1365
-    }
1362
+	if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1363
+		$post = geodir_get_post_info($request_post_id);
1364
+		setup_postdata($post);
1365
+	}
1366 1366
 
1367
-    $geodir_post_detail_fields = geodir_show_listing_info('detail');
1368
-
1369
-    if (geodir_is_page('detail')) {
1370
-        $video = geodir_get_video($post->ID);
1371
-        $special_offers = geodir_get_special_offers($post->ID);
1372
-        $related_listing_array = array();
1373
-        if (get_option('geodir_add_related_listing_posttypes'))
1374
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1375
-
1376
-        $related_listing = '';
1377
-        if (in_array($post->post_type, $related_listing_array)) {
1378
-            $request = array('post_number' => get_option('geodir_related_post_count'),
1379
-                'relate_to' => get_option('geodir_related_post_relate_to'),
1380
-                'layout' => get_option('geodir_related_post_listing_view'),
1381
-                'add_location_filter' => get_option('geodir_related_post_location_filter'),
1382
-                'list_sort' => get_option('geodir_related_post_sortby'),
1383
-                'character_count' => get_option('geodir_related_post_excerpt'));
1384
-
1385
-            $related_listing = geodir_related_posts_display($request);
1386
-        }
1367
+	$geodir_post_detail_fields = geodir_show_listing_info('detail');
1368
+
1369
+	if (geodir_is_page('detail')) {
1370
+		$video = geodir_get_video($post->ID);
1371
+		$special_offers = geodir_get_special_offers($post->ID);
1372
+		$related_listing_array = array();
1373
+		if (get_option('geodir_add_related_listing_posttypes'))
1374
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
1375
+
1376
+		$related_listing = '';
1377
+		if (in_array($post->post_type, $related_listing_array)) {
1378
+			$request = array('post_number' => get_option('geodir_related_post_count'),
1379
+				'relate_to' => get_option('geodir_related_post_relate_to'),
1380
+				'layout' => get_option('geodir_related_post_listing_view'),
1381
+				'add_location_filter' => get_option('geodir_related_post_location_filter'),
1382
+				'list_sort' => get_option('geodir_related_post_sortby'),
1383
+				'character_count' => get_option('geodir_related_post_excerpt'));
1384
+
1385
+			$related_listing = geodir_related_posts_display($request);
1386
+		}
1387 1387
 
1388
-        $post_images = geodir_get_images($post->ID, 'thumbnail');
1389
-        $thumb_image = '';
1390
-        if (!empty($post_images)) {
1391
-            foreach ($post_images as $image) {
1392
-                $caption = (!empty($image->caption)) ? $image->caption : '';
1393
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1394
-                $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1395
-                $thumb_image .= '</a>';
1396
-            }
1397
-        }
1388
+		$post_images = geodir_get_images($post->ID, 'thumbnail');
1389
+		$thumb_image = '';
1390
+		if (!empty($post_images)) {
1391
+			foreach ($post_images as $image) {
1392
+				$caption = (!empty($image->caption)) ? $image->caption : '';
1393
+				$thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1394
+				$thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1395
+				$thumb_image .= '</a>';
1396
+			}
1397
+		}
1398 1398
 
1399
-        $map_args = array();
1400
-        $map_args['map_canvas_name'] = 'detail_page_map_canvas';
1401
-        $map_args['width'] = '600';
1402
-        $map_args['height'] = '300';
1403
-        if ($post->post_mapzoom) {
1404
-            $map_args['zoom'] = '' . $post->post_mapzoom . '';
1405
-        }
1406
-        $map_args['autozoom'] = false;
1407
-        $map_args['child_collapse'] = '0';
1408
-        $map_args['enable_cat_filters'] = false;
1409
-        $map_args['enable_text_search'] = false;
1410
-        $map_args['enable_post_type_filters'] = false;
1411
-        $map_args['enable_location_filters'] = false;
1412
-        $map_args['enable_jason_on_load'] = true;
1413
-        $map_args['enable_map_direction'] = true;
1414
-        $map_args['map_class_name'] = 'geodir-map-detail-page';
1415
-        $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1416
-    } else if (geodir_is_page('preview')) {
1417
-        $video = isset($post->geodir_video) ? $post->geodir_video : '';
1418
-        $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1419
-
1420
-        if (isset($post->post_images))
1421
-            $post->post_images = trim($post->post_images, ",");
1422
-
1423
-        if (isset($post->post_images) && !empty($post->post_images))
1424
-            $post_images = explode(",", $post->post_images);
1425
-
1426
-        $thumb_image = '';
1427
-        if (!empty($post_images)) {
1428
-            foreach ($post_images as $image) {
1429
-                if ($image != '') {
1430
-                    $thumb_image .= '<a href="' . $image . '">';
1431
-                    $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1432
-                    $thumb_image .= '</a>';
1433
-                }
1434
-            }
1435
-        }
1399
+		$map_args = array();
1400
+		$map_args['map_canvas_name'] = 'detail_page_map_canvas';
1401
+		$map_args['width'] = '600';
1402
+		$map_args['height'] = '300';
1403
+		if ($post->post_mapzoom) {
1404
+			$map_args['zoom'] = '' . $post->post_mapzoom . '';
1405
+		}
1406
+		$map_args['autozoom'] = false;
1407
+		$map_args['child_collapse'] = '0';
1408
+		$map_args['enable_cat_filters'] = false;
1409
+		$map_args['enable_text_search'] = false;
1410
+		$map_args['enable_post_type_filters'] = false;
1411
+		$map_args['enable_location_filters'] = false;
1412
+		$map_args['enable_jason_on_load'] = true;
1413
+		$map_args['enable_map_direction'] = true;
1414
+		$map_args['map_class_name'] = 'geodir-map-detail-page';
1415
+		$map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1416
+	} else if (geodir_is_page('preview')) {
1417
+		$video = isset($post->geodir_video) ? $post->geodir_video : '';
1418
+		$special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1419
+
1420
+		if (isset($post->post_images))
1421
+			$post->post_images = trim($post->post_images, ",");
1422
+
1423
+		if (isset($post->post_images) && !empty($post->post_images))
1424
+			$post_images = explode(",", $post->post_images);
1425
+
1426
+		$thumb_image = '';
1427
+		if (!empty($post_images)) {
1428
+			foreach ($post_images as $image) {
1429
+				if ($image != '') {
1430
+					$thumb_image .= '<a href="' . $image . '">';
1431
+					$thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1432
+					$thumb_image .= '</a>';
1433
+				}
1434
+			}
1435
+		}
1436 1436
 
1437
-        global $map_jason;
1438
-        $map_jason[] = $post->marker_json;
1437
+		global $map_jason;
1438
+		$map_jason[] = $post->marker_json;
1439 1439
 
1440
-        $address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1441
-        $address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1442
-        $mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1443
-        $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1444
-        if (!$mapzoom) {
1445
-            $mapzoom = 12;
1446
-        }
1440
+		$address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1441
+		$address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1442
+		$mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1443
+		$mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1444
+		if (!$mapzoom) {
1445
+			$mapzoom = 12;
1446
+		}
1447 1447
 
1448
-        $map_args = array();
1449
-        $map_args['map_canvas_name'] = 'preview_map_canvas';
1450
-        $map_args['width'] = '950';
1451
-        $map_args['height'] = '300';
1452
-        $map_args['child_collapse'] = '0';
1453
-        $map_args['maptype'] = $mapview;
1454
-        $map_args['autozoom'] = false;
1455
-        $map_args['zoom'] = "$mapzoom";
1456
-        $map_args['latitude'] = $address_latitude;
1457
-        $map_args['longitude'] = $address_longitude;
1458
-        $map_args['enable_cat_filters'] = false;
1459
-        $map_args['enable_text_search'] = false;
1460
-        $map_args['enable_post_type_filters'] = false;
1461
-        $map_args['enable_location_filters'] = false;
1462
-        $map_args['enable_jason_on_load'] = true;
1463
-        $map_args['enable_map_direction'] = true;
1464
-        $map_args['map_class_name'] = 'geodir-map-preview-page';
1465
-    }
1448
+		$map_args = array();
1449
+		$map_args['map_canvas_name'] = 'preview_map_canvas';
1450
+		$map_args['width'] = '950';
1451
+		$map_args['height'] = '300';
1452
+		$map_args['child_collapse'] = '0';
1453
+		$map_args['maptype'] = $mapview;
1454
+		$map_args['autozoom'] = false;
1455
+		$map_args['zoom'] = "$mapzoom";
1456
+		$map_args['latitude'] = $address_latitude;
1457
+		$map_args['longitude'] = $address_longitude;
1458
+		$map_args['enable_cat_filters'] = false;
1459
+		$map_args['enable_text_search'] = false;
1460
+		$map_args['enable_post_type_filters'] = false;
1461
+		$map_args['enable_location_filters'] = false;
1462
+		$map_args['enable_jason_on_load'] = true;
1463
+		$map_args['enable_map_direction'] = true;
1464
+		$map_args['map_class_name'] = 'geodir-map-preview-page';
1465
+	}
1466 1466
 
1467
-    $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1467
+	$arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1468 1468
 
1469
-    $active_tab = '';
1470
-    $active_tab_name = '';
1471
-    $default_tab = '';
1472
-    $default_tab_name = '';
1473
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1474
-        if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1475
-            $active_tab = $tab_index;
1476
-            $active_tab_name = __($tabs['heading_text'], 'geodirectory');
1477
-        }
1469
+	$active_tab = '';
1470
+	$active_tab_name = '';
1471
+	$default_tab = '';
1472
+	$default_tab_name = '';
1473
+	foreach($arr_detail_page_tabs as $tab_index => $tabs){
1474
+		if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1475
+			$active_tab = $tab_index;
1476
+			$active_tab_name = __($tabs['heading_text'], 'geodirectory');
1477
+		}
1478 1478
         
1479
-        if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1480
-            $default_tab = $tab_index;
1481
-            $default_tab_name = __($tabs['heading_text'], 'geodirectory');
1482
-        }
1483
-    }
1479
+		if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1480
+			$default_tab = $tab_index;
1481
+			$default_tab_name = __($tabs['heading_text'], 'geodirectory');
1482
+		}
1483
+	}
1484 1484
     
1485
-    if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1486
-        if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1487
-            $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1488
-        }
1485
+	if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1486
+		if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1487
+			$arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1488
+		}
1489 1489
         
1490
-        $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1491
-        $active_tab = $default_tab;
1492
-        $active_tab_name = $default_tab_name;
1493
-    }
1494
-    ?>
1490
+		$arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1491
+		$active_tab = $default_tab;
1492
+		$active_tab_name = $default_tab_name;
1493
+	}
1494
+	?>
1495 1495
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1496 1496
         <div id="geodir-tab-mobile-menu" >
1497 1497
             <i class="fa fa-bars"></i>
@@ -1500,147 +1500,147 @@  discard block
 block discarded – undo
1500 1500
         </div>
1501 1501
         <dl class="geodir-tab-head">
1502 1502
             <?php
1503
-            /**
1504
-             * Called before the details page tab list headings, inside the `dl` tag.
1505
-             *
1506
-             * @since 1.0.0
1507
-             * @see 'geodir_after_tab_list'
1508
-             */
1509
-            do_action('geodir_before_tab_list'); ?>
1503
+			/**
1504
+			 * Called before the details page tab list headings, inside the `dl` tag.
1505
+			 *
1506
+			 * @since 1.0.0
1507
+			 * @see 'geodir_after_tab_list'
1508
+			 */
1509
+			do_action('geodir_before_tab_list'); ?>
1510 1510
             <?php
1511
-            foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1512
-                if ($detail_page_tab['is_display']) {
1513
-                    ?>
1511
+			foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1512
+				if ($detail_page_tab['is_display']) {
1513
+					?>
1514 1514
                     <dt></dt> <!-- added to comply with validation -->
1515 1515
                     <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php }?> ><a data-tab="#<?php echo $tab_index;?>" data-status="enable"><?php _e($detail_page_tab['heading_text'],'geodirectory');?></a>
1516 1516
                     </dd>
1517 1517
                     <?php
1518
-                    ob_start() // start tab content buffering
1519
-                    ?>
1518
+					ob_start() // start tab content buffering
1519
+					?>
1520 1520
                     <li id="<?php echo $tab_index;?>Tab">
1521 1521
                         <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1522 1522
                         <?php
1523
-                        /**
1524
-                         * Called before the details tab content is output per tab.
1525
-                         *
1526
-                         * @since 1.0.0
1527
-                         * @param string $tab_index The tab name ID.
1528
-                         */
1529
-                        do_action('geodir_before_tab_content', $tab_index);
1530
-
1531
-                        /**
1532
-                         * Called before the details tab content is output per tab.
1533
-                         *
1534
-                         * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1535
-                         *
1536
-                         * @since 1.0.0
1537
-                         * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1538
-                         */
1539
-                        do_action('geodir_before_' . $tab_index . '_tab_content');
1540
-                        /// write a code to generate content of each tab
1541
-                        switch ($tab_index) {
1542
-                            case 'post_profile':
1543
-                                /**
1544
-                                 * Called before the listing description content on the details page tab.
1545
-                                 *
1546
-                                 * @since 1.0.0
1547
-                                 */
1548
-                                do_action('geodir_before_description_on_listing_detail');
1549
-                                if (geodir_is_page('detail')) {
1550
-                                    the_content();
1551
-                                } else {
1552
-                                    /** This action is documented in geodirectory_template_actions.php */
1553
-                                    echo apply_filters('the_content', stripslashes($post->post_desc));
1554
-                                }
1555
-
1556
-                                /**
1557
-                                 * Called after the listing description content on the details page tab.
1558
-                                 *
1559
-                                 * @since 1.0.0
1560
-                                 */
1561
-                                do_action('geodir_after_description_on_listing_detail');
1562
-                                break;
1563
-                            case 'post_info':
1564
-                                echo $geodir_post_detail_fields;
1565
-                                break;
1566
-                            case 'post_images':
1567
-                                echo $thumb_image;
1568
-                                break;
1569
-                            case 'post_video':
1570
-                                /** This action is documented in geodirectory_template_actions.php */
1571
-                                echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1572
-                                break;
1573
-                            case 'special_offers':
1574
-                                echo wpautop(stripslashes($special_offers));
1575
-
1576
-                                break;
1577
-                            case 'post_map':
1578
-                                geodir_draw_map($map_args);
1579
-                                break;
1580
-                            case 'reviews':
1581
-                                comments_template();
1582
-                                break;
1583
-                            case 'related_listing':
1584
-                                echo $related_listing;
1585
-                                break;
1586
-                            default: {
1587
-                                if ((isset($post->$tab_index) || (!isset($post->$tab_index) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
1588
-                                    echo $detail_page_tab['tab_content'];
1589
-                                }
1590
-                            }
1591
-                                break;
1592
-                        }
1593
-
1594
-                        /**
1595
-                         * Called after the details tab content is output per tab.
1596
-                         *
1597
-                         * @since 1.0.0
1598
-                         */
1599
-                        do_action('geodir_after_tab_content', $tab_index);
1600
-
1601
-                        /**
1602
-                         * Called after the details tab content is output per tab.
1603
-                         *
1604
-                         * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1605
-                         *
1606
-                         * @since 1.0.0
1607
-                         * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1608
-                         */
1609
-                        do_action('geodir_after_' . $tab_index . '_tab_content');
1610
-                        ?> </li>
1523
+						/**
1524
+						 * Called before the details tab content is output per tab.
1525
+						 *
1526
+						 * @since 1.0.0
1527
+						 * @param string $tab_index The tab name ID.
1528
+						 */
1529
+						do_action('geodir_before_tab_content', $tab_index);
1530
+
1531
+						/**
1532
+						 * Called before the details tab content is output per tab.
1533
+						 *
1534
+						 * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1535
+						 *
1536
+						 * @since 1.0.0
1537
+						 * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1538
+						 */
1539
+						do_action('geodir_before_' . $tab_index . '_tab_content');
1540
+						/// write a code to generate content of each tab
1541
+						switch ($tab_index) {
1542
+							case 'post_profile':
1543
+								/**
1544
+								 * Called before the listing description content on the details page tab.
1545
+								 *
1546
+								 * @since 1.0.0
1547
+								 */
1548
+								do_action('geodir_before_description_on_listing_detail');
1549
+								if (geodir_is_page('detail')) {
1550
+									the_content();
1551
+								} else {
1552
+									/** This action is documented in geodirectory_template_actions.php */
1553
+									echo apply_filters('the_content', stripslashes($post->post_desc));
1554
+								}
1555
+
1556
+								/**
1557
+								 * Called after the listing description content on the details page tab.
1558
+								 *
1559
+								 * @since 1.0.0
1560
+								 */
1561
+								do_action('geodir_after_description_on_listing_detail');
1562
+								break;
1563
+							case 'post_info':
1564
+								echo $geodir_post_detail_fields;
1565
+								break;
1566
+							case 'post_images':
1567
+								echo $thumb_image;
1568
+								break;
1569
+							case 'post_video':
1570
+								/** This action is documented in geodirectory_template_actions.php */
1571
+								echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1572
+								break;
1573
+							case 'special_offers':
1574
+								echo wpautop(stripslashes($special_offers));
1575
+
1576
+								break;
1577
+							case 'post_map':
1578
+								geodir_draw_map($map_args);
1579
+								break;
1580
+							case 'reviews':
1581
+								comments_template();
1582
+								break;
1583
+							case 'related_listing':
1584
+								echo $related_listing;
1585
+								break;
1586
+							default: {
1587
+								if ((isset($post->$tab_index) || (!isset($post->$tab_index) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
1588
+									echo $detail_page_tab['tab_content'];
1589
+								}
1590
+							}
1591
+								break;
1592
+						}
1593
+
1594
+						/**
1595
+						 * Called after the details tab content is output per tab.
1596
+						 *
1597
+						 * @since 1.0.0
1598
+						 */
1599
+						do_action('geodir_after_tab_content', $tab_index);
1600
+
1601
+						/**
1602
+						 * Called after the details tab content is output per tab.
1603
+						 *
1604
+						 * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1605
+						 *
1606
+						 * @since 1.0.0
1607
+						 * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1608
+						 */
1609
+						do_action('geodir_after_' . $tab_index . '_tab_content');
1610
+						?> </li>
1611 1611
                     <?php
1612
-                    /**
1613
-                     * Filter the current tab content.
1614
-                     *
1615
-                     * @since 1.0.0
1616
-                     */
1617
-                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1618
-                } // end of if for is_display
1619
-            }// end of foreach
1620
-
1621
-            /**
1622
-             * Called after the details page tab list headings, inside the `dl` tag.
1623
-             *
1624
-             * @since 1.0.0
1625
-             * @see 'geodir_before_tab_list'
1626
-             */
1627
-            do_action('geodir_after_tab_list');
1628
-            ?>
1612
+					/**
1613
+					 * Filter the current tab content.
1614
+					 *
1615
+					 * @since 1.0.0
1616
+					 */
1617
+					$arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1618
+				} // end of if for is_display
1619
+			}// end of foreach
1620
+
1621
+			/**
1622
+			 * Called after the details page tab list headings, inside the `dl` tag.
1623
+			 *
1624
+			 * @since 1.0.0
1625
+			 * @see 'geodir_before_tab_list'
1626
+			 */
1627
+			do_action('geodir_after_tab_list');
1628
+			?>
1629 1629
         </dl>
1630 1630
         <ul class="geodir-tabs-content entry-content" style="position:relative;">
1631 1631
             <?php
1632
-            foreach ($arr_detail_page_tabs as $detail_page_tab) {
1633
-                if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1634
-                    echo $detail_page_tab['tab_content'];
1635
-                }// end of if
1636
-            }// end of foreach
1637
-
1638
-            /**
1639
-             * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1640
-             *
1641
-             * @since 1.0.0
1642
-             */
1643
-            do_action('geodir_add_tab_content'); ?>
1632
+			foreach ($arr_detail_page_tabs as $detail_page_tab) {
1633
+				if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1634
+					echo $detail_page_tab['tab_content'];
1635
+				}// end of if
1636
+			}// end of foreach
1637
+
1638
+			/**
1639
+			 * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1640
+			 *
1641
+			 * @since 1.0.0
1642
+			 */
1643
+			do_action('geodir_add_tab_content'); ?>
1644 1644
         </ul>
1645 1645
         <!--gd-tabs-content ul end-->
1646 1646
     </div>
@@ -1677,127 +1677,127 @@  discard block
 block discarded – undo
1677 1677
  */
1678 1678
 function geodir_exif($file)
1679 1679
 {
1680
-    if (empty($file) || !is_array($file)) {
1681
-        return $file;
1682
-    }
1680
+	if (empty($file) || !is_array($file)) {
1681
+		return $file;
1682
+	}
1683 1683
     
1684
-    $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1685
-    if (!($file_path && file_exists($file_path))) {
1686
-        return $file;
1687
-    }
1688
-    $file['file'] = $file_path;
1684
+	$file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1685
+	if (!($file_path && file_exists($file_path))) {
1686
+		return $file;
1687
+	}
1688
+	$file['file'] = $file_path;
1689 1689
     
1690
-    if (!file_is_valid_image($file_path)) {
1691
-        return $file; // Bail if file is not an image.
1692
-    }
1690
+	if (!file_is_valid_image($file_path)) {
1691
+		return $file; // Bail if file is not an image.
1692
+	}
1693 1693
     
1694
-    if (!function_exists('wp_get_image_editor')) {
1695
-        return $file;
1696
-    }
1694
+	if (!function_exists('wp_get_image_editor')) {
1695
+		return $file;
1696
+	}
1697 1697
    
1698
-    $mime_type = $file['type'];
1699
-    $exif = array();
1700
-    if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1701
-        try {
1702
-            $exif = exif_read_data($file_path);
1703
-        } catch(Exception $e) {
1704
-            $exif = array();
1705
-        }
1706
-    }
1698
+	$mime_type = $file['type'];
1699
+	$exif = array();
1700
+	if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1701
+		try {
1702
+			$exif = exif_read_data($file_path);
1703
+		} catch(Exception $e) {
1704
+			$exif = array();
1705
+		}
1706
+	}
1707 1707
     
1708
-    $rotate = false;
1709
-    $flip = false;
1710
-    $modify = false;
1711
-    $orientation = 0;
1712
-    if (!empty($exif) && isset($exif['Orientation'])) {
1713
-        switch ((int)$exif['Orientation']) {
1714
-            case 1:
1715
-                // do nothing
1716
-                break;
1717
-            case 2:
1718
-                $flip = array(false, true);
1719
-                $modify = true;
1720
-                break;
1721
-            case 3:
1722
-                $orientation = -180;
1723
-                $rotate = true;
1724
-                $modify = true;
1725
-                break;
1726
-            case 4:
1727
-                $flip = array(true, false);
1728
-                $modify = true;
1729
-                break;
1730
-            case 5:
1731
-                $orientation = -90;
1732
-                $rotate = true;
1733
-                $flip = array(false, true);
1734
-                $modify = true;
1735
-                break;
1736
-            case 6:
1737
-                $orientation = -90;
1738
-                $rotate = true;
1739
-                $modify = true;
1740
-                break;
1741
-            case 7:
1742
-                $orientation = -270;
1743
-                $rotate = true;
1744
-                $flip = array(false, true);
1745
-                $modify = true;
1746
-                break;
1747
-            case 8:
1748
-            case 9:
1749
-                $orientation = -270;
1750
-                $rotate = true;
1751
-                $modify = true;
1752
-                break;
1753
-            default:
1754
-                $orientation = 0;
1755
-                $rotate = true;
1756
-                $modify = true;
1757
-                break;
1758
-        }
1759
-    }
1708
+	$rotate = false;
1709
+	$flip = false;
1710
+	$modify = false;
1711
+	$orientation = 0;
1712
+	if (!empty($exif) && isset($exif['Orientation'])) {
1713
+		switch ((int)$exif['Orientation']) {
1714
+			case 1:
1715
+				// do nothing
1716
+				break;
1717
+			case 2:
1718
+				$flip = array(false, true);
1719
+				$modify = true;
1720
+				break;
1721
+			case 3:
1722
+				$orientation = -180;
1723
+				$rotate = true;
1724
+				$modify = true;
1725
+				break;
1726
+			case 4:
1727
+				$flip = array(true, false);
1728
+				$modify = true;
1729
+				break;
1730
+			case 5:
1731
+				$orientation = -90;
1732
+				$rotate = true;
1733
+				$flip = array(false, true);
1734
+				$modify = true;
1735
+				break;
1736
+			case 6:
1737
+				$orientation = -90;
1738
+				$rotate = true;
1739
+				$modify = true;
1740
+				break;
1741
+			case 7:
1742
+				$orientation = -270;
1743
+				$rotate = true;
1744
+				$flip = array(false, true);
1745
+				$modify = true;
1746
+				break;
1747
+			case 8:
1748
+			case 9:
1749
+				$orientation = -270;
1750
+				$rotate = true;
1751
+				$modify = true;
1752
+				break;
1753
+			default:
1754
+				$orientation = 0;
1755
+				$rotate = true;
1756
+				$modify = true;
1757
+				break;
1758
+		}
1759
+	}
1760 1760
     
1761
-    $quality = null;
1762
-    /**
1763
-     * Filter the image quality.
1764
-     *
1765
-     * @since 1.5.7
1766
-     * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1767
-     * @param string $quality Image mime type.
1768
-     */
1769
-    $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1770
-    if ($quality !== null) {
1771
-        $modify = true;
1772
-    }
1761
+	$quality = null;
1762
+	/**
1763
+	 * Filter the image quality.
1764
+	 *
1765
+	 * @since 1.5.7
1766
+	 * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1767
+	 * @param string $quality Image mime type.
1768
+	 */
1769
+	$quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1770
+	if ($quality !== null) {
1771
+		$modify = true;
1772
+	}
1773 1773
 
1774
-    if (!$modify) {
1775
-        return $file; // no change
1776
-    }
1774
+	if (!$modify) {
1775
+		return $file; // no change
1776
+	}
1777 1777
 
1778
-    $image = wp_get_image_editor($file_path);
1779
-    if (!is_wp_error($image)) {
1780
-        if ($rotate) {
1781
-            $image->rotate($orientation);
1782
-        }
1778
+	$image = wp_get_image_editor($file_path);
1779
+	if (!is_wp_error($image)) {
1780
+		if ($rotate) {
1781
+			$image->rotate($orientation);
1782
+		}
1783 1783
         
1784
-        if (!empty($flip)) {
1785
-            $image->flip($flip[0], $flip[1]);
1786
-        }
1784
+		if (!empty($flip)) {
1785
+			$image->flip($flip[0], $flip[1]);
1786
+		}
1787 1787
         
1788
-        if ($quality !== null) {
1789
-            $image->set_quality((int)$quality);
1790
-        }
1788
+		if ($quality !== null) {
1789
+			$image->set_quality((int)$quality);
1790
+		}
1791 1791
         
1792
-       $result = $image->save($file_path);
1793
-       if (!is_wp_error($result)) {
1794
-           $file['file'] = $result['path'];
1795
-           $file['tmp_name'] = $result['path'];
1796
-       }
1797
-    }
1792
+	   $result = $image->save($file_path);
1793
+	   if (!is_wp_error($result)) {
1794
+		   $file['file'] = $result['path'];
1795
+		   $file['tmp_name'] = $result['path'];
1796
+	   }
1797
+	}
1798 1798
     
1799
-    // The image orientation is fixed, pass it back for further processing
1800
-    return $file;
1799
+	// The image orientation is fixed, pass it back for further processing
1800
+	return $file;
1801 1801
 }
1802 1802
 
1803 1803
 /**
@@ -1816,138 +1816,138 @@  discard block
 block discarded – undo
1816 1816
  * @return string Returns the recent reviews html.
1817 1817
  */
1818 1818
 function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
1819
-    global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1820
-    $tablecomments = $wpdb->comments;
1821
-    $tableposts = $wpdb->posts;
1822
-
1823
-    $comments_echo = '';
1824
-    $city_filter = '';
1825
-    $region_filter = '';
1826
-    $country_filter = '';
1827
-
1828
-    if ($gd_session->get('gd_multi_location')) {
1829
-        if ($gd_ses_country = $gd_session->get('gd_country')) {
1830
-            $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1831
-        }
1819
+	global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1820
+	$tablecomments = $wpdb->comments;
1821
+	$tableposts = $wpdb->posts;
1822
+
1823
+	$comments_echo = '';
1824
+	$city_filter = '';
1825
+	$region_filter = '';
1826
+	$country_filter = '';
1827
+
1828
+	if ($gd_session->get('gd_multi_location')) {
1829
+		if ($gd_ses_country = $gd_session->get('gd_country')) {
1830
+			$country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1831
+		}
1832 1832
 
1833
-        if ($gd_ses_region = $gd_session->get('gd_region')) {
1834
-            $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1835
-        }
1833
+		if ($gd_ses_region = $gd_session->get('gd_region')) {
1834
+			$region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1835
+		}
1836 1836
 
1837
-        if ($gd_ses_city = $gd_session->get('gd_city')) {
1838
-            $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1839
-        }
1840
-    }
1837
+		if ($gd_ses_city = $gd_session->get('gd_city')) {
1838
+			$city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1839
+		}
1840
+	}
1841 1841
 	
1842
-    $review_table = GEODIR_REVIEW_TABLE;
1843
-    $request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments";
1844
-
1845
-    $comments = $wpdb->get_results($request);
1846
-
1847
-    foreach ($comments as $comment) {
1848
-        // Set the extra comment info needed.
1849
-        $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1850
-        //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1851
-        $comment->comment_content = $comment_extra->comment_content;
1852
-        $comment->comment_author = $comment_extra->comment_author;
1853
-        $comment->comment_author_email = $comment_extra->comment_author_email;
1854
-
1855
-        $comment_id = '';
1856
-        $comment_id = $comment->comment_ID;
1857
-        $comment_content = strip_tags($comment->comment_content);
1858
-
1859
-        $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1860
-
1861
-        $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1862
-        $comment_author_email = $comment->comment_author_email;
1863
-        $comment_post_ID = $comment->post_id;
1864
-
1865
-        $na = true;
1866
-        if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1867
-            $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1868
-            if ($comment_post_ID == $comment_post_ID2) {
1869
-            } else {
1870
-                $na = false;
1871
-            }
1872
-        }
1842
+	$review_table = GEODIR_REVIEW_TABLE;
1843
+	$request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments";
1844
+
1845
+	$comments = $wpdb->get_results($request);
1846
+
1847
+	foreach ($comments as $comment) {
1848
+		// Set the extra comment info needed.
1849
+		$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1850
+		//echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1851
+		$comment->comment_content = $comment_extra->comment_content;
1852
+		$comment->comment_author = $comment_extra->comment_author;
1853
+		$comment->comment_author_email = $comment_extra->comment_author_email;
1854
+
1855
+		$comment_id = '';
1856
+		$comment_id = $comment->comment_ID;
1857
+		$comment_content = strip_tags($comment->comment_content);
1858
+
1859
+		$comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1860
+
1861
+		$permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1862
+		$comment_author_email = $comment->comment_author_email;
1863
+		$comment_post_ID = $comment->post_id;
1864
+
1865
+		$na = true;
1866
+		if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1867
+			$comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1868
+			if ($comment_post_ID == $comment_post_ID2) {
1869
+			} else {
1870
+				$na = false;
1871
+			}
1872
+		}
1873 1873
 
1874
-        $post_title = get_the_title($comment_post_ID);
1875
-        $permalink = get_permalink($comment_post_ID);
1876
-        $comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1877
-        $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1874
+		$post_title = get_the_title($comment_post_ID);
1875
+		$permalink = get_permalink($comment_post_ID);
1876
+		$comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1877
+		$read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1878 1878
 
1879
-        $comment_content_length = strlen($comment_content);
1880
-        if ($comment_content_length > $comment_lenth) {
1881
-            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1882
-        } else {
1883
-            $comment_excerpt = $comment_content;
1884
-        }
1879
+		$comment_content_length = strlen($comment_content);
1880
+		if ($comment_content_length > $comment_lenth) {
1881
+			$comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1882
+		} else {
1883
+			$comment_excerpt = $comment_content;
1884
+		}
1885 1885
 
1886
-        if ($comment->user_id) {
1887
-            $user_profile_url = get_author_posts_url($comment->user_id);
1888
-        } else {
1889
-            $user_profile_url = '';
1890
-        }
1886
+		if ($comment->user_id) {
1887
+			$user_profile_url = get_author_posts_url($comment->user_id);
1888
+		} else {
1889
+			$user_profile_url = '';
1890
+		}
1891 1891
 
1892
-        if ($comment_id && $na) {
1893
-            $comments_echo .= '<li class="clearfix">';
1894
-            $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1895
-            if (function_exists('get_avatar')) {
1896
-                if (!isset($comment->comment_type)) {
1897
-                    if ($user_profile_url) {
1898
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1899
-                    }
1900
-                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1901
-                    if ($user_profile_url) {
1902
-                        $comments_echo .= '</a>';
1903
-                    }
1904
-                } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1905
-                    if ($user_profile_url) {
1906
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1907
-                    }
1908
-                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1909
-                }
1910
-            } elseif (function_exists('gravatar')) {
1911
-                if ($user_profile_url) {
1912
-                    $comments_echo .= '<a href="' . $user_profile_url . '">';
1913
-                }
1914
-                $comments_echo .= "<img src=\"";
1915
-                if ('' == $comment->comment_type) {
1916
-                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1917
-                    if ($user_profile_url) {
1918
-                        $comments_echo .= '</a>';
1919
-                    }
1920
-                } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1921
-                    if ($user_profile_url) {
1922
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1923
-                    }
1924
-                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1925
-                    if ($user_profile_url) {
1926
-                        $comments_echo .= '</a>';
1927
-                    }
1928
-                }
1929
-                $comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1930
-            }
1892
+		if ($comment_id && $na) {
1893
+			$comments_echo .= '<li class="clearfix">';
1894
+			$comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1895
+			if (function_exists('get_avatar')) {
1896
+				if (!isset($comment->comment_type)) {
1897
+					if ($user_profile_url) {
1898
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1899
+					}
1900
+					$comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1901
+					if ($user_profile_url) {
1902
+						$comments_echo .= '</a>';
1903
+					}
1904
+				} elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1905
+					if ($user_profile_url) {
1906
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1907
+					}
1908
+					$comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1909
+				}
1910
+			} elseif (function_exists('gravatar')) {
1911
+				if ($user_profile_url) {
1912
+					$comments_echo .= '<a href="' . $user_profile_url . '">';
1913
+				}
1914
+				$comments_echo .= "<img src=\"";
1915
+				if ('' == $comment->comment_type) {
1916
+					$comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1917
+					if ($user_profile_url) {
1918
+						$comments_echo .= '</a>';
1919
+					}
1920
+				} elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1921
+					if ($user_profile_url) {
1922
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1923
+					}
1924
+					$comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1925
+					if ($user_profile_url) {
1926
+						$comments_echo .= '</a>';
1927
+					}
1928
+				}
1929
+				$comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1930
+			}
1931 1931
 
1932
-            $comments_echo .= "</span>\n";
1933
-
1934
-            $comments_echo .= '<span class="geodir_reviewer_content">';
1935
-            if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1936
-            $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1937
-            if($comment->user_id){$comments_echo .= '</a>';}
1938
-            $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1939
-            $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1940
-            $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
1941
-            $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
1942
-            //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
1943
-            $comments_echo .= '</p>';
1944
-
1945
-            $comments_echo .= "</span>\n";
1946
-            $comments_echo .= '</li>';
1947
-        }
1948
-    }
1932
+			$comments_echo .= "</span>\n";
1933
+
1934
+			$comments_echo .= '<span class="geodir_reviewer_content">';
1935
+			if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1936
+			$comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1937
+			if($comment->user_id){$comments_echo .= '</a>';}
1938
+			$comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1939
+			$comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1940
+			$comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
1941
+			$comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
1942
+			//echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
1943
+			$comments_echo .= '</p>';
1944
+
1945
+			$comments_echo .= "</span>\n";
1946
+			$comments_echo .= '</li>';
1947
+		}
1948
+	}
1949 1949
 
1950
-    return $comments_echo;
1950
+	return $comments_echo;
1951 1951
 }
1952 1952
 
1953 1953
 /**
@@ -1959,29 +1959,29 @@  discard block
 block discarded – undo
1959 1959
  */
1960 1960
 function geodir_home_map_cats_key_value_array()
1961 1961
 {
1962
-    $post_types = geodir_get_posttypes('object');
1962
+	$post_types = geodir_get_posttypes('object');
1963 1963
 
1964
-    $return = array();
1965
-    if (!empty($post_types)) {
1966
-        foreach ($post_types as $key => $post_type) {
1967
-            $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1968
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1969
-            $taxonomies = geodir_get_taxonomies($key);
1970
-            $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
1971
-            $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
1964
+	$return = array();
1965
+	if (!empty($post_types)) {
1966
+		foreach ($post_types as $key => $post_type) {
1967
+			$cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1968
+			$post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1969
+			$taxonomies = geodir_get_taxonomies($key);
1970
+			$cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
1971
+			$cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
1972 1972
 
1973
-            if (!empty($cat_terms)) {
1974
-                $return['optgroup_start-' . $key] = $post_type_name;
1973
+			if (!empty($cat_terms)) {
1974
+				$return['optgroup_start-' . $key] = $post_type_name;
1975 1975
 
1976
-                foreach ($cat_terms as $cat_term) {
1977
-                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
1978
-                }
1976
+				foreach ($cat_terms as $cat_term) {
1977
+					$return[$key . '_' . $cat_term->term_id] = $cat_term->name;
1978
+				}
1979 1979
 
1980
-                $return['optgroup_end-' . $key] = $post_type_name;
1981
-            }
1982
-        }
1983
-    }
1984
-    return $return;
1980
+				$return['optgroup_end-' . $key] = $post_type_name;
1981
+			}
1982
+		}
1983
+	}
1984
+	return $return;
1985 1985
 }
1986 1986
 
1987 1987
 /**
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
  */
1994 1994
 function geodir_twitter_tweet_button()
1995 1995
 {
1996
-    ?>
1996
+	?>
1997 1997
     <a href="http://twitter.com/share"
1998 1998
        class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
1999 1999
     <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
@@ -2011,11 +2011,11 @@  discard block
 block discarded – undo
2011 2011
  */
2012 2012
 function geodir_fb_like_button()
2013 2013
 {
2014
-    global $post;
2015
-    ?>
2014
+	global $post;
2015
+	?>
2016 2016
     <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
2017
-        echo 'allowtransparency="true"';
2018
-    } ?> class="facebook"
2017
+		echo 'allowtransparency="true"';
2018
+	} ?> class="facebook"
2019 2019
          src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light"
2020 2020
          style="border:none; overflow:hidden; width:100px; height:20px"></iframe>
2021 2021
 <?php
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
  */
2032 2032
 function geodir_google_plus_button()
2033 2033
 {
2034
-    ?>
2034
+	?>
2035 2035
     <div id="plusone-div" class="g-plusone" data-size="medium"></div>
2036 2036
     <script type="text/javascript">
2037 2037
         (function () {
@@ -2057,8 +2057,8 @@  discard block
 block discarded – undo
2057 2057
  */
2058 2058
 function geodir_share_this_button_code()
2059 2059
 {
2060
-    global $post;
2061
-    ?>
2060
+	global $post;
2061
+	?>
2062 2062
     <div class="addthis_toolbox addthis_default_style">
2063 2063
         <span id='st_sharethis'></span>
2064 2064
         <script type="text/javascript">var switchTo5x = false;</script>
@@ -2085,8 +2085,8 @@  discard block
 block discarded – undo
2085 2085
 
2086 2086
 function geodir_listing_bounce_map_pin_on_hover(){
2087 2087
 
2088
-    if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2089
-            ?>
2088
+	if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2089
+			?>
2090 2090
             <script>
2091 2091
                 jQuery(function ($) {
2092 2092
                     if (typeof(animate_marker) == 'function') {
@@ -2103,35 +2103,35 @@  discard block
 block discarded – undo
2103 2103
 
2104 2104
         <?php
2105 2105
 
2106
-    }
2106
+	}
2107 2107
 }
2108 2108
 add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2109 2109
 
2110 2110
 add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2111 2111
 
2112 2112
 function geodir_output_favourite_html_listings( $post_id){
2113
-    geodir_favourite_html('', $post_id);
2113
+	geodir_favourite_html('', $post_id);
2114 2114
 }
2115 2115
 
2116 2116
 
2117 2117
 do_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings',1,2 );
2118 2118
 
2119 2119
 function geodir_output_pinpoint_html_listings( $post_id, $post){
2120
-    global $wp_query;
2120
+	global $wp_query;
2121 2121
 
2122
-    $show_pin_point = $wp_query->is_main_query();
2123
-    if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2122
+	$show_pin_point = $wp_query->is_main_query();
2123
+	if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2124 2124
 
2125
-        /*if($json_info = json_decode($post->marker_json))
2125
+		/*if($json_info = json_decode($post->marker_json))
2126 2126
             $marker_icon = $json_info->icon;*/
2127 2127
 
2128
-        $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2129
-        $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2130
-        ?>
2128
+		$term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2129
+		$marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2130
+		?>
2131 2131
         <span class="geodir-pinpoint"
2132 2132
               style=" background:url('<?php if (isset($marker_icon)) {
2133
-                  echo $marker_icon;
2134
-              } ?>') no-repeat scroll left top transparent; background-size:auto 100%; -webkit-background-size:auto 100%; -moz-background-size:auto 100%; height:9px; width:14px; ">
2133
+				  echo $marker_icon;
2134
+			  } ?>') no-repeat scroll left top transparent; background-size:auto 100%; -webkit-background-size:auto 100%; -moz-background-size:auto 100%; height:9px; width:14px; ">
2135 2135
                                         <?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?>
2136 2136
                                     </span>
2137 2137
         <a class="geodir-pinpoint-link" href="javascript:void(0)"
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -51,20 +51,20 @@  discard block
 block discarded – undo
51 51
 			jQuery(listSel).children('li').switchClass('gridview_onehalf gridview_onethird gridview_onefourth', 'gridview_onefifth', 600);
52 52
 		}
53 53
 
54
-		jQuery.post("<?php echo geodir_get_ajax_url();?>&gd_listing_view=" + val, function (data) {
54
+		jQuery.post("<?php echo geodir_get_ajax_url(); ?>&gd_listing_view=" + val, function (data) {
55 55
 			//alert(data );
56 56
 		});
57 57
 	}
58 58
     </script>
59 59
     <div class="geodir-list-view-select">
60 60
         <select name="gd_list_view" id="gd_list_view" onchange="geodir_list_view_select(this);">
61
-            <?php $listing_view = (int)$gd_session->get('gd_listing_view'); ?>
62
-            <option value=""><?php _e('View:', 'geodirectory');?></option>
63
-            <option value="1" <?php selected(1, $listing_view);?>><?php _e('View: List', 'geodirectory');?></option>
64
-            <option value="2" <?php selected(2, $listing_view);?>><?php _e('View: Grid 2', 'geodirectory');?></option>
65
-            <option value="3" <?php selected(3, $listing_view);?>><?php _e('View: Grid 3', 'geodirectory');?></option>
66
-            <option value="4" <?php selected(4, $listing_view);?>><?php _e('View: Grid 4', 'geodirectory');?></option>
67
-            <option value="5" <?php selected(5, $listing_view);?>><?php _e('View: Grid 5', 'geodirectory');?></option>
61
+            <?php $listing_view = (int) $gd_session->get('gd_listing_view'); ?>
62
+            <option value=""><?php _e('View:', 'geodirectory'); ?></option>
63
+            <option value="1" <?php selected(1, $listing_view); ?>><?php _e('View: List', 'geodirectory'); ?></option>
64
+            <option value="2" <?php selected(2, $listing_view); ?>><?php _e('View: Grid 2', 'geodirectory'); ?></option>
65
+            <option value="3" <?php selected(3, $listing_view); ?>><?php _e('View: Grid 3', 'geodirectory'); ?></option>
66
+            <option value="4" <?php selected(4, $listing_view); ?>><?php _e('View: Grid 4', 'geodirectory'); ?></option>
67
+            <option value="5" <?php selected(5, $listing_view); ?>><?php _e('View: Grid 5', 'geodirectory'); ?></option>
68 68
         </select>
69 69
     </div>
70 70
 <?php
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      * @param object|string $post The post object.
185 185
      * @param string $post_type The post type.
186 186
      */
187
-    return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
187
+    return (object) apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
188 188
 
189 189
 }
190 190
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         // strip slashes message
299 299
         $client_message = stripslashes_deep($client_message);
300 300
 
301
-        geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
301
+        geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email
302 302
     }
303 303
 
304 304
     /**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      * }
404 404
      */
405 405
     do_action('geodir_before_send_to_friend_email', $request);
406
-    geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
406
+    geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email
407 407
 
408 408
     /**
409 409
      * Called after the send to friend email is sent.
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 *
588 588
 	 * @since 1.4.4
589 589
 	 */
590
-	if ( is_search() ) {
590
+	if (is_search()) {
591 591
 		return;
592 592
 	}
593 593
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
             if ($sort->field_type == 'random') {
612 612
                 $key = $sort->field_type;
613 613
                 ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
614
+                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url(add_query_arg('sort_by', $key)) . '">' . __($label, 'geodirectory') . '</option>';
615 615
             }
616 616
 
617 617
             if ($sort->htmlvar_name == 'comment_count') {
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                 if ($sort->asc_title)
625 625
                     $label = $sort->asc_title;
626 626
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
627
+                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url(add_query_arg('sort_by', $key)) . '">' . __($label, 'geodirectory') . '</option>';
628 628
             }
629 629
 
630 630
             if ($sort->sort_desc) {
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
                 if ($sort->desc_title)
634 634
                     $label = $sort->desc_title;
635 635
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
636
+                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url(add_query_arg('sort_by', $key)) . '">' . __($label, 'geodirectory') . '</option>';
637 637
             }
638 638
 
639 639
         }
@@ -648,9 +648,9 @@  discard block
 block discarded – undo
648 648
             <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;">
649 649
 
650 650
                 <option
651
-                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
651
+                    value="<?php echo esc_url(add_query_arg('sort_by', '')); ?>" <?php if ($sort_by == '') echo 'selected="selected"'; ?>><?php _e('Sort By', 'geodirectory'); ?></option><?php
652 652
 
653
-                echo $sort_field_options;?>
653
+                echo $sort_field_options; ?>
654 654
 
655 655
             </select>
656 656
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
         $category = array();
720 720
 
721 721
         if (isset($_REQUEST['backandedit'])) {
722
-            $post = (object)$gd_session->get('listing');
722
+            $post = (object) $gd_session->get('listing');
723 723
             $post_type = $post->listing_type;
724 724
             if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725 725
                 $post_id = $_REQUEST['pid'];
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
             if ($add_location_filter != '0') {
797 797
                 $geodir_add_location_url = '1';
798 798
             }
799
-            $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
799
+            $viewall_url = get_term_link((int) $category[0], $post_type . $category_taxonomy);
800 800
             $geodir_add_location_url = NULL;
801 801
         }
802 802
         ob_start();
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
         $geodir_post_category_str = serialize($geodir_post_category_str);
894 894
     }
895 895
 
896
-    $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
896
+    $all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8');
897 897
     $script = "var post_category_array = " . json_encode($all_var) . ';';
898 898
     echo '<script>';
899 899
     echo $script;
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
     $location_id = NULL;
1027 1027
     if ($geodir_location_manager) {
1028 1028
         $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1029
-        $location_id = (int)$wpdb->get_var($sql);
1029
+        $location_id = (int) $wpdb->get_var($sql);
1030 1030
         $location_type = geodir_what_is_current_location();
1031 1031
         if ($location_type == 'city') {
1032 1032
             $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
@@ -1087,45 +1087,45 @@  discard block
 block discarded – undo
1087 1087
 
1088 1088
 
1089 1089
     $gd_page = '';
1090
-    if(geodir_is_page('home')){
1090
+    if (geodir_is_page('home')) {
1091 1091
         $gd_page = 'home';
1092 1092
         $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093 1093
     }
1094
-    elseif(geodir_is_page('detail')){
1094
+    elseif (geodir_is_page('detail')) {
1095 1095
         $gd_page = 'detail';
1096 1096
         $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097 1097
     }
1098
-    elseif(geodir_is_page('pt')){
1098
+    elseif (geodir_is_page('pt')) {
1099 1099
         $gd_page = 'pt';
1100 1100
         $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101 1101
     }
1102
-    elseif(geodir_is_page('listing')){
1102
+    elseif (geodir_is_page('listing')) {
1103 1103
         $gd_page = 'listing';
1104 1104
         $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105 1105
     }
1106
-    elseif(geodir_is_page('location')){
1106
+    elseif (geodir_is_page('location')) {
1107 1107
         $gd_page = 'location';
1108 1108
         $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109 1109
         $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1110 1110
 
1111 1111
     }
1112
-    elseif(geodir_is_page('search')){
1112
+    elseif (geodir_is_page('search')) {
1113 1113
         $gd_page = 'search';
1114 1114
         $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115 1115
     }
1116
-    elseif(geodir_is_page('add-listing')){
1116
+    elseif (geodir_is_page('add-listing')) {
1117 1117
         $gd_page = 'add-listing';
1118 1118
         $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119 1119
     }
1120
-    elseif(geodir_is_page('author')){
1120
+    elseif (geodir_is_page('author')) {
1121 1121
         $gd_page = 'author';
1122 1122
         $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123 1123
     }
1124
-    elseif(geodir_is_page('login')){
1124
+    elseif (geodir_is_page('login')) {
1125 1125
         $gd_page = 'login';
1126 1126
         $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127 1127
     }
1128
-    elseif(geodir_is_page('listing-success')){
1128
+    elseif (geodir_is_page('listing-success')) {
1129 1129
         $gd_page = 'listing-success';
1130 1130
         $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131 1131
     }
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
          * @param string $title The page description including variables.
1154 1154
          * @param string $gd_page The GeoDirectory page type if any.
1155 1155
          */
1156
-        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1156
+        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
1157 1157
 
1158 1158
         /**
1159 1159
          * Filter SEO meta description.
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
         $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1170 1170
         $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1171 1171
 
1172
-        $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1172
+        $meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
1173 1173
     } else {
1174 1174
         $posttags = get_the_tags();
1175 1175
         if ($posttags) {
@@ -1355,8 +1355,8 @@  discard block
 block discarded – undo
1355 1355
 {
1356 1356
     global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1357 1357
 
1358
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1358
+    $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0;
1359
+    $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
1360 1360
     $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1361 1361
 
1362 1362
     if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
         if (!empty($post_images)) {
1391 1391
             foreach ($post_images as $image) {
1392 1392
                 $caption = (!empty($image->caption)) ? $image->caption : '';
1393
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1393
+                $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">';
1394 1394
                 $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1395 1395
                 $thumb_image .= '</a>';
1396 1396
             }
@@ -1464,13 +1464,13 @@  discard block
 block discarded – undo
1464 1464
         $map_args['map_class_name'] = 'geodir-map-preview-page';
1465 1465
     }
1466 1466
 
1467
-    $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1467
+    $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user
1468 1468
 
1469 1469
     $active_tab = '';
1470 1470
     $active_tab_name = '';
1471 1471
     $default_tab = '';
1472 1472
     $default_tab_name = '';
1473
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1473
+    foreach ($arr_detail_page_tabs as $tab_index => $tabs) {
1474 1474
         if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1475 1475
             $active_tab = $tab_index;
1476 1476
             $active_tab_name = __($tabs['heading_text'], 'geodirectory');
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1496 1496
         <div id="geodir-tab-mobile-menu" >
1497 1497
             <i class="fa fa-bars"></i>
1498
-            <span class="geodir-mobile-active-tab"><?php echo $active_tab_name;?></span>
1498
+            <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span>
1499 1499
             <i class="fa fa-sort-desc"></i>
1500 1500
         </div>
1501 1501
         <dl class="geodir-tab-head">
@@ -1512,13 +1512,13 @@  discard block
 block discarded – undo
1512 1512
                 if ($detail_page_tab['is_display']) {
1513 1513
                     ?>
1514 1514
                     <dt></dt> <!-- added to comply with validation -->
1515
-                    <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php }?> ><a data-tab="#<?php echo $tab_index;?>" data-status="enable"><?php _e($detail_page_tab['heading_text'],'geodirectory');?></a>
1515
+                    <dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php }?> ><a data-tab="#<?php echo $tab_index; ?>" data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a>
1516 1516
                     </dd>
1517 1517
                     <?php
1518 1518
                     ob_start() // start tab content buffering
1519 1519
                     ?>
1520
-                    <li id="<?php echo $tab_index;?>Tab">
1521
-                        <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1520
+                    <li id="<?php echo $tab_index; ?>Tab">
1521
+                        <div id="<?php echo $tab_index; ?>" class="hash-offset"></div>
1522 1522
                         <?php
1523 1523
                         /**
1524 1524
                          * Called before the details tab content is output per tab.
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
                                 break;
1569 1569
                             case 'post_video':
1570 1570
                                 /** This action is documented in geodirectory_template_actions.php */
1571
-                                echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1571
+                                echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
1572 1572
                                 break;
1573 1573
                             case 'special_offers':
1574 1574
                                 echo wpautop(stripslashes($special_offers));
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
     if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1701 1701
         try {
1702 1702
             $exif = exif_read_data($file_path);
1703
-        } catch(Exception $e) {
1703
+        } catch (Exception $e) {
1704 1704
             $exif = array();
1705 1705
         }
1706 1706
     }
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
     $modify = false;
1711 1711
     $orientation = 0;
1712 1712
     if (!empty($exif) && isset($exif['Orientation'])) {
1713
-        switch ((int)$exif['Orientation']) {
1713
+        switch ((int) $exif['Orientation']) {
1714 1714
             case 1:
1715 1715
                 // do nothing
1716 1716
                 break;
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
         }
1787 1787
         
1788 1788
         if ($quality !== null) {
1789
-            $image->set_quality((int)$quality);
1789
+            $image->set_quality((int) $quality);
1790 1790
         }
1791 1791
         
1792 1792
        $result = $image->save($file_path);
@@ -1932,9 +1932,9 @@  discard block
 block discarded – undo
1932 1932
             $comments_echo .= "</span>\n";
1933 1933
 
1934 1934
             $comments_echo .= '<span class="geodir_reviewer_content">';
1935
-            if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1935
+            if ($comment->user_id) {$comments_echo .= '<a href="' . get_author_posts_url($comment->user_id) . '">'; }
1936 1936
             $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1937
-            if($comment->user_id){$comments_echo .= '</a>';}
1937
+            if ($comment->user_id) {$comments_echo .= '</a>'; }
1938 1938
             $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1939 1939
             $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1940 1940
             $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
@@ -1965,7 +1965,7 @@  discard block
 block discarded – undo
1965 1965
     if (!empty($post_types)) {
1966 1966
         foreach ($post_types as $key => $post_type) {
1967 1967
             $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1968
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1968
+            $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
1969 1969
             $taxonomies = geodir_get_taxonomies($key);
1970 1970
             $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
1971 1971
             $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
@@ -2072,10 +2072,10 @@  discard block
 block discarded – undo
2072 2072
             stWidget.addEntry({
2073 2073
                 "service": "sharethis",
2074 2074
                 "element": document.getElementById('st_sharethis'),
2075
-                "url": "<?php echo geodir_curPageURL();?>",
2076
-                "title": "<?php echo $post->post_title;?>",
2075
+                "url": "<?php echo geodir_curPageURL(); ?>",
2076
+                "title": "<?php echo $post->post_title; ?>",
2077 2077
                 "type": "chicklet",
2078
-                "text": "<?php _e( 'Share', 'geodirectory' );?>"
2078
+                "text": "<?php _e('Share', 'geodirectory'); ?>"
2079 2079
             });</script>
2080 2080
 
2081 2081
     </div>
@@ -2083,9 +2083,9 @@  discard block
 block discarded – undo
2083 2083
 }
2084 2084
 
2085 2085
 
2086
-function geodir_listing_bounce_map_pin_on_hover(){
2086
+function geodir_listing_bounce_map_pin_on_hover() {
2087 2087
 
2088
-    if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2088
+    if (get_option('geodir_listing_hover_bounce_map_pin', true)) {
2089 2089
             ?>
2090 2090
             <script>
2091 2091
                 jQuery(function ($) {
@@ -2105,18 +2105,18 @@  discard block
 block discarded – undo
2105 2105
 
2106 2106
     }
2107 2107
 }
2108
-add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2108
+add_action('geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10);
2109 2109
 
2110
-add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2110
+add_action('geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1);
2111 2111
 
2112
-function geodir_output_favourite_html_listings( $post_id){
2112
+function geodir_output_favourite_html_listings($post_id) {
2113 2113
     geodir_favourite_html('', $post_id);
2114 2114
 }
2115 2115
 
2116 2116
 
2117
-do_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings',1,2 );
2117
+do_action('geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2118 2118
 
2119
-function geodir_output_pinpoint_html_listings( $post_id, $post){
2119
+function geodir_output_pinpoint_html_listings($post_id, $post) {
2120 2120
     global $wp_query;
2121 2121
 
2122 2122
     $show_pin_point = $wp_query->is_main_query();
Please login to merge, or discard this patch.
geodirectory-functions/custom_taxonomy_hooks_actions.php 4 patches
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
  * @global wpdb $wpdb WordPress database abstraction object.
326 326
  * @deprecated 1.5.0 No longer required.
327 327
  * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
328
- * @return array Rewrite rules.
328
+ * @return string Rewrite rules.
329 329
  */
330 330
 function geodir_htaccess_contents($rules)
331 331
 {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
  * @since 1.0.0
351 351
  *
352 352
  * @param array $public_query_vars The array of query variables.
353
- * @return array Query variables.
353
+ * @return string[] Query variables.
354 354
  */
355 355
 function geodir_add_location_var($public_query_vars)
356 356
 {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
  * @since 1.0.0
367 367
  *
368 368
  * @param array $public_query_vars The array of query variables.
369
- * @return array Query variables.
369
+ * @return string[] Query variables.
370 370
  */
371 371
 function geodir_add_geodir_page_var($public_query_vars)
372 372
 {
@@ -793,7 +793,6 @@  discard block
 block discarded – undo
793 793
  *
794 794
  * @since 1.0.0
795 795
  *
796
- * @param object $wp The WordPress object.
797 796
  */
798 797
 function geodir_custom_post_status()
799 798
 {
Please login to merge, or discard this patch.
Braces   +103 added lines, -70 removed lines patch added patch discarded remove patch
@@ -106,24 +106,30 @@  discard block
 block discarded – undo
106 106
         $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
107 107
 
108 108
         if ($post_type == 'gd_place') {
109
-            if (array_key_exists('has_archive', $args))
110
-                $args['has_archive'] = $listing_slug;
109
+            if (array_key_exists('has_archive', $args)) {
110
+                            $args['has_archive'] = $listing_slug;
111
+            }
111 112
 
112 113
             if (array_key_exists('rewrite', $args)) {
113
-                if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
114
+                if (array_key_exists('slug', $args['rewrite'])) {
115
+                                    $args['rewrite']['slug'] = $listing_slug;
116
+                }
117
+                // . '/%gd_taxonomy%';
115 118
             }
116 119
 
117 120
             $geodir_post_types = get_option('geodir_post_types');
118 121
 
119 122
             if (array_key_exists($post_type, $geodir_post_types)) {
120 123
 
121
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
124
+                if (array_key_exists('has_archive', $geodir_post_types[$post_type])) {
125
+                                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
126
+                }
123 127
 
124
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
128
+                if (array_key_exists('rewrite', $geodir_post_types[$post_type])) {
129
+                                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
130
+                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;
131
+                }
132
+                // . '/%gd_taxonomy%';
127 133
 
128 134
                 update_option('geodir_post_types', $geodir_post_types);
129 135
 
@@ -138,10 +144,11 @@  discard block
 block discarded – undo
138 144
             if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139 145
                 $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
140 146
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
147
+                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category'])) {
148
+                                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143 149
                         if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
150
+                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
151
+                }
145 152
 
146 153
                 update_option('geodir_taxonomies', $geodir_taxonomies);
147 154
 
@@ -152,10 +159,11 @@  discard block
 block discarded – undo
152 159
             if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153 160
                 $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
154 161
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
162
+                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags'])) {
163
+                                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157 164
                         if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
165
+                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
166
+                }
159 167
 
160 168
                 update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 169
 
@@ -221,8 +229,9 @@  discard block
 block discarded – undo
221 229
         global $wpdb;
222 230
         $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223 231
     }
224
-    if (!isset($location_prefix))
225
-        $location_prefix = 'location';
232
+    if (!isset($location_prefix)) {
233
+            $location_prefix = 'location';
234
+    }
226 235
 
227 236
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
228 237
 	if ($location_manager) {
@@ -441,14 +450,17 @@  discard block
 block discarded – undo
441 450
         $gd_country = '';
442 451
         $gd_region = '';
443 452
         $gd_city = '';
444
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
-            $gd_country = urldecode($wp->query_vars['gd_country']);
453
+        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') {
454
+                    $gd_country = urldecode($wp->query_vars['gd_country']);
455
+        }
446 456
 
447
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
-            $gd_region = urldecode($wp->query_vars['gd_region']);
457
+        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') {
458
+                    $gd_region = urldecode($wp->query_vars['gd_region']);
459
+        }
449 460
 
450
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
-            $gd_city = urldecode($wp->query_vars['gd_city']);
461
+        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') {
462
+                    $gd_city = urldecode($wp->query_vars['gd_city']);
463
+        }
452 464
 
453 465
         if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454 466
             $default_location = geodir_get_default_location();
@@ -456,17 +468,19 @@  discard block
 block discarded – undo
456 468
             if (get_option('geodir_add_location_url')) {
457 469
                 if ($geodir_show_location_url != 'all') {
458 470
                     if ($gd_region == '') {
459
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
460
-                            $gd_region = $gd_ses_region;
461
-                        else
462
-                            $gd_region = $default_location->region_slug;
471
+                        if ($gd_ses_region = $gd_session->get('gd_region')) {
472
+                                                    $gd_region = $gd_ses_region;
473
+                        } else {
474
+                                                    $gd_region = $default_location->region_slug;
475
+                        }
463 476
                     }
464 477
 
465 478
                     if ($gd_city == '') {
466
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
467
-                            $gd_city = $gd_ses_city;
468
-                        else
469
-                            $gd_city = $default_location->city_slug;
479
+                        if ($gd_ses_city = $gd_session->get('gd_city')) {
480
+                                                    $gd_city = $gd_ses_city;
481
+                        } else {
482
+                                                    $gd_city = $default_location->city_slug;
483
+                        }
470 484
 
471 485
                         $base_location_link = geodir_get_location_link('base');
472 486
                         wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
@@ -585,8 +599,9 @@  discard block
 block discarded – undo
585 599
 
586 600
 
587 601
 				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
588
-				if (!$post_title_replace_count)
589
-					$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
602
+				if (!$post_title_replace_count) {
603
+									$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
604
+				}
590 605
 				$geodir_terms = explode('/', $geodir_term);
591 606
 				$geodir_last_term = end($geodir_terms);
592 607
 
@@ -622,8 +637,9 @@  discard block
 block discarded – undo
622 637
                     if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
623 638
                         geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
624 639
                         geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
625
-                    )
626
-                        $is_geodir_location_found = true;
640
+                    ) {
641
+                                            $is_geodir_location_found = true;
642
+                    }
627 643
 
628 644
                     // if location has not been found for country , region and city then search for country and region only
629 645
 
@@ -631,8 +647,9 @@  discard block
 block discarded – undo
631 647
                         $gd_city = '';
632 648
                         if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
633 649
                             geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
634
-                        )
635
-                            $is_geodir_location_found = true;
650
+                        ) {
651
+                                                    $is_geodir_location_found = true;
652
+                        }
636 653
 
637 654
                     }
638 655
 
@@ -640,8 +657,9 @@  discard block
 block discarded – undo
640 657
                     if (!$is_geodir_location_found) {
641 658
                         $gd_city = '';
642 659
                         $gd_region = '';
643
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
644
-                            $is_geodir_location_found = true;
660
+                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) {
661
+                                                    $is_geodir_location_found = true;
662
+                        }
645 663
                     }
646 664
                 } else if ($geodir_show_location_url == 'country_city') {
647 665
                     if (count($geodir_terms) >= 2) {
@@ -651,17 +669,19 @@  discard block
 block discarded – undo
651 669
                         $gd_country = urldecode($geodir_terms[0]);
652 670
                     }
653 671
 
654
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
655
-                        $is_geodir_location_found = true;
672
+                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
673
+                                            $is_geodir_location_found = true;
674
+                    }
656 675
 
657 676
                     // if location has not been found for country and city  then search for country only
658 677
                     if (!$is_geodir_location_found) {
659 678
                         $gd_city = '';
660 679
                         
661
-						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
662
-                            $is_geodir_location_found = true;
680
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) {
681
+						                            $is_geodir_location_found = true;
682
+						}
663 683
                     }
664
-                }  else if ($geodir_show_location_url == 'region_city') {
684
+                } else if ($geodir_show_location_url == 'region_city') {
665 685
                     if (count($geodir_terms) >= 2) {
666 686
                         $gd_region = urldecode($geodir_terms[0]);
667 687
                         $gd_city = urldecode($geodir_terms[1]);
@@ -669,15 +689,17 @@  discard block
 block discarded – undo
669 689
                         $gd_region = urldecode($geodir_terms[0]);
670 690
                     }
671 691
 
672
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
673
-                        $is_geodir_location_found = true;
692
+                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
693
+                                            $is_geodir_location_found = true;
694
+                    }
674 695
 
675 696
                     // if location has not been found for region and city  then search for region only
676 697
                     if (!$is_geodir_location_found) {
677 698
                         $gd_city = '';
678 699
                         
679
-						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
680
-                            $is_geodir_location_found = true;
700
+						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) {
701
+						                            $is_geodir_location_found = true;
702
+						}
681 703
                     }
682 704
                 } else {
683 705
                     $gd_city = $geodir_terms[0];
@@ -719,14 +741,17 @@  discard block
 block discarded – undo
719 741
 
720 742
             $wp->query_vars[$geodir_taxonomy] = $geodir_term;
721 743
             // eliminate location related terms from taxonomy term
722
-            if ($gd_country != '')
723
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
744
+            if ($gd_country != '') {
745
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
746
+            }
724 747
 
725
-            if ($gd_region != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
748
+            if ($gd_region != '') {
749
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
750
+            }
727 751
 
728
-            if ($gd_city != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
752
+            if ($gd_city != '') {
753
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
754
+            }
730 755
 
731 756
 
732 757
             $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
@@ -762,27 +787,34 @@  discard block
 block discarded – undo
762 787
     if (get_option('geodir_add_location_url')) {        
763 788
 		if ($geodir_show_location_url == 'all') {
764 789
 		} else if ($geodir_show_location_url == 'country_city') {
765
-			 if (isset($wp->query_vars['gd_region']))
766
-                $wp->query_vars['gd_region'] = '';
790
+			 if (isset($wp->query_vars['gd_region'])) {
791
+			                 $wp->query_vars['gd_region'] = '';
792
+			 }
767 793
 		} else if ($geodir_show_location_url == 'region_city') {
768
-			if (isset($wp->query_vars['gd_country']))
769
-                $wp->query_vars['gd_country'] = '';
794
+			if (isset($wp->query_vars['gd_country'])) {
795
+			                $wp->query_vars['gd_country'] = '';
796
+			}
770 797
 		} else {
771
-			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
798
+			if (isset($wp->query_vars['gd_country'])) {
799
+			                $wp->query_vars['gd_country'] = '';
800
+			}
773 801
 
774
-            if (isset($wp->query_vars['gd_region']))
775
-                $wp->query_vars['gd_region'] = '';
802
+            if (isset($wp->query_vars['gd_region'])) {
803
+                            $wp->query_vars['gd_region'] = '';
804
+            }
776 805
 		}
777 806
     } else {
778
-        if (isset($wp->query_vars['gd_country']))
779
-            $wp->query_vars['gd_country'] = '';
807
+        if (isset($wp->query_vars['gd_country'])) {
808
+                    $wp->query_vars['gd_country'] = '';
809
+        }
780 810
 
781
-        if (isset($wp->query_vars['gd_region']))
782
-            $wp->query_vars['gd_region'] = '';
811
+        if (isset($wp->query_vars['gd_region'])) {
812
+                    $wp->query_vars['gd_region'] = '';
813
+        }
783 814
 
784
-        if (isset($wp->query_vars['gd_city']))
785
-            $wp->query_vars['gd_city'] = '';
815
+        if (isset($wp->query_vars['gd_city'])) {
816
+                    $wp->query_vars['gd_city'] = '';
817
+        }
786 818
     }
787 819
 }
788 820
 
@@ -894,8 +926,9 @@  discard block
 block discarded – undo
894 926
 function geodir_exclude_page_where($where)
895 927
 {
896 928
     global $wpdb;
897
-    if (is_admin())
898
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
929
+    if (is_admin()) {
930
+            $where .= " AND $wpdb->posts.post_status != 'virtual'";
931
+    }
899 932
 
900 933
     return $where;
901 934
 }
Please login to merge, or discard this patch.
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function geodir_register_taxonomies()
15 15
 {
16
-    $taxonomies = array();
17
-    $taxonomies = get_option('geodir_taxonomies');
18
-    // If custom taxonomies are present, register them
19
-    if (is_array($taxonomies)) {
20
-        // Sort taxonomies
21
-        ksort($taxonomies);
22
-
23
-        // Register taxonomies
24
-        foreach ($taxonomies as $taxonomy => $args) {
25
-            // Allow taxonomie names to be translated
26
-            if (!empty($args['args']['labels'])) {
27
-                foreach ($args['args']['labels'] as $key => $tax_label) {
28
-                    $args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
-                }
30
-            }
31
-
32
-            $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
-
34
-            if (taxonomy_exists($taxonomy)) {
35
-                $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
-            }
37
-        }
38
-    }
16
+	$taxonomies = array();
17
+	$taxonomies = get_option('geodir_taxonomies');
18
+	// If custom taxonomies are present, register them
19
+	if (is_array($taxonomies)) {
20
+		// Sort taxonomies
21
+		ksort($taxonomies);
22
+
23
+		// Register taxonomies
24
+		foreach ($taxonomies as $taxonomy => $args) {
25
+			// Allow taxonomie names to be translated
26
+			if (!empty($args['args']['labels'])) {
27
+				foreach ($args['args']['labels'] as $key => $tax_label) {
28
+					$args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
+				}
30
+			}
31
+
32
+			$tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
+
34
+			if (taxonomy_exists($taxonomy)) {
35
+				$tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
+			}
37
+		}
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function geodir_register_post_types() 
55 55
 {
56
-    global $wp_post_types;
56
+	global $wp_post_types;
57 57
 
58
-    $post_types = array();
59
-    $post_types = get_option('geodir_post_types');
58
+	$post_types = array();
59
+	$post_types = get_option('geodir_post_types');
60 60
 
61
-    // Register each post type if array of data is returned
62
-    if (is_array($post_types)):
61
+	// Register each post type if array of data is returned
62
+	if (is_array($post_types)):
63 63
 
64
-        foreach ($post_types as $post_type => $args):
64
+		foreach ($post_types as $post_type => $args):
65 65
 
66
-            if (!empty($args['rewrite']['slug'])) {
67
-                $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
-            }
69
-            $args = stripslashes_deep($args);
66
+			if (!empty($args['rewrite']['slug'])) {
67
+				$args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
+			}
69
+			$args = stripslashes_deep($args);
70 70
 
71
-            if (!empty($args['labels'])) {
72
-                foreach ($args['labels'] as $key => $val) {
73
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
-                }
75
-            }
71
+			if (!empty($args['labels'])) {
72
+				foreach ($args['labels'] as $key => $val) {
73
+					$args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
+				}
75
+			}
76 76
 
77
-            /**
78
-             * Filter post type args.
79
-             *
80
-             * @since 1.0.0
81
-             * @param string $args Post type args.
82
-             * @param string $post_type The post type.
83
-             */
84
-            $args = apply_filters('geodir_post_type_args', $args, $post_type);
77
+			/**
78
+			 * Filter post type args.
79
+			 *
80
+			 * @since 1.0.0
81
+			 * @param string $args Post type args.
82
+			 * @param string $post_type The post type.
83
+			 */
84
+			$args = apply_filters('geodir_post_type_args', $args, $post_type);
85 85
 
86
-            $post_type = register_post_type($post_type, $args);
86
+			$post_type = register_post_type($post_type, $args);
87 87
 
88
-        endforeach;
89
-    endif;
88
+		endforeach;
89
+	endif;
90 90
 }
91 91
 
92 92
 /**
@@ -100,72 +100,72 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_post_type_args_modify($args, $post_type)
102 102
 {
103
-    $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
103
+	$geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
104 104
 	if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
105 105
 
106
-        $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
106
+		$listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
107 107
 
108
-        if ($post_type == 'gd_place') {
109
-            if (array_key_exists('has_archive', $args))
110
-                $args['has_archive'] = $listing_slug;
108
+		if ($post_type == 'gd_place') {
109
+			if (array_key_exists('has_archive', $args))
110
+				$args['has_archive'] = $listing_slug;
111 111
 
112
-            if (array_key_exists('rewrite', $args)) {
113
-                if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
-            }
112
+			if (array_key_exists('rewrite', $args)) {
113
+				if (array_key_exists('slug', $args['rewrite']))
114
+					$args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
+			}
116 116
 
117
-            $geodir_post_types = get_option('geodir_post_types');
117
+			$geodir_post_types = get_option('geodir_post_types');
118 118
 
119
-            if (array_key_exists($post_type, $geodir_post_types)) {
119
+			if (array_key_exists($post_type, $geodir_post_types)) {
120 120
 
121
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
121
+				if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
+					$geodir_post_types[$post_type]['has_archive'] = $listing_slug;
123 123
 
124
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
124
+				if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
+					if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
+						$geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
127 127
 
128
-                update_option('geodir_post_types', $geodir_post_types);
128
+				update_option('geodir_post_types', $geodir_post_types);
129 129
 
130
-            }
130
+			}
131 131
 
132
-            $geodir_post_types = get_option('geodir_post_types');
132
+			$geodir_post_types = get_option('geodir_post_types');
133 133
 
134
-            /* --- update taxonomies (category) --- */
134
+			/* --- update taxonomies (category) --- */
135 135
 
136
-            $geodir_taxonomies = get_option('geodir_taxonomies');
136
+			$geodir_taxonomies = get_option('geodir_taxonomies');
137 137
 
138
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
138
+			if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
+				$geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
140 140
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
141
+				if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
+					if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
+						if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
+							$geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
145 145
 
146
-                update_option('geodir_taxonomies', $geodir_taxonomies);
146
+				update_option('geodir_taxonomies', $geodir_taxonomies);
147 147
 
148
-            }
148
+			}
149 149
 
150
-            /* --- update taxonomies (tags) --- */
151
-            $geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
150
+			/* --- update taxonomies (tags) --- */
151
+			$geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
+			if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
+				$geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
154 154
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
155
+				if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
+					if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
+						if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
+							$geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
159 159
 
160
-                update_option('geodir_taxonomies', $geodir_taxonomies_tag);
160
+				update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 161
 
162
-            }
162
+			}
163 163
 
164
-        }
164
+		}
165 165
 
166
-    }
166
+	}
167 167
 
168
-    return $args;
168
+	return $args;
169 169
 }
170 170
 
171 171
 /**
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function geodir_flush_rewrite_rules()
180 180
 {
181
-    global $wp_rewrite;
182
-    $wp_rewrite->flush_rules(false);
181
+	global $wp_rewrite;
182
+	$wp_rewrite->flush_rules(false);
183 183
 }
184 184
 
185 185
 /**
@@ -194,35 +194,35 @@  discard block
 block discarded – undo
194 194
  * @return array Rewrite rules.
195 195
  */
196 196
 function geodir_listing_rewrite_rules($rules) {
197
-    $newrules = array();
198
-    $taxonomies = get_option('geodir_taxonomies');
199
-    $detail_url_seprator = get_option('geodir_detailurl_separator');
197
+	$newrules = array();
198
+	$taxonomies = get_option('geodir_taxonomies');
199
+	$detail_url_seprator = get_option('geodir_detailurl_separator');
200 200
     
201 201
 	// create rules for post listing
202
-    if (is_array($taxonomies)):
203
-        foreach ($taxonomies as $taxonomy => $args):
204
-            $post_type = $args['object_type'];
205
-            $listing_slug = $args['listing_slug'];
206
-
207
-            if (strpos($taxonomy, 'tags')) {
208
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
-            } else {
211
-                // use this loop to add paging for details page comments paging
212
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
-            }
214
-        endforeach;
215
-    endif;
216
-
217
-    // create rules for location listing
218
-    $location_page = get_option('geodir_location_page');
202
+	if (is_array($taxonomies)):
203
+		foreach ($taxonomies as $taxonomy => $args):
204
+			$post_type = $args['object_type'];
205
+			$listing_slug = $args['listing_slug'];
206
+
207
+			if (strpos($taxonomy, 'tags')) {
208
+				$newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
+				$newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
+			} else {
211
+				// use this loop to add paging for details page comments paging
212
+				$newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
+			}
214
+		endforeach;
215
+	endif;
216
+
217
+	// create rules for location listing
218
+	$location_page = get_option('geodir_location_page');
219 219
 	
220
-    if($location_page) {
221
-        global $wpdb;
222
-        $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
-    }
224
-    if (!isset($location_prefix))
225
-        $location_prefix = 'location';
220
+	if($location_page) {
221
+		global $wpdb;
222
+		$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
+	}
224
+	if (!isset($location_prefix))
225
+		$location_prefix = 'location';
226 226
 
227 227
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
228 228
 	if ($location_manager) {
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
267 267
 	}
268 268
 
269
-    if ($location_page && function_exists('icl_object_id')) {
270
-        foreach(icl_get_languages('skip_missing=N') as $lang){
271
-            $alt_page_id = '';
272
-            $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
-            if($alt_page_id){
274
-                $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
269
+	if ($location_page && function_exists('icl_object_id')) {
270
+		foreach(icl_get_languages('skip_missing=N') as $lang){
271
+			$alt_page_id = '';
272
+			$alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
+			if($alt_page_id){
274
+				$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
275 275
 
276 276
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
277 277
 					$matches2 = '';
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
308 308
 					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
309 309
 				}
310
-            }
311
-        }
312
-    }
310
+			}
311
+		}
312
+	}
313 313
 
314
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
314
+	$newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
315 315
 
316
-    $rules = array_merge($newrules, $rules);
317
-    return $rules;
316
+	$rules = array_merge($newrules, $rules);
317
+	return $rules;
318 318
 }
319 319
 
320 320
 /**
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
  */
330 330
 function geodir_htaccess_contents($rules)
331 331
 {
332
-    global $wpdb;
333
-    $location_prefix = get_option('geodir_location_prefix');
334
-    // if location page slug changed then add redirect
335
-    if ($location_prefix == 'location') {
336
-        return $rules;
337
-    }
338
-    $my_content = <<<EOD
332
+	global $wpdb;
333
+	$location_prefix = get_option('geodir_location_prefix');
334
+	// if location page slug changed then add redirect
335
+	if ($location_prefix == 'location') {
336
+		return $rules;
337
+	}
338
+	$my_content = <<<EOD
339 339
 \n# BEGIN GeoDirectory Rules
340 340
 #Redirect 301 /location/ /$location_prefix/
341 341
 # END GeoDirectory Rules\n\n
342 342
 EOD;
343
-    return $my_content . $rules;
343
+	return $my_content . $rules;
344 344
 }
345 345
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
346 346
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function geodir_add_location_var($public_query_vars)
356 356
 {
357
-    $public_query_vars[] = 'gd_country';
358
-    $public_query_vars[] = 'gd_region';
359
-    $public_query_vars[] = 'gd_city';
360
-    return $public_query_vars;
357
+	$public_query_vars[] = 'gd_country';
358
+	$public_query_vars[] = 'gd_region';
359
+	$public_query_vars[] = 'gd_city';
360
+	return $public_query_vars;
361 361
 }
362 362
 
363 363
 /**
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
  */
371 371
 function geodir_add_geodir_page_var($public_query_vars)
372 372
 {
373
-    $public_query_vars[] = 'gd_is_geodir_page';
374
-    return $public_query_vars;
373
+	$public_query_vars[] = 'gd_is_geodir_page';
374
+	return $public_query_vars;
375 375
 }
376 376
 
377 377
 /**
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
  */
384 384
 function geodir_add_page_id_in_query_var()
385 385
 {
386
-    global $wp_query;
386
+	global $wp_query;
387 387
 
388
-    $page_id = $wp_query->get_queried_object_id();
388
+	$page_id = $wp_query->get_queried_object_id();
389 389
 
390
-    if (!get_query_var('page_id')) {
391
-        // fix for WP tags conflict with enfold theme
392
-        $theme_name = geodir_strtolower(wp_get_theme());
393
-        if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
-            return $wp_query;
395
-        }
396
-        $wp_query->set('page_id', $page_id);
397
-    }
390
+	if (!get_query_var('page_id')) {
391
+		// fix for WP tags conflict with enfold theme
392
+		$theme_name = geodir_strtolower(wp_get_theme());
393
+		if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
+			return $wp_query;
395
+		}
396
+		$wp_query->set('page_id', $page_id);
397
+	}
398 398
 
399
-    return $wp_query;
399
+	return $wp_query;
400 400
 }
401 401
 
402 402
 /**
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
 function geodir_set_location_var_in_session_in_core($wp) {
412 412
 	global $gd_session;
413 413
 	
414
-    // Fix for WPML removing page_id query var:
415
-    if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
-        global $wpdb;
417
-
418
-        $page_for_posts = get_option('page_for_posts');
419
-        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
-
421
-        if (function_exists('icl_object_id')) {
422
-            $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
-        }
424
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
425
-            $wp->query_vars['page_id'] = $real_page_id;
426
-        }
427
-    }
414
+	// Fix for WPML removing page_id query var:
415
+	if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
+		global $wpdb;
417
+
418
+		$page_for_posts = get_option('page_for_posts');
419
+		$real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
+
421
+		if (function_exists('icl_object_id')) {
422
+			$real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
+		}
424
+		if ($real_page_id && $real_page_id!=$page_for_posts) {
425
+			$wp->query_vars['page_id'] = $real_page_id;
426
+		}
427
+	}
428 428
 	
429 429
 	// Query Vars will have page_id parameter
430 430
 	// check if query var has page_id and that page id is location page
431
-    geodir_set_is_geodir_page($wp);
431
+	geodir_set_is_geodir_page($wp);
432 432
 	// if is GD homepage set the page ID
433 433
 	if (geodir_is_page('home')) {
434 434
 		$wp->query_vars['page_id'] = get_option('page_on_front');
@@ -437,118 +437,118 @@  discard block
 block discarded – undo
437 437
 	// The location url format (all or country_city or region_city or city).
438 438
 	$geodir_show_location_url = get_option('geodir_show_location_url');
439 439
 
440
-    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
-        $gd_country = '';
442
-        $gd_region = '';
443
-        $gd_city = '';
444
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
-            $gd_country = urldecode($wp->query_vars['gd_country']);
446
-
447
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
-            $gd_region = urldecode($wp->query_vars['gd_region']);
449
-
450
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
-            $gd_city = urldecode($wp->query_vars['gd_city']);
452
-
453
-        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
-            $default_location = geodir_get_default_location();
455
-
456
-            if (get_option('geodir_add_location_url')) {
457
-                if ($geodir_show_location_url != 'all') {
458
-                    if ($gd_region == '') {
459
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
460
-                            $gd_region = $gd_ses_region;
461
-                        else
462
-                            $gd_region = $default_location->region_slug;
463
-                    }
464
-
465
-                    if ($gd_city == '') {
466
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
467
-                            $gd_city = $gd_ses_city;
468
-                        else
469
-                            $gd_city = $default_location->city_slug;
470
-
471
-                        $base_location_link = geodir_get_location_link('base');
472
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
-                        exit();
474
-                    }
475
-                }
476
-            }
477
-
478
-            $args = array(
479
-                'what' => 'city',
480
-                'city_val' => $gd_city,
481
-                'region_val' => $gd_region,
482
-                'country_val' => $gd_country,
483
-                'country_column_name' => 'country_slug',
484
-                'region_column_name' => 'region_slug',
485
-                'city_column_name' => 'city_slug',
486
-                'location_link_part' => false,
487
-                'compare_operator' => ''
488
-            );
489
-
490
-            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
-            if (!empty($location_array)) {
492
-                $gd_session->set('gd_multi_location', 1);
493
-                $gd_session->set('gd_country', $gd_country);
494
-                $gd_session->set('gd_region', $gd_region);
495
-                $gd_session->set('gd_city', $gd_city);
440
+	if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
+		$gd_country = '';
442
+		$gd_region = '';
443
+		$gd_city = '';
444
+		if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
+			$gd_country = urldecode($wp->query_vars['gd_country']);
446
+
447
+		if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
+			$gd_region = urldecode($wp->query_vars['gd_region']);
449
+
450
+		if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
+			$gd_city = urldecode($wp->query_vars['gd_city']);
452
+
453
+		if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
+			$default_location = geodir_get_default_location();
455
+
456
+			if (get_option('geodir_add_location_url')) {
457
+				if ($geodir_show_location_url != 'all') {
458
+					if ($gd_region == '') {
459
+						if ($gd_ses_region = $gd_session->get('gd_region'))
460
+							$gd_region = $gd_ses_region;
461
+						else
462
+							$gd_region = $default_location->region_slug;
463
+					}
464
+
465
+					if ($gd_city == '') {
466
+						if ($gd_ses_city = $gd_session->get('gd_city'))
467
+							$gd_city = $gd_ses_city;
468
+						else
469
+							$gd_city = $default_location->city_slug;
470
+
471
+						$base_location_link = geodir_get_location_link('base');
472
+						wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
+						exit();
474
+					}
475
+				}
476
+			}
477
+
478
+			$args = array(
479
+				'what' => 'city',
480
+				'city_val' => $gd_city,
481
+				'region_val' => $gd_region,
482
+				'country_val' => $gd_country,
483
+				'country_column_name' => 'country_slug',
484
+				'region_column_name' => 'region_slug',
485
+				'city_column_name' => 'city_slug',
486
+				'location_link_part' => false,
487
+				'compare_operator' => ''
488
+			);
489
+
490
+			$location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
+			if (!empty($location_array)) {
492
+				$gd_session->set('gd_multi_location', 1);
493
+				$gd_session->set('gd_country', $gd_country);
494
+				$gd_session->set('gd_region', $gd_region);
495
+				$gd_session->set('gd_city', $gd_city);
496 496
                 
497 497
 				$wp->query_vars['gd_country'] = $gd_country;
498
-                $wp->query_vars['gd_region'] = $gd_region;
499
-                $wp->query_vars['gd_city'] = $gd_city;
500
-            } else {
501
-                $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
-            }
503
-        } else {
504
-            $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
-        }
506
-
507
-    } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
-        if (!is_admin()) {
509
-            $requested_post_type = $wp->query_vars['post_type'];
510
-            // check if this post type is geodirectory post types
511
-            $post_type_array = geodir_get_posttypes();
498
+				$wp->query_vars['gd_region'] = $gd_region;
499
+				$wp->query_vars['gd_city'] = $gd_city;
500
+			} else {
501
+				$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
+			}
503
+		} else {
504
+			$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
+		}
506
+
507
+	} else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
+		if (!is_admin()) {
509
+			$requested_post_type = $wp->query_vars['post_type'];
510
+			// check if this post type is geodirectory post types
511
+			$post_type_array = geodir_get_posttypes();
512 512
             
513 513
 			if (in_array($requested_post_type, $post_type_array)) {
514
-                // now u can apply geodirectory related manipulation.
515
-            }
516
-        }
517
-    } else {
518
-        // check if a geodirectory taxonomy is set
519
-        $gd_country = '';
520
-        $gd_region = '';
521
-        $gd_city = '';
514
+				// now u can apply geodirectory related manipulation.
515
+			}
516
+		}
517
+	} else {
518
+		// check if a geodirectory taxonomy is set
519
+		$gd_country = '';
520
+		$gd_region = '';
521
+		$gd_city = '';
522 522
         
523 523
 		$is_geodir_taxonomy = false;
524
-        $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
-        $is_geodir_location_found = false;
524
+		$is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
+		$is_geodir_location_found = false;
526 526
 		
527 527
 		$geodir_taxonomy = '';
528
-        $geodir_post_type = '';
529
-        $geodir_term = '';
530
-        $geodir_set_location_session = true;
531
-        $geodir_taxonomis = geodir_get_taxonomies('', true);
532
-
533
-        if(!empty($geodir_taxonomis)){
534
-            foreach ($geodir_taxonomis as $taxonomy) {
535
-                if (array_key_exists($taxonomy, $wp->query_vars)) {
536
-                    $is_geodir_taxonomy = true;
537
-                    $geodir_taxonomy = $taxonomy;
538
-                    $geodir_post_type = str_replace('category', '', $taxonomy);
539
-                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
-                    $geodir_term = $wp->query_vars[$geodir_taxonomy];
541
-                    break;
542
-                }
543
-            }
544
-        }
545
-
546
-        // now get an array of all terms seperated by '/'
547
-        $geodir_terms = explode('/', $geodir_term);
548
-        $geodir_last_term = end($geodir_terms);
549
-
550
-        if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
-            $wp->query_vars['post_type'] = $geodir_post_type;
528
+		$geodir_post_type = '';
529
+		$geodir_term = '';
530
+		$geodir_set_location_session = true;
531
+		$geodir_taxonomis = geodir_get_taxonomies('', true);
532
+
533
+		if(!empty($geodir_taxonomis)){
534
+			foreach ($geodir_taxonomis as $taxonomy) {
535
+				if (array_key_exists($taxonomy, $wp->query_vars)) {
536
+					$is_geodir_taxonomy = true;
537
+					$geodir_taxonomy = $taxonomy;
538
+					$geodir_post_type = str_replace('category', '', $taxonomy);
539
+					$geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
+					$geodir_term = $wp->query_vars[$geodir_taxonomy];
541
+					break;
542
+				}
543
+			}
544
+		}
545
+
546
+		// now get an array of all terms seperated by '/'
547
+		$geodir_terms = explode('/', $geodir_term);
548
+		$geodir_last_term = end($geodir_terms);
549
+
550
+		if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
+			$wp->query_vars['post_type'] = $geodir_post_type;
552 552
 
553 553
 			// now check if last term is a post of geodirectory post types
554 554
 			$geodir_post = get_posts(array(
@@ -597,196 +597,196 @@  discard block
 block discarded – undo
597 597
 				//return ;
598 598
 			}
599 599
 
600
-            $geodir_location_terms = '';
601
-            // if last term is not a post then check if last term is a term of the specific texonomy or not
602
-            if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
-                $is_geodir_taxonomy_term = true;
600
+			$geodir_location_terms = '';
601
+			// if last term is not a post then check if last term is a term of the specific texonomy or not
602
+			if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
+				$is_geodir_taxonomy_term = true;
604 604
 
605
-                $geodir_set_location_session = false;
606
-            }
605
+				$geodir_set_location_session = false;
606
+			}
607 607
 
608 608
 
609
-            // now check if there is location parts in the url or not
610
-            if (get_option('geodir_add_location_url')) {				
609
+			// now check if there is location parts in the url or not
610
+			if (get_option('geodir_add_location_url')) {				
611 611
 				$default_location = geodir_get_default_location();
612 612
                 
613 613
 				if ($geodir_show_location_url == 'all') {
614
-                    if (count($geodir_terms) >= 3) {
615
-                        $gd_country = urldecode($geodir_terms[0]);
616
-                        $gd_region = urldecode($geodir_terms[1]);
617
-                        $gd_city = urldecode($geodir_terms[2]);
618
-                    } else if (count($geodir_terms) >= 2) {
619
-                        $gd_country = urldecode($geodir_terms[0]);
620
-                        $gd_region = urldecode($geodir_terms[1]);
621
-                    } else if (count($geodir_terms) >= 1) {
622
-                        $gd_country = urldecode($geodir_terms[0]);
623
-                    }
624
-
625
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
-                        geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
-                        geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
-                    )
629
-                        $is_geodir_location_found = true;
630
-
631
-                    // if location has not been found for country , region and city then search for country and region only
632
-
633
-                    if (!$is_geodir_location_found) {
634
-                        $gd_city = '';
635
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
-                            geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
-                        )
638
-                            $is_geodir_location_found = true;
639
-
640
-                    }
641
-
642
-                    // if location has not been found for country , region  then search for country only
643
-                    if (!$is_geodir_location_found) {
644
-                        $gd_city = '';
645
-                        $gd_region = '';
646
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
-                            $is_geodir_location_found = true;
648
-                    }
649
-                } else if ($geodir_show_location_url == 'country_city') {
650
-                    if (count($geodir_terms) >= 2) {
651
-                        $gd_country = urldecode($geodir_terms[0]);
652
-                        $gd_city = urldecode($geodir_terms[1]);
653
-                    } else if (count($geodir_terms) >= 1) {
654
-                        $gd_country = urldecode($geodir_terms[0]);
655
-                    }
656
-
657
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
-                        $is_geodir_location_found = true;
659
-
660
-                    // if location has not been found for country and city  then search for country only
661
-                    if (!$is_geodir_location_found) {
662
-                        $gd_city = '';
614
+					if (count($geodir_terms) >= 3) {
615
+						$gd_country = urldecode($geodir_terms[0]);
616
+						$gd_region = urldecode($geodir_terms[1]);
617
+						$gd_city = urldecode($geodir_terms[2]);
618
+					} else if (count($geodir_terms) >= 2) {
619
+						$gd_country = urldecode($geodir_terms[0]);
620
+						$gd_region = urldecode($geodir_terms[1]);
621
+					} else if (count($geodir_terms) >= 1) {
622
+						$gd_country = urldecode($geodir_terms[0]);
623
+					}
624
+
625
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
+						geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
+						geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
+					)
629
+						$is_geodir_location_found = true;
630
+
631
+					// if location has not been found for country , region and city then search for country and region only
632
+
633
+					if (!$is_geodir_location_found) {
634
+						$gd_city = '';
635
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
+							geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
+						)
638
+							$is_geodir_location_found = true;
639
+
640
+					}
641
+
642
+					// if location has not been found for country , region  then search for country only
643
+					if (!$is_geodir_location_found) {
644
+						$gd_city = '';
645
+						$gd_region = '';
646
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
+							$is_geodir_location_found = true;
648
+					}
649
+				} else if ($geodir_show_location_url == 'country_city') {
650
+					if (count($geodir_terms) >= 2) {
651
+						$gd_country = urldecode($geodir_terms[0]);
652
+						$gd_city = urldecode($geodir_terms[1]);
653
+					} else if (count($geodir_terms) >= 1) {
654
+						$gd_country = urldecode($geodir_terms[0]);
655
+					}
656
+
657
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
+						$is_geodir_location_found = true;
659
+
660
+					// if location has not been found for country and city  then search for country only
661
+					if (!$is_geodir_location_found) {
662
+						$gd_city = '';
663 663
                         
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665
-                            $is_geodir_location_found = true;
666
-                    }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
668
-                    if (count($geodir_terms) >= 2) {
669
-                        $gd_region = urldecode($geodir_terms[0]);
670
-                        $gd_city = urldecode($geodir_terms[1]);
671
-                    } else if (count($geodir_terms) >= 1) {
672
-                        $gd_region = urldecode($geodir_terms[0]);
673
-                    }
674
-
675
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
-                        $is_geodir_location_found = true;
677
-
678
-                    // if location has not been found for region and city  then search for region only
679
-                    if (!$is_geodir_location_found) {
680
-                        $gd_city = '';
665
+							$is_geodir_location_found = true;
666
+					}
667
+				}  else if ($geodir_show_location_url == 'region_city') {
668
+					if (count($geodir_terms) >= 2) {
669
+						$gd_region = urldecode($geodir_terms[0]);
670
+						$gd_city = urldecode($geodir_terms[1]);
671
+					} else if (count($geodir_terms) >= 1) {
672
+						$gd_region = urldecode($geodir_terms[0]);
673
+					}
674
+
675
+					if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
+						$is_geodir_location_found = true;
677
+
678
+					// if location has not been found for region and city  then search for region only
679
+					if (!$is_geodir_location_found) {
680
+						$gd_city = '';
681 681
                         
682 682
 						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
683
-                            $is_geodir_location_found = true;
684
-                    }
685
-                } else {
686
-                    $gd_city = $geodir_terms[0];
687
-
688
-                    if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
-                        $is_geodir_location_found = true;
690
-                        $gd_region = $default_location->region_slug;
691
-                        $gd_country = $default_location->country_slug;
692
-                    }
693
-                }
694
-                // if locaton still not found then clear location related session variables
695
-                if ($is_geodir_location_found && $geodir_set_location_session) {
696
-                    $gd_session->set('gd_multi_location', 1);
697
-                    $gd_session->set('gd_country', $gd_country);
698
-                    $gd_session->set('gd_region', $gd_region);
699
-                    $gd_session->set('gd_city', $gd_city);
700
-                }
701
-
702
-                if ($geodir_show_location_url == 'all') {
683
+							$is_geodir_location_found = true;
684
+					}
685
+				} else {
686
+					$gd_city = $geodir_terms[0];
687
+
688
+					if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
+						$is_geodir_location_found = true;
690
+						$gd_region = $default_location->region_slug;
691
+						$gd_country = $default_location->country_slug;
692
+					}
693
+				}
694
+				// if locaton still not found then clear location related session variables
695
+				if ($is_geodir_location_found && $geodir_set_location_session) {
696
+					$gd_session->set('gd_multi_location', 1);
697
+					$gd_session->set('gd_country', $gd_country);
698
+					$gd_session->set('gd_region', $gd_region);
699
+					$gd_session->set('gd_city', $gd_city);
700
+				}
701
+
702
+				if ($geodir_show_location_url == 'all') {
703 703
 				} else if ($geodir_show_location_url == 'country_city') {
704 704
 					$gd_region = '';
705 705
 				} else if ($geodir_show_location_url == 'region_city') {
706 706
 					$gd_country = '';
707 707
 				} else {
708 708
 					$gd_country = '';
709
-                    $gd_region = '';
709
+					$gd_region = '';
710
+				}
711
+
712
+				if ($is_geodir_location_found) {
713
+					$wp->query_vars['gd_country'] = $gd_country;
714
+					$wp->query_vars['gd_region'] = $gd_region;
715
+					$wp->query_vars['gd_city'] = $gd_city;
716
+				} else {
717
+					$gd_country = '';
718
+					$gd_region = '';
719
+					$gd_city = '';
710 720
 				}
721
+			}
722
+
723
+			$wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
+			// eliminate location related terms from taxonomy term
725
+			if ($gd_country != '')
726
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
+
728
+			if ($gd_region != '')
729
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
+
731
+			if ($gd_city != '')
732
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
+
734
+
735
+			$wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
+			$wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
711 737
 
712
-                if ($is_geodir_location_found) {
713
-                    $wp->query_vars['gd_country'] = $gd_country;
714
-                    $wp->query_vars['gd_region'] = $gd_region;
715
-                    $wp->query_vars['gd_city'] = $gd_city;
716
-                } else {
717
-                    $gd_country = '';
718
-                    $gd_region = '';
719
-                    $gd_city = '';
720
-                }
721
-            }
722
-
723
-            $wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
-            // eliminate location related terms from taxonomy term
725
-            if ($gd_country != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
-
728
-            if ($gd_region != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
-
731
-            if ($gd_city != '')
732
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
-
734
-
735
-            $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
-            $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
737
-
738
-            $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
-
740
-            if ($wp->query_vars[$geodir_taxonomy] == '') {
741
-                unset($wp->query_vars[$geodir_taxonomy]);
742
-            } else {
743
-                if (!$is_geodir_taxonomy_term) {
744
-                    foreach ($wp->query_vars as $key => $vars) {
745
-                        unset($wp->query_vars[$key]);
746
-                    }
747
-                    $wp->query_vars['error'] = '404';
748
-                }
749
-            }
750
-        }
751
-    }
738
+			$wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
+
740
+			if ($wp->query_vars[$geodir_taxonomy] == '') {
741
+				unset($wp->query_vars[$geodir_taxonomy]);
742
+			} else {
743
+				if (!$is_geodir_taxonomy_term) {
744
+					foreach ($wp->query_vars as $key => $vars) {
745
+						unset($wp->query_vars[$key]);
746
+					}
747
+					$wp->query_vars['error'] = '404';
748
+				}
749
+			}
750
+		}
751
+	}
752 752
 	
753 753
 	// Unset location session if gd page and location not set.
754 754
 	if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
755 755
 		$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
756 756
 	}
757 757
 
758
-    if ($gd_session->get('gd_multi_location') == 1) {
759
-        $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
-        $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
-        $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
-    }
758
+	if ($gd_session->get('gd_multi_location') == 1) {
759
+		$wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
+		$wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
+		$wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
+	}
763 763
 
764
-    // now check if there is location parts in the url or not
765
-    if (get_option('geodir_add_location_url')) {        
764
+	// now check if there is location parts in the url or not
765
+	if (get_option('geodir_add_location_url')) {        
766 766
 		if ($geodir_show_location_url == 'all') {
767 767
 		} else if ($geodir_show_location_url == 'country_city') {
768 768
 			 if (isset($wp->query_vars['gd_region']))
769
-                $wp->query_vars['gd_region'] = '';
769
+				$wp->query_vars['gd_region'] = '';
770 770
 		} else if ($geodir_show_location_url == 'region_city') {
771 771
 			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
772
+				$wp->query_vars['gd_country'] = '';
773 773
 		} else {
774 774
 			if (isset($wp->query_vars['gd_country']))
775
-                $wp->query_vars['gd_country'] = '';
775
+				$wp->query_vars['gd_country'] = '';
776 776
 
777
-            if (isset($wp->query_vars['gd_region']))
778
-                $wp->query_vars['gd_region'] = '';
777
+			if (isset($wp->query_vars['gd_region']))
778
+				$wp->query_vars['gd_region'] = '';
779 779
 		}
780
-    } else {
781
-        if (isset($wp->query_vars['gd_country']))
782
-            $wp->query_vars['gd_country'] = '';
780
+	} else {
781
+		if (isset($wp->query_vars['gd_country']))
782
+			$wp->query_vars['gd_country'] = '';
783 783
 
784
-        if (isset($wp->query_vars['gd_region']))
785
-            $wp->query_vars['gd_region'] = '';
784
+		if (isset($wp->query_vars['gd_region']))
785
+			$wp->query_vars['gd_region'] = '';
786 786
 
787
-        if (isset($wp->query_vars['gd_city']))
788
-            $wp->query_vars['gd_city'] = '';
789
-    }
787
+		if (isset($wp->query_vars['gd_city']))
788
+			$wp->query_vars['gd_city'] = '';
789
+	}
790 790
 }
791 791
 
792 792
 /**
@@ -800,24 +800,24 @@  discard block
 block discarded – undo
800 800
  */
801 801
 function geodir_custom_post_status()
802 802
 {
803
-    // Vertual Page Status
804
-    register_post_status('virtual', array(
805
-        'label' => _x('Virtual', 'page', 'geodirectory'),
806
-        'public' => true,
807
-        'exclude_from_search' => true,
808
-        'show_in_admin_all_list' => true,
809
-        'show_in_admin_status_list' => true,
810
-        'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
-    ));
812
-
813
-    /**
814
-     * Called after we register the custom post status 'Virtual'.
815
-     *
816
-     * Can be use to add more post statuses.
817
-     *
818
-     * @since 1.0.0
819
-     */
820
-    do_action('geodir_custom_post_status');
803
+	// Vertual Page Status
804
+	register_post_status('virtual', array(
805
+		'label' => _x('Virtual', 'page', 'geodirectory'),
806
+		'public' => true,
807
+		'exclude_from_search' => true,
808
+		'show_in_admin_all_list' => true,
809
+		'show_in_admin_status_list' => true,
810
+		'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
+	));
812
+
813
+	/**
814
+	 * Called after we register the custom post status 'Virtual'.
815
+	 *
816
+	 * Can be use to add more post statuses.
817
+	 *
818
+	 * @since 1.0.0
819
+	 */
820
+	do_action('geodir_custom_post_status');
821 821
 }
822 822
 
823 823
 /**
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
  */
833 833
 function geodir_get_term_link($termlink, $term, $taxonomy)
834 834
 {
835
-    return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
835
+	return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
836 836
 }
837 837
 
838 838
 /**
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
  */
847 847
 function geodir_get_posttype_link($link, $post_type)
848 848
 {
849
-    return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
849
+	return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
850 850
 }
851 851
 
852 852
 /**
@@ -861,13 +861,13 @@  discard block
 block discarded – undo
861 861
  */
862 862
 function exclude_from_wp_list_pages($exclude_array)
863 863
 {
864
-    $pages_ids = array();
865
-    $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
-    foreach ($pages_array as $page) {
867
-        $pages_ids[] = $page->ID;
868
-    }
869
-    $exclude_array = $exclude_array + $pages_ids;
870
-    return $exclude_array;
864
+	$pages_ids = array();
865
+	$pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
+	foreach ($pages_array as $page) {
867
+		$pages_ids[] = $page->ID;
868
+	}
869
+	$exclude_array = $exclude_array + $pages_ids;
870
+	return $exclude_array;
871 871
 }
872 872
 
873 873
 /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
  */
881 881
 function geodir_exclude_page($query)
882 882
 {
883
-    add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
-    return $query;
883
+	add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
+	return $query;
885 885
 }
886 886
 
887 887
 /**
@@ -896,9 +896,9 @@  discard block
 block discarded – undo
896 896
  */
897 897
 function geodir_exclude_page_where($where)
898 898
 {
899
-    global $wpdb;
900
-    if (is_admin())
901
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
899
+	global $wpdb;
900
+	if (is_admin())
901
+		$where .= " AND $wpdb->posts.post_status != 'virtual'";
902 902
 
903
-    return $where;
903
+	return $where;
904 904
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
             if (!empty($args['labels'])) {
72 72
                 foreach ($args['labels'] as $key => $val) {
73
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
73
+                    $args['labels'][$key] = __($val, 'geodirectory'); // allow translation
74 74
                 }
75 75
             }
76 76
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
             if (array_key_exists('rewrite', $args)) {
113 113
                 if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
114
+                    $args['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
115 115
             }
116 116
 
117 117
             $geodir_post_types = get_option('geodir_post_types');
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
                 if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125 125
                     if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
126
+                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
127 127
 
128 128
                 update_option('geodir_post_types', $geodir_post_types);
129 129
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                 $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210 210
             } else {
211 211
                 // use this loop to add paging for details page comments paging
212
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
212
+                $newrules[str_replace("/tags", "", $listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213 213
             }
214 214
         endforeach;
215 215
     endif;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     // create rules for location listing
218 218
     $location_page = get_option('geodir_location_page');
219 219
 	
220
-    if($location_page) {
220
+    if ($location_page) {
221 221
         global $wpdb;
222 222
         $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223 223
     }
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	}
268 268
 
269 269
     if ($location_page && function_exists('icl_object_id')) {
270
-        foreach(icl_get_languages('skip_missing=N') as $lang){
270
+        foreach (icl_get_languages('skip_missing=N') as $lang) {
271 271
             $alt_page_id = '';
272
-            $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
-            if($alt_page_id){
272
+            $alt_page_id = icl_object_id($location_page, 'page', false, $lang['language_code']);
273
+            if ($alt_page_id) {
274 274
                 $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
275 275
 
276 276
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
         global $wpdb;
417 417
 
418 418
         $page_for_posts = get_option('page_for_posts');
419
-        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
419
+        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename']));
420 420
 
421 421
         if (function_exists('icl_object_id')) {
422 422
             $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423 423
         }
424
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
424
+        if ($real_page_id && $real_page_id != $page_for_posts) {
425 425
             $wp->query_vars['page_id'] = $real_page_id;
426 426
         }
427 427
     }
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
         $geodir_set_location_session = true;
531 531
         $geodir_taxonomis = geodir_get_taxonomies('', true);
532 532
 
533
-        if(!empty($geodir_taxonomis)){
533
+        if (!empty($geodir_taxonomis)) {
534 534
             foreach ($geodir_taxonomis as $taxonomy) {
535 535
                 if (array_key_exists($taxonomy, $wp->query_vars)) {
536 536
                     $is_geodir_taxonomy = true;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665 665
                             $is_geodir_location_found = true;
666 666
                     }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
667
+                } else if ($geodir_show_location_url == 'region_city') {
668 668
                     if (count($geodir_terms) >= 2) {
669 669
                         $gd_region = urldecode($geodir_terms[0]);
670 670
                         $gd_city = urldecode($geodir_terms[1]);
Please login to merge, or discard this patch.
geodirectory-functions/general_functions.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
  * @global string $plugin_prefix Geodirectory plugin table prefix.
1733 1733
  * @global string $table_prefix WordPress Database Table prefix.
1734 1734
  * @param array $query_args The query array.
1735
- * @param  int|bool $count_only If true returns listings count only, otherwise returns array
1735
+ * @param  boolean $count_only If true returns listings count only, otherwise returns array
1736 1736
  * @return mixed Result object.
1737 1737
  */
1738 1738
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
  *
3265 3265
  * @since 1.0.0
3266 3266
  * @package GeoDirectory
3267
- * @return bool
3267
+ * @return null|boolean
3268 3268
  */
3269 3269
 function geodir_term_review_count_force_update($new_status, $old_status='', $post='')
3270 3270
 {
Please login to merge, or discard this patch.
Braces   +271 added lines, -190 removed lines patch added patch discarded remove patch
@@ -30,8 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
     if (is_ssl()) :
32 32
         return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
-    else :
34
-        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
+    else {
34
+    	:
35
+        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
36
+    }
35 37
     endif;
36 38
 }
37 39
 
@@ -63,7 +65,9 @@  discard block
 block discarded – undo
63 65
 {
64 66
     $active_plugins = get_option('active_plugins');
65 67
     foreach ($active_plugins as $key => $active_plugin) {
66
-        if (strstr($active_plugin, $plugin)) return true;
68
+        if (strstr($active_plugin, $plugin)) {
69
+        	return true;
70
+        }
67 71
     }
68 72
     return false;
69 73
 }
@@ -114,12 +118,25 @@  discard block
 block discarded – undo
114 118
  */
115 119
 function geodir_getlink($url, $params = array(), $use_existing_arguments = false)
116 120
 {
117
-    if ($use_existing_arguments) $params = $params + $_GET;
118
-    if (!$params) return $url;
121
+    if ($use_existing_arguments) {
122
+    	$params = $params + $_GET;
123
+    }
124
+    if (!$params) {
125
+    	return $url;
126
+    }
119 127
     $link = $url;
120
-    if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
121
-    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
122
-    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
128
+    if (strpos($link, '?') === false) {
129
+    	$link .= '?';
130
+    }
131
+    //If there is no '?' add one at the end
132
+    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) {
133
+    	$link .= '&amp;';
134
+    }
135
+    //If there is no '&' at the END, add one.
136
+    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) {
137
+    	$link .= '&';
138
+    }
139
+    //If there is no '&' at the END, add one.
123 140
 
124 141
     $params_arr = array();
125 142
     foreach ($params as $key => $value) {
@@ -157,9 +174,10 @@  discard block
 block discarded – undo
157 174
         $add_listing_link = get_page_link(geodir_add_listing_page_id());
158 175
 
159 176
         return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
160
-    } else
161
-        return get_bloginfo('url');
162
-}
177
+    } else {
178
+            return get_bloginfo('url');
179
+    }
180
+    }
163 181
 
164 182
 /**
165 183
  * Get the current page URL.
@@ -264,24 +282,28 @@  discard block
 block discarded – undo
264 282
         case 'preview':
265 283
             if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
266 284
                 && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
267
-            )
268
-                return true;
285
+            ) {
286
+                            return true;
287
+            }
269 288
             break;
270 289
         case 'listing-success':
271
-            if (is_page() && get_query_var('page_id') == geodir_success_page_id())
272
-                return true;
290
+            if (is_page() && get_query_var('page_id') == geodir_success_page_id()) {
291
+                            return true;
292
+            }
273 293
             break;
274 294
         case 'detail':
275 295
             $post_type = get_query_var('post_type');
276 296
             if(is_array($post_type)){$post_type = reset($post_type);}
277
-            if (is_single() && in_array($post_type, geodir_get_posttypes()))
278
-                return true;
297
+            if (is_single() && in_array($post_type, geodir_get_posttypes())) {
298
+                            return true;
299
+            }
279 300
             break;
280 301
         case 'pt':
281 302
             $post_type = get_query_var('post_type');
282 303
             if(is_array($post_type)){$post_type = reset($post_type);}
283
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
284
-                return true;
304
+            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) {
305
+                            return true;
306
+            }
285 307
 
286 308
             break;
287 309
         case 'listing':
@@ -292,23 +314,27 @@  discard block
 block discarded – undo
292 314
             }
293 315
             $post_type = get_query_var('post_type');
294 316
             if(is_array($post_type)){$post_type = reset($post_type);}
295
-            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
296
-                return true;
317
+            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) {
318
+                            return true;
319
+            }
297 320
 
298 321
             break;
299 322
         case 'home':
300 323
 
301
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
302
-                return true;
324
+            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) {
325
+                            return true;
326
+            }
303 327
 
304 328
             break;
305 329
         case 'location':
306
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
307
-                return true;
330
+            if (is_page() && get_query_var('page_id') == geodir_location_page_id()) {
331
+                            return true;
332
+            }
308 333
             break;
309 334
         case 'author':
310
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
311
-                return true;
335
+            if (is_author() && isset($_REQUEST['geodir_dashbord'])) {
336
+                            return true;
337
+            }
312 338
 			
313 339
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
314 340
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
@@ -317,24 +343,29 @@  discard block
 block discarded – undo
317 343
 			}
318 344
             break;
319 345
         case 'search':
320
-            if (is_search() && isset($_REQUEST['geodir_search']))
321
-                return true;
346
+            if (is_search() && isset($_REQUEST['geodir_search'])) {
347
+                            return true;
348
+            }
322 349
             break;
323 350
         case 'info':
324
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
325
-                return true;
351
+            if (is_page() && get_query_var('page_id') == geodir_info_page_id()) {
352
+                            return true;
353
+            }
326 354
             break;
327 355
         case 'login':
328
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
329
-                return true;
356
+            if (is_page() && get_query_var('page_id') == geodir_login_page_id()) {
357
+                            return true;
358
+            }
330 359
             break;
331 360
         case 'checkout':
332
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
333
-                return true;
361
+            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) {
362
+                            return true;
363
+            }
334 364
             break;
335 365
         case 'invoices':
336
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
337
-                return true;
366
+            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) {
367
+                            return true;
368
+            }
338 369
             break;
339 370
         default:
340 371
             return false;
@@ -362,8 +393,9 @@  discard block
 block discarded – undo
362 393
         //$wp->query_vars['gd_is_geodir_page'] = false;
363 394
         //print_r()
364 395
         if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
365
-            if (get_option('geodir_set_as_home'))
366
-                $wp->query_vars['gd_is_geodir_page'] = true;
396
+            if (get_option('geodir_set_as_home')) {
397
+                            $wp->query_vars['gd_is_geodir_page'] = true;
398
+            }
367 399
             if(geodir_is_page('home')){
368 400
                 $wp->query_vars['gd_is_geodir_page'] = true;
369 401
             }
@@ -382,8 +414,9 @@  discard block
 block discarded – undo
382 414
                 || $wp->query_vars['page_id'] == geodir_login_page_id()
383 415
                 || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
384 416
                 || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
385
-            )
386
-                $wp->query_vars['gd_is_geodir_page'] = true;
417
+            ) {
418
+                            $wp->query_vars['gd_is_geodir_page'] = true;
419
+            }
387 420
         }
388 421
 
389 422
         if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
@@ -400,8 +433,9 @@  discard block
 block discarded – undo
400 433
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
401 434
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
402 435
                 )
403
-            )
404
-                $wp->query_vars['gd_is_geodir_page'] = true;
436
+            ) {
437
+                            $wp->query_vars['gd_is_geodir_page'] = true;
438
+            }
405 439
         }
406 440
 
407 441
 
@@ -427,12 +461,14 @@  discard block
 block discarded – undo
427 461
 
428 462
         }
429 463
 
430
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
431
-            $wp->query_vars['gd_is_geodir_page'] = true;
464
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) {
465
+                    $wp->query_vars['gd_is_geodir_page'] = true;
466
+        }
432 467
 
433 468
 
434
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
435
-            $wp->query_vars['gd_is_geodir_page'] = true;
469
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) {
470
+                    $wp->query_vars['gd_is_geodir_page'] = true;
471
+        }
436 472
 
437 473
 
438 474
 //check if homepage
@@ -462,11 +498,12 @@  discard block
 block discarded – undo
462 498
 function geodir_is_geodir_page()
463 499
 {
464 500
     global $wp;
465
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
466
-        return true;
467
-    else
468
-        return false;
469
-}
501
+    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) {
502
+            return true;
503
+    } else {
504
+            return false;
505
+    }
506
+    }
470 507
 
471 508
 if (!function_exists('geodir_get_imagesize')) {
472 509
     /**
@@ -763,20 +800,16 @@  discard block
 block discarded – undo
763 800
             $subject .= ' - ADMIN BCC COPY';
764 801
             $admin_bcc = true;
765 802
 
766
-        }
767
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
803
+        } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
768 804
             $subject .= ' - ADMIN BCC COPY';
769 805
             $admin_bcc = true;
770
-        }
771
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
806
+        } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
772 807
             $subject .= ' - ADMIN BCC COPY';
773 808
             $admin_bcc = true;
774
-        }
775
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
809
+        } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
776 810
             $subject .= ' - ADMIN BCC COPY';
777 811
             $admin_bcc = true;
778
-        }
779
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
812
+        } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
780 813
             $subject .= ' - ADMIN BCC COPY';
781 814
             $admin_bcc = true;
782 815
         }
@@ -945,21 +978,24 @@  discard block
 block discarded – undo
945 978
             $is_location_last = '';
946 979
             $is_taxonomy_last = '';
947 980
             $breadcrumb .= '<li>';
948
-            if (get_query_var($gd_post_type . 'category'))
949
-                $gd_taxonomy = $gd_post_type . 'category';
950
-            elseif (get_query_var($gd_post_type . '_tags'))
951
-                $gd_taxonomy = $gd_post_type . '_tags';
981
+            if (get_query_var($gd_post_type . 'category')) {
982
+                            $gd_taxonomy = $gd_post_type . 'category';
983
+            } elseif (get_query_var($gd_post_type . '_tags')) {
984
+                            $gd_taxonomy = $gd_post_type . '_tags';
985
+            }
952 986
 
953 987
             $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
954
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
955
-                $is_location_last = false;
956
-            else
957
-                $is_location_last = true;
958
-
959
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
960
-                $is_taxonomy_last = true;
961
-            else
962
-                $is_taxonomy_last = false;
988
+            if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
989
+                            $is_location_last = false;
990
+            } else {
991
+                            $is_location_last = true;
992
+            }
993
+
994
+            if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
995
+                            $is_taxonomy_last = true;
996
+            } else {
997
+                            $is_taxonomy_last = false;
998
+            }
963 999
 
964 1000
             if (!empty($location_terms)) {
965 1001
                 $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
@@ -1041,8 +1077,9 @@  discard block
 block discarded – undo
1041 1077
                 {
1042 1078
                     if (get_query_var($gd_post_type . '_tags')) {
1043 1079
                         $cat_link = $listing_link . 'tags/';
1044
-                    } else
1045
-                        $cat_link = $listing_link;
1080
+                    } else {
1081
+                                            $cat_link = $listing_link;
1082
+                    }
1046 1083
 
1047 1084
                     foreach ($location_terms as $key => $location_term) {
1048 1085
                         if ($location_manager && in_array($key, $hide_url_part)) {
@@ -1069,9 +1106,9 @@  discard block
 block discarded – undo
1069 1106
                             $term_link_text = geodir_ucwords(urldecode($term_link_text));
1070 1107
                         }
1071 1108
 
1072
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1073
-                            $breadcrumb .= $separator . $term_link_text;
1074
-                        else {
1109
+                        if ($term_index == count($term_array) && $is_taxonomy_last) {
1110
+                                                    $breadcrumb .= $separator . $term_link_text;
1111
+                        } else {
1075 1112
                             $cat_link .= $term . '/';
1076 1113
                             $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1077 1114
                         }
@@ -1082,8 +1119,9 @@  discard block
 block discarded – undo
1082 1119
 
1083 1120
             }
1084 1121
 
1085
-            if (geodir_is_page('detail'))
1086
-                $breadcrumb .= $separator . get_the_title();
1122
+            if (geodir_is_page('detail')) {
1123
+                            $breadcrumb .= $separator . get_the_title();
1124
+            }
1087 1125
 
1088 1126
             $breadcrumb .= '</li>';
1089 1127
 
@@ -1120,8 +1158,9 @@  discard block
 block discarded – undo
1120 1158
 
1121 1159
                 $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1122 1160
                 $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1123
-            } else
1124
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1161
+            } else {
1162
+                            $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1163
+            }
1125 1164
 
1126 1165
             $breadcrumb .= '</li>';
1127 1166
         } elseif (is_category() || is_single()) {
@@ -1196,12 +1235,14 @@  discard block
 block discarded – undo
1196 1235
     function geodir_allow_wpadmin()
1197 1236
     {
1198 1237
         global $wpdb;
1199
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1238
+        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) {
1239
+        	// checking action in request to allow ajax request go through
1200 1240
         {
1201 1241
             if (current_user_can('manage_options')) {
1202 1242
             } else {
1203 1243
 
1204
-                wp_redirect(home_url());
1244
+                wp_redirect(home_url());
1245
+        }
1205 1246
                 exit;
1206 1247
             }
1207 1248
 
@@ -1233,8 +1274,9 @@  discard block
 block discarded – undo
1233 1274
     $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1234 1275
 
1235 1276
     $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1236
-    if ($upload['error'])
1237
-        return new WP_Error('upload_dir_error', $upload['error']);
1277
+    if ($upload['error']) {
1278
+            return new WP_Error('upload_dir_error', $upload['error']);
1279
+    }
1238 1280
 
1239 1281
     // fetch the remote url and write it to the placeholder file
1240 1282
     $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
@@ -1248,11 +1290,9 @@  discard block
 block discarded – undo
1248 1290
     // make sure the fetch was successful
1249 1291
     elseif ($headers['response']['code'] != '200') {
1250 1292
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1251
-    }
1252
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1293
+    } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1253 1294
         $log_message =  __('Remote file is incorrect size', 'geodirectory');
1254
-    }
1255
-    elseif (0 == $filesize) {
1295
+    } elseif (0 == $filesize) {
1256 1296
         $log_message = __('Zero size file downloaded', 'geodirectory');
1257 1297
     }
1258 1298
 
@@ -1304,10 +1344,11 @@  discard block
 block discarded – undo
1304 1344
 function geodir_dummy_folder_exists()
1305 1345
 {
1306 1346
     $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1307
-    if (!is_dir($path))
1308
-        return false;
1309
-    else
1310
-        return true;
1347
+    if (!is_dir($path)) {
1348
+            return false;
1349
+    } else {
1350
+            return true;
1351
+    }
1311 1352
 
1312 1353
 }
1313 1354
 
@@ -1525,12 +1566,10 @@  discard block
 block discarded – undo
1525 1566
         if ($message_type == 'registration' && get_option('bcc_new_user')) {
1526 1567
             $subject .= ' - ADMIN BCC COPY';
1527 1568
             $admin_bcc = true;
1528
-        }
1529
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1569
+        } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1530 1570
             $subject .= ' - ADMIN BCC COPY';
1531 1571
             $admin_bcc = true;
1532
-        }
1533
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1572
+        } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1534 1573
             $subject .= ' - ADMIN BCC COPY';
1535 1574
             $admin_bcc = true;
1536 1575
         }
@@ -1574,7 +1613,9 @@  discard block
 block discarded – undo
1574 1613
         $res = array();
1575 1614
         foreach ($ids_array as $id) {
1576 1615
             $xlat = icl_object_id($id, $type, false);
1577
-            if (!is_null($xlat)) $res[] = $xlat;
1616
+            if (!is_null($xlat)) {
1617
+            	$res[] = $xlat;
1618
+            }
1578 1619
         }
1579 1620
         return $res;
1580 1621
     } else {
@@ -1916,8 +1957,9 @@  discard block
 block discarded – undo
1916 1957
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1917 1958
 
1918 1959
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1919
-        if ( !$page )
1920
-            $page = 1;
1960
+        if ( !$page ) {
1961
+                    $page = 1;
1962
+        }
1921 1963
 
1922 1964
         $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1923 1965
 
@@ -2265,7 +2307,7 @@  discard block
 block discarded – undo
2265 2307
     $home_url = str_replace("www.", "", $home_url);
2266 2308
     if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
2267 2309
         return true;
2268
-    }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2310
+    } elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2269 2311
         return true;
2270 2312
     } else {
2271 2313
         return false;
@@ -2760,8 +2802,9 @@  discard block
 block discarded – undo
2760 2802
                         $name = $postobj->labels->name;
2761 2803
 
2762 2804
                         $selected = '';
2763
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2764
-                            $selected = 'selected="selected"';
2805
+                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
2806
+                                                    $selected = 'selected="selected"';
2807
+                        }
2765 2808
 
2766 2809
                         /**
2767 2810
                          * Filter add listing link.
@@ -3228,8 +3271,9 @@  discard block
 block discarded – undo
3228 3271
             $geodir_is_widget_listing = false;
3229 3272
 
3230 3273
             $GLOBALS['post'] = $current_post;
3231
-            if (!empty($current_post))
3232
-                setup_postdata($current_post);
3274
+            if (!empty($current_post)) {
3275
+                            setup_postdata($current_post);
3276
+            }
3233 3277
             $map_jason = $current_map_jason;
3234 3278
             $map_canvas_arr = $current_map_canvas_arr;
3235 3279
             ?>
@@ -3545,11 +3589,15 @@  discard block
 block discarded – undo
3545 3589
 
3546 3590
     $language_file = geodir_plugin_path() . '/db-language.php';
3547 3591
 
3548
-    if(is_file($language_file) && !is_writable($language_file))
3549
-        return false; // Not possible to create.
3592
+    if(is_file($language_file) && !is_writable($language_file)) {
3593
+            return false;
3594
+    }
3595
+    // Not possible to create.
3550 3596
 
3551
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3552
-        return false; // Not possible to create.
3597
+    if(!is_file($language_file) && !is_writable(dirname($language_file))) {
3598
+            return false;
3599
+    }
3600
+    // Not possible to create.
3553 3601
 
3554 3602
     $contents_strings = array();
3555 3603
 
@@ -3592,8 +3640,10 @@  discard block
 block discarded – undo
3592 3640
 
3593 3641
     $contents .= implode(PHP_EOL, $contents_foot);
3594 3642
 
3595
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3596
-        return false; // Failure; could not write file.
3643
+    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) {
3644
+            return false;
3645
+    }
3646
+    // Failure; could not write file.
3597 3647
 
3598 3648
     return true;
3599 3649
 }
@@ -3619,23 +3669,29 @@  discard block
 block discarded – undo
3619 3669
 
3620 3670
     if (!empty($rows)) {
3621 3671
         foreach($rows as $row) {
3622
-            if (!empty($row->admin_title))
3623
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3672
+            if (!empty($row->admin_title)) {
3673
+                            $translation_texts[] = stripslashes_deep($row->admin_title);
3674
+            }
3624 3675
 			
3625
-            if (!empty($row->admin_desc))
3626
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3676
+            if (!empty($row->admin_desc)) {
3677
+                            $translation_texts[] = stripslashes_deep($row->admin_desc);
3678
+            }
3627 3679
 
3628
-            if (!empty($row->site_title))
3629
-                $translation_texts[] = stripslashes_deep($row->site_title);
3680
+            if (!empty($row->site_title)) {
3681
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3682
+            }
3630 3683
 
3631
-            if (!empty($row->clabels))
3632
-                $translation_texts[] = stripslashes_deep($row->clabels);
3684
+            if (!empty($row->clabels)) {
3685
+                            $translation_texts[] = stripslashes_deep($row->clabels);
3686
+            }
3633 3687
 
3634
-            if (!empty($row->required_msg))
3635
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3688
+            if (!empty($row->required_msg)) {
3689
+                            $translation_texts[] = stripslashes_deep($row->required_msg);
3690
+            }
3636 3691
 			
3637
-			if (!empty($row->default_value))
3638
-                $translation_texts[] = stripslashes_deep($row->default_value);
3692
+			if (!empty($row->default_value)) {
3693
+			                $translation_texts[] = stripslashes_deep($row->default_value);
3694
+			}
3639 3695
 			
3640 3696
 			if (!empty($row->option_values)) {
3641 3697
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3657,14 +3713,17 @@  discard block
 block discarded – undo
3657 3713
 
3658 3714
     if (!empty($rows)) {
3659 3715
         foreach($rows as $row) {
3660
-            if (!empty($row->site_title))
3661
-                $translation_texts[] = stripslashes_deep($row->site_title);
3716
+            if (!empty($row->site_title)) {
3717
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3718
+            }
3662 3719
 
3663
-            if (!empty($row->asc_title))
3664
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3720
+            if (!empty($row->asc_title)) {
3721
+                            $translation_texts[] = stripslashes_deep($row->asc_title);
3722
+            }
3665 3723
 
3666
-            if (!empty($row->desc_title))
3667
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3724
+            if (!empty($row->desc_title)) {
3725
+                            $translation_texts[] = stripslashes_deep($row->desc_title);
3726
+            }
3668 3727
         }
3669 3728
     }
3670 3729
 	
@@ -3675,14 +3734,17 @@  discard block
 block discarded – undo
3675 3734
 
3676 3735
 		if (!empty($rows)) {
3677 3736
 			foreach($rows as $row) {
3678
-				if (!empty($row->field_site_name))
3679
-					$translation_texts[] = stripslashes_deep($row->field_site_name);
3737
+				if (!empty($row->field_site_name)) {
3738
+									$translation_texts[] = stripslashes_deep($row->field_site_name);
3739
+				}
3680 3740
 
3681
-				if (!empty($row->front_search_title))
3682
-					$translation_texts[] = stripslashes_deep($row->front_search_title);
3741
+				if (!empty($row->front_search_title)) {
3742
+									$translation_texts[] = stripslashes_deep($row->front_search_title);
3743
+				}
3683 3744
 
3684
-				if (!empty($row->field_desc))
3685
-					$translation_texts[] = stripslashes_deep($row->field_desc);
3745
+				if (!empty($row->field_desc)) {
3746
+									$translation_texts[] = stripslashes_deep($row->field_desc);
3747
+				}
3686 3748
 			}
3687 3749
 		}
3688 3750
 	}
@@ -4000,7 +4062,7 @@  discard block
 block discarded – undo
4000 4062
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4001 4063
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4002 4064
             }
4003
-        }elseif($gd_page=='add-listing'){
4065
+        } elseif($gd_page=='add-listing'){
4004 4066
             $geodir_post_types = get_option('geodir_post_types');
4005 4067
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4006 4068
             if(!$spt && isset($_REQUEST['pid'])){
@@ -4010,8 +4072,7 @@  discard block
 block discarded – undo
4010 4072
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4011 4073
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4012 4074
             }
4013
-        }
4014
-        elseif($post->post_type){
4075
+        } elseif($post->post_type){
4015 4076
             $geodir_post_types = get_option('geodir_post_types');
4016 4077
             if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4017 4078
                 $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
@@ -4030,15 +4091,14 @@  discard block
 block discarded – undo
4030 4091
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4031 4092
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4032 4093
             }
4033
-        }elseif($gd_page=='add-listing'){
4094
+        } elseif($gd_page=='add-listing'){
4034 4095
             $geodir_post_types = get_option('geodir_post_types');
4035 4096
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4036 4097
             if(!$spt){$spt='gd_place';}
4037 4098
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4038 4099
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4039 4100
             }
4040
-        }
4041
-        elseif(isset($post->post_type) && $post->post_type){
4101
+        } elseif(isset($post->post_type) && $post->post_type){
4042 4102
             $geodir_post_types = get_option('geodir_post_types');
4043 4103
             if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4044 4104
                 $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
@@ -4058,7 +4118,7 @@  discard block
 block discarded – undo
4058 4118
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4059 4119
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4060 4120
             }
4061
-        }elseif($gd_page=='listing'){
4121
+        } elseif($gd_page=='listing'){
4062 4122
             $queried_object = get_queried_object();
4063 4123
             if(isset($queried_object->name)){
4064 4124
                 $cat_name = $queried_object->name;
@@ -4075,7 +4135,7 @@  discard block
 block discarded – undo
4075 4135
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4076 4136
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4077 4137
             }
4078
-        }elseif($gd_page=='listing'){
4138
+        } elseif($gd_page=='listing'){
4079 4139
             $queried_object = get_queried_object();
4080 4140
             if(isset($queried_object->name)){
4081 4141
                 $cat_name = $queried_object->name;
@@ -4243,8 +4303,7 @@  discard block
 block discarded – undo
4243 4303
 
4244 4304
     if(strpos($title,'%%name%%') !== false){
4245 4305
         $author_name = '';
4246
-        if($author_name = get_the_author()){}
4247
-        else{
4306
+        if($author_name = get_the_author()){} else{
4248 4307
             $queried_object = get_queried_object();
4249 4308
             if(isset($queried_object->data->user_nicename)){
4250 4309
                 $author_name = $queried_object->data->user_nicename;
@@ -4290,38 +4349,54 @@  discard block
 block discarded – undo
4290 4349
             $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4291 4350
 
4292 4351
             if (!empty($labels)) {
4293
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4294
-                    $translation_texts[] = $labels['name'];
4295
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4296
-                    $translation_texts[] = $labels['singular_name'];
4297
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4298
-                    $translation_texts[] = $labels['add_new'];
4299
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4300
-                    $translation_texts[] = $labels['add_new_item'];
4301
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4302
-                    $translation_texts[] = $labels['edit_item'];
4303
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4304
-                    $translation_texts[] = $labels['new_item'];
4305
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4306
-                    $translation_texts[] = $labels['view_item'];
4307
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4308
-                    $translation_texts[] = $labels['search_items'];
4309
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4310
-                    $translation_texts[] = $labels['not_found'];
4311
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4312
-                    $translation_texts[] = $labels['not_found_in_trash'];
4313
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4314
-                    $translation_texts[] = $labels['label_post_profile'];
4315
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4316
-                    $translation_texts[] = $labels['label_post_info'];
4317
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4318
-                    $translation_texts[] = $labels['label_post_images'];
4319
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4320
-                    $translation_texts[] = $labels['label_post_map'];
4321
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4322
-                    $translation_texts[] = $labels['label_reviews'];
4323
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4324
-                    $translation_texts[] = $labels['label_related_listing'];
4352
+                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
4353
+                                    $translation_texts[] = $labels['name'];
4354
+                }
4355
+                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
4356
+                                    $translation_texts[] = $labels['singular_name'];
4357
+                }
4358
+                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
4359
+                                    $translation_texts[] = $labels['add_new'];
4360
+                }
4361
+                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
4362
+                                    $translation_texts[] = $labels['add_new_item'];
4363
+                }
4364
+                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
4365
+                                    $translation_texts[] = $labels['edit_item'];
4366
+                }
4367
+                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
4368
+                                    $translation_texts[] = $labels['new_item'];
4369
+                }
4370
+                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
4371
+                                    $translation_texts[] = $labels['view_item'];
4372
+                }
4373
+                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
4374
+                                    $translation_texts[] = $labels['search_items'];
4375
+                }
4376
+                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
4377
+                                    $translation_texts[] = $labels['not_found'];
4378
+                }
4379
+                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
4380
+                                    $translation_texts[] = $labels['not_found_in_trash'];
4381
+                }
4382
+                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
4383
+                                    $translation_texts[] = $labels['label_post_profile'];
4384
+                }
4385
+                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
4386
+                                    $translation_texts[] = $labels['label_post_info'];
4387
+                }
4388
+                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
4389
+                                    $translation_texts[] = $labels['label_post_images'];
4390
+                }
4391
+                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
4392
+                                    $translation_texts[] = $labels['label_post_map'];
4393
+                }
4394
+                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
4395
+                                    $translation_texts[] = $labels['label_reviews'];
4396
+                }
4397
+                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
4398
+                                    $translation_texts[] = $labels['label_related_listing'];
4399
+                }
4325 4400
             }
4326 4401
 
4327 4402
             if ($description != '' && !in_array($description, $translation_texts)) {
@@ -4329,11 +4404,13 @@  discard block
 block discarded – undo
4329 4404
             }
4330 4405
 
4331 4406
             if (!empty($seo)) {
4332
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4333
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4407
+                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
4408
+                                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4409
+                }
4334 4410
 
4335
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4336
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4411
+                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
4412
+                                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4413
+                }
4337 4414
             }
4338 4415
         }
4339 4416
     }
@@ -4359,16 +4436,20 @@  discard block
 block discarded – undo
4359 4436
         $hide_region_part = get_option('geodir_location_hide_region_part');
4360 4437
 
4361 4438
         if ($hide_region_part && $hide_country_part) {
4362
-            if (isset($location_terms['gd_country']))
4363
-                unset($location_terms['gd_country']);
4364
-            if (isset($location_terms['gd_region']))
4365
-                unset($location_terms['gd_region']);
4439
+            if (isset($location_terms['gd_country'])) {
4440
+                            unset($location_terms['gd_country']);
4441
+            }
4442
+            if (isset($location_terms['gd_region'])) {
4443
+                            unset($location_terms['gd_region']);
4444
+            }
4366 4445
         } else if ($hide_region_part && !$hide_country_part) {
4367
-            if (isset($location_terms['gd_region']))
4368
-                unset($location_terms['gd_region']);
4446
+            if (isset($location_terms['gd_region'])) {
4447
+                            unset($location_terms['gd_region']);
4448
+            }
4369 4449
         } else if (!$hide_region_part && $hide_country_part) {
4370
-            if (isset($location_terms['gd_country']))
4371
-                unset($location_terms['gd_country']);
4450
+            if (isset($location_terms['gd_country'])) {
4451
+                            unset($location_terms['gd_country']);
4452
+            }
4372 4453
         }
4373 4454
     }
4374 4455
 
Please login to merge, or discard this patch.
Spacing   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_plugin_path()
49 49
 {
50
-    if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
50
+    if (defined('GD_TESTING_MODE') && GD_TESTING_MODE) {
51 51
         return dirname(dirname(__FILE__));
52 52
     } else {
53 53
         return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
         $add_listing_link = get_page_link(geodir_add_listing_page_id());
162 162
 
163
-        return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
163
+        return esc_url(add_query_arg(array('listing_type' => $post_type), $add_listing_link));
164 164
     } else
165 165
         return get_bloginfo('url');
166 166
 }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 function geodir_is_page($gdpage = '')
253 253
 {
254 254
 
255
-    global $wp_query, $post,$wp;
255
+    global $wp_query, $post, $wp;
256 256
     //if(!is_admin()):
257 257
 
258 258
     switch ($gdpage):
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
             break;
278 278
         case 'detail':
279 279
             $post_type = get_query_var('post_type');
280
-            if(is_array($post_type)){$post_type = reset($post_type);}
280
+            if (is_array($post_type)) {$post_type = reset($post_type); }
281 281
             if (is_single() && in_array($post_type, geodir_get_posttypes()))
282 282
                 return true;
283 283
             break;
284 284
         case 'pt':
285 285
             $post_type = get_query_var('post_type');
286
-            if(is_array($post_type)){$post_type = reset($post_type);}
287
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
286
+            if (is_array($post_type)) {$post_type = reset($post_type); }
287
+            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()) && !is_tax())
288 288
                 return true;
289 289
 
290 290
             break;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                 return true;
296 296
             }
297 297
             $post_type = get_query_var('post_type');
298
-            if(is_array($post_type)){$post_type = reset($post_type);}
298
+            if (is_array($post_type)) {$post_type = reset($post_type); }
299 299
             if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300 300
                 return true;
301 301
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
             if (is_author() && isset($_REQUEST['geodir_dashbord']))
315 315
                 return true;
316 316
 			
317
-			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
318
-				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
317
+			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
318
+				if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
319 319
 					return true;
320 320
 				}
321 321
 			}
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369 369
             if (get_option('geodir_set_as_home'))
370 370
                 $wp->query_vars['gd_is_geodir_page'] = true;
371
-            if(geodir_is_page('home')){
371
+            if (geodir_is_page('home')) {
372 372
                 $wp->query_vars['gd_is_geodir_page'] = true;
373 373
             }
374 374
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
         if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422 422
             $geodir_taxonomis = geodir_get_taxonomies('', true);
423
-            if(!empty($geodir_taxonomis)){
423
+            if (!empty($geodir_taxonomis)) {
424 424
                 foreach ($geodir_taxonomis as $taxonomy) {
425 425
                     if (array_key_exists($taxonomy, $wp->query_vars)) {
426 426
                         $wp->query_vars['gd_is_geodir_page'] = true;
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 
441 441
 
442 442
 //check if homepage
443
-        if(!isset($wp->query_vars['gd_is_geodir_page'])
443
+        if (!isset($wp->query_vars['gd_is_geodir_page'])
444 444
             && !isset($wp->query_vars['page_id'])
445 445
             && !isset($wp->query_vars['pagename'])
446
-            && is_page_geodir_home()){
446
+            && is_page_geodir_home()) {
447 447
             $wp->query_vars['gd_is_geodir_page'] = true;
448 448
         }
449 449
         //echo $wp->query_vars['gd_is_geodir_page'] ;
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
     function createRandomString()
545 545
     {
546 546
         $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
-        srand((double)microtime() * 1000000);
547
+        srand((double) microtime() * 1000000);
548 548
         $i = 0;
549 549
         $rstring = '';
550 550
         while ($i <= 25) {
@@ -681,11 +681,11 @@  discard block
 block discarded – undo
681 681
         }
682 682
 		
683 683
 		if (!empty($subject)) {
684
-			$subject = __(stripslashes_deep($subject),'geodirectory');
684
+			$subject = __(stripslashes_deep($subject), 'geodirectory');
685 685
 		}
686 686
 		
687 687
 		if (!empty($message)) {
688
-			$message = __(stripslashes_deep($message),'geodirectory');
688
+			$message = __(stripslashes_deep($message), 'geodirectory');
689 689
 		}
690 690
 
691 691
         $to_message = nl2br($to_message);
@@ -724,12 +724,12 @@  discard block
 block discarded – undo
724 724
             $fromEmailName = get_option('site_email_name');
725 725
         }
726 726
 
727
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
727
+        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]', '[#post_author_id#]', '[#post_author_name#]', '[#current_date#]');
728
+        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729 729
         $message = str_replace($search_array, $replace_array, $message);
730 730
 
731
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
731
+        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]', '[#post_author_id#]', '[#post_author_name#]', '[#current_date#]');
732
+        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733 733
         $subject = str_replace($search_array, $replace_array, $subject);
734 734
 
735 735
         $headers = 'MIME-Version: 1.0' . "\r\n";
@@ -740,18 +740,18 @@  discard block
 block discarded – undo
740 740
         $to = $toEmail;
741 741
         $sent = wp_mail($to, $subject, $message, $headers);
742 742
 
743
-        if( ! $sent ) {
744
-            if ( is_array( $to ) ) {
745
-                $to = implode( ',', $to );
743
+        if (!$sent) {
744
+            if (is_array($to)) {
745
+                $to = implode(',', $to);
746 746
             }
747 747
             $log_message = sprintf(
748
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
748
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
749 749
                 $message_type,
750
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
750
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
751 751
                 $to,
752 752
                 $subject
753 753
             );
754
-            geodir_error_log( $log_message );
754
+            geodir_error_log($log_message);
755 755
         }
756 756
 
757 757
         ///////// ADMIN BCC EMIALS
@@ -763,11 +763,11 @@  discard block
 block discarded – undo
763 763
             $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
764 764
             $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
765 765
 
766
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
766
+            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
767 767
             $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login);
768 768
             $message = str_replace($search_array, $replace_array, $message);
769 769
 
770
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
770
+            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
771 771
             $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
772 772
             $subject = str_replace($search_array, $replace_array, $subject);
773 773
 
@@ -792,21 +792,21 @@  discard block
 block discarded – undo
792 792
             $admin_bcc = true;
793 793
         }
794 794
 
795
-        if($admin_bcc===true){
795
+        if ($admin_bcc === true) {
796 796
             $sent = wp_mail($to, $subject, $message, $headers);
797 797
 
798
-            if( ! $sent ) {
799
-                if ( is_array( $to ) ) {
800
-                    $to = implode( ',', $to );
798
+            if (!$sent) {
799
+                if (is_array($to)) {
800
+                    $to = implode(',', $to);
801 801
                 }
802 802
                 $log_message = sprintf(
803
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
803
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
804 804
                     $message_type,
805
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
805
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
806 806
                     $to,
807 807
                     $subject
808 808
                 );
809
-                geodir_error_log( $log_message );
809
+                geodir_error_log($log_message);
810 810
             }
811 811
         }
812 812
 
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
             $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
902 902
 			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
903 903
 				
904
-			if(geodir_is_page('detail') && isset($post->country_slug)){
904
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
905 905
                 $location_terms = array(
906 906
                     'gd_country' => $post->country_slug,
907 907
                     'gd_region' => $post->region_slug,
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
             $breadcrumb .= stripslashes_deep($page_title);
1157 1157
             $breadcrumb .= '</li>';
1158 1158
         } else if (is_tag()) {
1159
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1159
+            $breadcrumb .= "<li> " . $separator . single_tag_title('', false) . '</li>';
1160 1160
         } else if (is_day()) {
1161 1161
             $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1162 1162
             the_time('F jS, Y');
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
         return new WP_Error('upload_dir_error', $upload['error']);
1249 1249
 
1250 1250
     // fetch the remote url and write it to the placeholder file
1251
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1251
+    $headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
1252 1252
 
1253 1253
     $log_message = '';
1254 1254
     $filesize = filesize($upload['file']);
@@ -1261,16 +1261,16 @@  discard block
 block discarded – undo
1261 1261
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1262 1262
     }
1263 1263
     elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1264
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1264
+        $log_message = __('Remote file is incorrect size', 'geodirectory');
1265 1265
     }
1266 1266
     elseif (0 == $filesize) {
1267 1267
         $log_message = __('Zero size file downloaded', 'geodirectory');
1268 1268
     }
1269 1269
 
1270
-    if($log_message){
1270
+    if ($log_message) {
1271 1271
         $del = unlink($upload['file']);
1272
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1273
-        return new WP_Error('import_file_error',$log_message );
1272
+        if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
1273
+        return new WP_Error('import_file_error', $log_message);
1274 1274
     }
1275 1275
 
1276 1276
 
@@ -1286,10 +1286,10 @@  discard block
 block discarded – undo
1286 1286
  */
1287 1287
 function geodir_max_upload_size()
1288 1288
 {
1289
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1289
+    $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
1290 1290
 
1291 1291
     if ($max_filesize > 0 && $max_filesize < 1) {
1292
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1292
+        $max_filesize = (int) ($max_filesize * 1024) . 'kb';
1293 1293
     } else {
1294 1294
         $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1295 1295
     }
@@ -1358,35 +1358,35 @@  discard block
 block discarded – undo
1358 1358
     {
1359 1359
         global $wpdb;
1360 1360
         if ($message_type == 'expiration') {
1361
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1362
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1361
+            $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
1362
+            $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
1363 1363
         } elseif ($message_type == 'post_submited') {
1364
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1365
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1364
+            $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
1365
+            $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
1366 1366
         } elseif ($message_type == 'renew') {
1367
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1368
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1367
+            $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
1368
+            $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
1369 1369
         } elseif ($message_type == 'upgrade') {
1370
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1371
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1370
+            $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
1371
+            $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
1372 1372
         } elseif ($message_type == 'claim_approved') {
1373
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1374
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1373
+            $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
1374
+            $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
1375 1375
         } elseif ($message_type == 'claim_rejected') {
1376
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1377
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1376
+            $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
1377
+            $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
1378 1378
         } elseif ($message_type == 'claim_requested') {
1379
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1380
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1379
+            $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
1380
+            $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
1381 1381
         } elseif ($message_type == 'auto_claim') {
1382
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1383
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1382
+            $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
1383
+            $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
1384 1384
         } elseif ($message_type == 'payment_success') {
1385
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1386
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1385
+            $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
1386
+            $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
1387 1387
         } elseif ($message_type == 'payment_fail') {
1388
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1389
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1388
+            $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
1389
+            $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
1390 1390
         }
1391 1391
         $transaction_details = $custom_1;
1392 1392
         $fromEmail = get_option('site_email');
@@ -1427,18 +1427,18 @@  discard block
 block discarded – undo
1427 1427
         $to = $fromEmail;
1428 1428
         $message = $client_message;
1429 1429
         $sent = wp_mail($to, $subject, $message, $headers);
1430
-        if( ! $sent ) {
1431
-            if ( is_array( $to ) ) {
1432
-                $to = implode( ',', $to );
1430
+        if (!$sent) {
1431
+            if (is_array($to)) {
1432
+                $to = implode(',', $to);
1433 1433
             }
1434 1434
             $log_message = sprintf(
1435
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1435
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1436 1436
                 $message_type,
1437
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1437
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1438 1438
                 $to,
1439 1439
                 $subject
1440 1440
             );
1441
-            geodir_error_log( $log_message );
1441
+            geodir_error_log($log_message);
1442 1442
         }
1443 1443
     }
1444 1444
 }
@@ -1464,18 +1464,18 @@  discard block
 block discarded – undo
1464 1464
     {
1465 1465
         $login_details = '';
1466 1466
         if ($message_type == 'send_friend') {
1467
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1468
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1467
+            $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
1468
+            $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
1469 1469
         } elseif ($message_type == 'send_enquiry') {
1470
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1471
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1470
+            $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
1471
+            $message = __(get_option('email_enquiry_content'), 'geodirectory');
1472 1472
         } elseif ($message_type == 'forgot_password') {
1473
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1474
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1473
+            $subject = __(get_option('forgot_password_subject'), 'geodirectory');
1474
+            $message = __(get_option('forgot_password_content'), 'geodirectory');
1475 1475
             $login_details = $to_message;
1476 1476
         } elseif ($message_type == 'registration') {
1477
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1478
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1477
+            $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
1478
+            $message = __(get_option('registration_success_email_content'), 'geodirectory');
1479 1479
             $login_details = $to_message;
1480 1480
         }
1481 1481
         $to_message = nl2br($to_message);
@@ -1509,18 +1509,18 @@  discard block
 block discarded – undo
1509 1509
         $to = $toEmail;
1510 1510
 
1511 1511
         $sent = wp_mail($to, $subject, $message, $headers);
1512
-        if( ! $sent ) {
1513
-            if ( is_array( $to ) ) {
1514
-                $to = implode( ',', $to );
1512
+        if (!$sent) {
1513
+            if (is_array($to)) {
1514
+                $to = implode(',', $to);
1515 1515
             }
1516 1516
             $log_message = sprintf(
1517
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1517
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1518 1518
                 $message_type,
1519
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1519
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1520 1520
                 $to,
1521 1521
                 $subject
1522 1522
             );
1523
-            geodir_error_log( $log_message );
1523
+            geodir_error_log($log_message);
1524 1524
         }
1525 1525
 
1526 1526
         ///////// ADMIN BCC EMIALS
@@ -1546,20 +1546,20 @@  discard block
 block discarded – undo
1546 1546
             $admin_bcc = true;
1547 1547
         }
1548 1548
 
1549
-        if($admin_bcc === true){
1549
+        if ($admin_bcc === true) {
1550 1550
             $sent = wp_mail($to, $subject, $message, $headers);
1551
-            if( ! $sent ) {
1552
-                if ( is_array( $to ) ) {
1553
-                    $to = implode( ',', $to );
1551
+            if (!$sent) {
1552
+                if (is_array($to)) {
1553
+                    $to = implode(',', $to);
1554 1554
                 }
1555 1555
                 $log_message = sprintf(
1556
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1556
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1557 1557
                     $message_type,
1558
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1558
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
1559 1559
                     $to,
1560 1560
                     $subject
1561 1561
                 );
1562
-                geodir_error_log( $log_message );
1562
+                geodir_error_log($log_message);
1563 1563
             }
1564 1564
         }
1565 1565
 
@@ -1607,7 +1607,7 @@  discard block
 block discarded – undo
1607 1607
 function geodir_custom_posts_body_class($classes) {
1608 1608
     global $wpdb, $wp;
1609 1609
     $post_types = geodir_get_posttypes('object');
1610
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1610
+    if (!empty($post_types) && count((array) $post_types) > 1) {
1611 1611
         $classes[] = 'geodir_custom_posts';
1612 1612
     }
1613 1613
 
@@ -1901,7 +1901,7 @@  discard block
 block discarded – undo
1901 1901
         $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1902 1902
 			" . $join . "
1903 1903
 			" . $where;
1904
-        $rows = (int)$wpdb->get_var($sql);
1904
+        $rows = (int) $wpdb->get_var($sql);
1905 1905
     } else {
1906 1906
         $orderby = geodir_widget_listings_get_order($query_args);
1907 1907
         /**
@@ -1927,10 +1927,10 @@  discard block
 block discarded – undo
1927 1927
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1928 1928
 
1929 1929
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1930
-        if ( !$page )
1930
+        if (!$page)
1931 1931
             $page = 1;
1932 1932
 
1933
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1933
+        $limit = (int) $limit > 0 ? " LIMIT " . absint(($page - 1) * (int) $limit) . ", " . (int) $limit : "";
1934 1934
 
1935 1935
         $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
1936 1936
 			" . $join . "
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
         }
2046 2046
 
2047 2047
         if (!empty($query_args['post_author'])) {
2048
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2048
+            $where .= " AND " . $wpdb->posts . ".post_author = " . (int) $query_args['post_author'];
2049 2049
         }
2050 2050
         
2051 2051
         if (!empty($query_args['show_featured_only'])) {
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
     }
2132 2132
 
2133 2133
     if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2134
-        $limit = (int)$query_args['posts_per_page'];
2134
+        $limit = (int) $query_args['posts_per_page'];
2135 2135
     }
2136 2136
 
2137 2137
     return $limit;
@@ -2274,9 +2274,9 @@  discard block
 block discarded – undo
2274 2274
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2275 2275
     }
2276 2276
     $home_url = str_replace("www.", "", $home_url);
2277
-    if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
2277
+    if ((strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page'))) {
2278 2278
         return true;
2279
-    }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2279
+    }elseif (get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page')) {
2280 2280
         return true;
2281 2281
     } else {
2282 2282
         return false;
@@ -2359,7 +2359,7 @@  discard block
 block discarded – undo
2359 2359
 
2360 2360
     $gd_post_type = geodir_get_current_posttype();
2361 2361
 
2362
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2362
+    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
2363 2363
     $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2364 2364
 
2365 2365
     $taxonomy = array();
@@ -2392,14 +2392,14 @@  discard block
 block discarded – undo
2392 2392
             foreach ($b_terms as $key => $val) {
2393 2393
                 $ptype = get_post_type_object(str_replace("category", "", $key));
2394 2394
                 $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2395
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2395
+                $tax_change_output .= "<option value='$key' " . selected($key, $default_taxonomy, false) . ">" . sprintf(__('%s Categories', 'geodirectory'), $cpt_name) . "</option>";
2396 2396
             }
2397 2397
             $tax_change_output .= "</select>";
2398 2398
         }
2399 2399
 
2400 2400
         if (!empty($b_terms)) {
2401
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2402
-            global $cat_count;//make global so we can change via function
2401
+            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array
2402
+            global $cat_count; //make global so we can change via function
2403 2403
             $cat_count = 0;
2404 2404
             ?>
2405 2405
             <div class="geodir-category-list-in clearfix">
@@ -2463,7 +2463,7 @@  discard block
 block discarded – undo
2463 2463
         $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2464 2464
         $total_post = $cat->count;
2465 2465
 
2466
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2466
+        $term_link = get_term_link($cat, $cat->taxonomy);
2467 2467
         /**
2468 2468
          * Filer the category term link.
2469 2469
          *
@@ -2472,7 +2472,7 @@  discard block
 block discarded – undo
2472 2472
          * @param int    $cat->term_id The term id.
2473 2473
          * @param string $post_type Wordpress post type.
2474 2474
          */
2475
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2475
+        $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
2476 2476
 
2477 2477
         echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2478 2478
         echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
@@ -2606,29 +2606,29 @@  discard block
 block discarded – undo
2606 2606
                 itemWidth: 75,
2607 2607
                 itemMargin: 5,
2608 2608
                 asNavFor: '#geodir_widget_slider',
2609
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2609
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2610 2610
             });
2611 2611
 
2612 2612
             jQuery('#geodir_widget_slider').flexslider({
2613
-                animation: "<?php echo $animation;?>",
2613
+                animation: "<?php echo $animation; ?>",
2614 2614
                 selector: ".geodir-slides > li",
2615 2615
                 namespace: "geodir-",
2616 2616
                 controlNav: true,
2617
-                animationLoop: <?php echo $animationLoop;?>,
2618
-                slideshow: <?php echo $slideshow;?>,
2619
-                slideshowSpeed: <?php echo $slideshowSpeed;?>,
2620
-                animationSpeed: <?php echo $animationSpeed;?>,
2621
-                directionNav: <?php echo $directionNav;?>,
2622
-                maxItems: <?php echo $max_show;?>,
2617
+                animationLoop: <?php echo $animationLoop; ?>,
2618
+                slideshow: <?php echo $slideshow; ?>,
2619
+                slideshowSpeed: <?php echo $slideshowSpeed; ?>,
2620
+                animationSpeed: <?php echo $animationSpeed; ?>,
2621
+                directionNav: <?php echo $directionNav; ?>,
2622
+                maxItems: <?php echo $max_show; ?>,
2623 2623
                 move: 1,
2624
-                <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
2624
+                <?php if ($slide_width) { echo "itemWidth: " . $slide_width . ","; }?>
2625 2625
                 sync: "#geodir_widget_carousel",
2626 2626
                 start: function (slider) {
2627 2627
                     jQuery('.geodir-listing-flex-loader').hide();
2628 2628
                     jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
2629 2629
                     jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
2630 2630
                 },
2631
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2631
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2632 2632
             });
2633 2633
         });
2634 2634
     </script>
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
 
2670 2670
         global $post;
2671 2671
 
2672
-        $current_post = $post;// keep current post info
2672
+        $current_post = $post; // keep current post info
2673 2673
 
2674 2674
         $widget_main_slides = '';
2675 2675
         $nav_slides = '';
@@ -3112,7 +3112,7 @@  discard block
 block discarded – undo
3112 3112
             $geodir_add_location_url = '1';
3113 3113
         }
3114 3114
 
3115
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3115
+        $viewall_url = get_term_link((int) $category[0], $post_type . 'category');
3116 3116
 
3117 3117
         $geodir_add_location_url = NULL;
3118 3118
     }
@@ -3120,7 +3120,7 @@  discard block
 block discarded – undo
3120 3120
         $gd_session->set('gd_multi_location', 1);
3121 3121
     }
3122 3122
 
3123
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3123
+    if (is_wp_error($viewall_url)) {$viewall_url = ''; }
3124 3124
 
3125 3125
     $query_args = array(
3126 3126
         'posts_per_page' => $post_number,
@@ -3358,14 +3358,14 @@  discard block
 block discarded – undo
3358 3358
  * @package GeoDirectory
3359 3359
  * @return bool
3360 3360
  */
3361
-function geodir_term_review_count_force_update($new_status, $old_status='', $post='')
3361
+function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '')
3362 3362
 {
3363
-    if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
3363
+    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {return; }//do not run if importing listings
3364 3364
 
3365
-    if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
3365
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
3366 3366
         return;
3367 3367
     }
3368
-    if($new_status!=$old_status) {
3368
+    if ($new_status != $old_status) {
3369 3369
         geodir_count_reviews_by_terms(true);
3370 3370
     }
3371 3371
     return true;
@@ -3530,7 +3530,7 @@  discard block
 block discarded – undo
3530 3530
          */
3531 3531
         try {
3532 3532
             require_once($language_file);
3533
-        } catch(Exception $e) {
3533
+        } catch (Exception $e) {
3534 3534
             error_log('Language Error: ' . $e->getMessage());
3535 3535
         }
3536 3536
     }
@@ -3548,18 +3548,18 @@  discard block
 block discarded – undo
3548 3548
  */
3549 3549
 function geodirectory_load_db_language() {
3550 3550
     global $wp_filesystem;
3551
-    if( empty( $wp_filesystem ) ) {
3552
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3551
+    if (empty($wp_filesystem)) {
3552
+        require_once(ABSPATH . '/wp-admin/includes/file.php');
3553 3553
         WP_Filesystem();
3554 3554
         global $wp_filesystem;
3555 3555
     }
3556 3556
 
3557 3557
     $language_file = geodir_plugin_path() . '/db-language.php';
3558 3558
 
3559
-    if(is_file($language_file) && !is_writable($language_file))
3559
+    if (is_file($language_file) && !is_writable($language_file))
3560 3560
         return false; // Not possible to create.
3561 3561
 
3562
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3562
+    if (!is_file($language_file) && !is_writable(dirname($language_file)))
3563 3563
         return false; // Not possible to create.
3564 3564
 
3565 3565
     $contents_strings = array();
@@ -3593,7 +3593,7 @@  discard block
 block discarded – undo
3593 3593
     $contents = implode(PHP_EOL, $contents_head);
3594 3594
 
3595 3595
     if (!empty($contents_strings)) {
3596
-        foreach ( $contents_strings as $string ) {
3596
+        foreach ($contents_strings as $string) {
3597 3597
             if (is_scalar($string) && $string != '') {
3598 3598
                 $string = str_replace("'", "\'", $string);
3599 3599
                 $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
@@ -3603,7 +3603,7 @@  discard block
 block discarded – undo
3603 3603
 
3604 3604
     $contents .= implode(PHP_EOL, $contents_foot);
3605 3605
 
3606
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3606
+    if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE))
3607 3607
         return false; // Failure; could not write file.
3608 3608
 
3609 3609
     return true;
@@ -3629,7 +3629,7 @@  discard block
 block discarded – undo
3629 3629
     $rows = $wpdb->get_results($sql);
3630 3630
 
3631 3631
     if (!empty($rows)) {
3632
-        foreach($rows as $row) {
3632
+        foreach ($rows as $row) {
3633 3633
             if (!empty($row->admin_title))
3634 3634
                 $translation_texts[] = stripslashes_deep($row->admin_title);
3635 3635
 			
@@ -3667,7 +3667,7 @@  discard block
 block discarded – undo
3667 3667
     $rows = $wpdb->get_results($sql);
3668 3668
 
3669 3669
     if (!empty($rows)) {
3670
-        foreach($rows as $row) {
3670
+        foreach ($rows as $row) {
3671 3671
             if (!empty($row->site_title))
3672 3672
                 $translation_texts[] = stripslashes_deep($row->site_title);
3673 3673
 
@@ -3685,7 +3685,7 @@  discard block
 block discarded – undo
3685 3685
 		$rows = $wpdb->get_results($sql);
3686 3686
 
3687 3687
 		if (!empty($rows)) {
3688
-			foreach($rows as $row) {
3688
+			foreach ($rows as $row) {
3689 3689
 				if (!empty($row->field_site_name))
3690 3690
 					$translation_texts[] = stripslashes_deep($row->field_site_name);
3691 3691
 
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
      *
3721 3721
      * @param array $geodir_allowed_mime_types and file extensions.
3722 3722
      */
3723
-    return apply_filters( 'geodir_allowed_mime_types', array(
3723
+    return apply_filters('geodir_allowed_mime_types', array(
3724 3724
             'Image' => array( // Image formats.
3725 3725
                 'jpg' => 'image/jpeg',
3726 3726
                 'jpe' => 'image/jpeg',
@@ -3809,13 +3809,13 @@  discard block
 block discarded – undo
3809 3809
 
3810 3810
 
3811 3811
 
3812
-add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
3812
+add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
3813 3813
 /*
3814 3814
  * Add location variables to wpseo replacements.
3815 3815
  *
3816 3816
  * @since 1.5.4
3817 3817
  */
3818
-function geodir_wpseo_replacements($vars){
3818
+function geodir_wpseo_replacements($vars) {
3819 3819
 
3820 3820
     global $wp;
3821 3821
     $title = '';
@@ -3830,12 +3830,12 @@  discard block
 block discarded – undo
3830 3830
      * @param array $location_array The array of location variables.
3831 3831
      * @param array $vars The page title variables.
3832 3832
      */
3833
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
3833
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
3834 3834
     $location_titles = array();
3835
-    if(get_query_var( 'gd_country_full' )){
3836
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
3837
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
3838
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
3835
+    if (get_query_var('gd_country_full')) {
3836
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
3837
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
3838
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
3839 3839
     }
3840 3840
     $location_single = '';
3841 3841
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -3907,23 +3907,23 @@  discard block
 block discarded – undo
3907 3907
     }
3908 3908
 
3909 3909
 
3910
-    if(!empty($location_titles)) {
3910
+    if (!empty($location_titles)) {
3911 3911
         $vars['%%location%%'] = implode(", ", $location_titles);
3912 3912
     }
3913 3913
 
3914 3914
 
3915
-    if(!empty($location_titles)) {
3915
+    if (!empty($location_titles)) {
3916 3916
         $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
3917 3917
     }
3918 3918
 
3919 3919
 
3920 3920
 
3921
-    if($location_single) {
3922
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
3921
+    if ($location_single) {
3922
+        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' . $location_single;
3923 3923
     }
3924 3924
 
3925 3925
 
3926
-    if($location_single) {
3926
+    if ($location_single) {
3927 3927
         $vars['%%location_single%%'] = $location_single;
3928 3928
     }
3929 3929
 
@@ -3935,17 +3935,17 @@  discard block
 block discarded – undo
3935 3935
      * @param string $vars The title with variables.
3936 3936
      * @param array $location_array The array of location variables.
3937 3937
      */
3938
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3938
+    return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
3939 3939
 }
3940 3940
 
3941 3941
 
3942
-add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
3943
-add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
3944
-add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
3945
-function geodir_filter_title_variables($title, $gd_page, $sep=''){
3942
+add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
3943
+add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
3944
+add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
3945
+function geodir_filter_title_variables($title, $gd_page, $sep = '') {
3946 3946
 
3947 3947
 
3948
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
3948
+    if (!$gd_page || !$title) {return $title; }// if no a GD page then bail.
3949 3949
     global $post;
3950 3950
     //print_r($post);
3951 3951
     /*
@@ -3987,119 +3987,119 @@  discard block
 block discarded – undo
3987 3987
     }
3988 3988
 
3989 3989
 
3990
-    if(strpos($title,'%%title%%') !== false){
3991
-        $title = str_replace("%%title%%",$post->post_title,$title);
3990
+    if (strpos($title, '%%title%%') !== false) {
3991
+        $title = str_replace("%%title%%", $post->post_title, $title);
3992 3992
     }
3993 3993
 
3994
-    if(strpos($title,'%%sitename%%') !== false){
3995
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
3994
+    if (strpos($title, '%%sitename%%') !== false) {
3995
+        $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
3996 3996
     }
3997 3997
 
3998
-    if(strpos($title,'%%sitedesc%%') !== false){
3999
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
3998
+    if (strpos($title, '%%sitedesc%%') !== false) {
3999
+        $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4000 4000
     }
4001 4001
 
4002
-    if(strpos($title,'%%excerpt%%') !== false){
4003
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4002
+    if (strpos($title, '%%excerpt%%') !== false) {
4003
+        $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4004 4004
     }
4005 4005
 
4006
-    if(strpos($title,'%%pt_single%%') !== false){
4006
+    if (strpos($title, '%%pt_single%%') !== false) {
4007 4007
         $single_name = '';
4008
-        if($gd_page=='search' || $gd_page=='author'){
4008
+        if ($gd_page == 'search' || $gd_page == 'author') {
4009 4009
             $geodir_post_types = get_option('geodir_post_types');
4010 4010
             $spt = esc_attr($_REQUEST['stype']);
4011
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4012
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4011
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
4012
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
4013 4013
             }
4014
-        }elseif($gd_page=='add-listing'){
4014
+        }elseif ($gd_page == 'add-listing') {
4015 4015
             $geodir_post_types = get_option('geodir_post_types');
4016 4016
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4017
-            if(!$spt && isset($_REQUEST['pid'])){
4018
-                $spt = get_post_type( $_REQUEST['pid'] );
4017
+            if (!$spt && isset($_REQUEST['pid'])) {
4018
+                $spt = get_post_type($_REQUEST['pid']);
4019 4019
             }
4020
-            if(!$spt){$spt='gd_place';}
4021
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4022
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4020
+            if (!$spt) {$spt = 'gd_place'; }
4021
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
4022
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
4023 4023
             }
4024 4024
         }
4025
-        elseif($post->post_type){
4025
+        elseif ($post->post_type) {
4026 4026
             $geodir_post_types = get_option('geodir_post_types');
4027
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4028
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4027
+            if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) {
4028
+                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory');
4029 4029
             }
4030 4030
 
4031 4031
 
4032 4032
         }
4033
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4033
+        $title = str_replace("%%pt_single%%", $single_name, $title);
4034 4034
     }
4035 4035
 
4036
-    if(strpos($title,'%%pt_plural%%') !== false){
4036
+    if (strpos($title, '%%pt_plural%%') !== false) {
4037 4037
         $plural_name = '';
4038
-        if($gd_page=='search' || $gd_page=='author'){
4038
+        if ($gd_page == 'search' || $gd_page == 'author') {
4039 4039
             $geodir_post_types = get_option('geodir_post_types');
4040 4040
             $spt = esc_attr($_REQUEST['stype']);
4041
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4042
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4041
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4042
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4043 4043
             }
4044
-        }elseif($gd_page=='add-listing'){
4044
+        }elseif ($gd_page == 'add-listing') {
4045 4045
             $geodir_post_types = get_option('geodir_post_types');
4046 4046
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4047
-            if(!$spt){$spt='gd_place';}
4048
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4049
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4047
+            if (!$spt) {$spt = 'gd_place'; }
4048
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4049
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4050 4050
             }
4051 4051
         }
4052
-        elseif(isset($post->post_type) && $post->post_type){
4052
+        elseif (isset($post->post_type) && $post->post_type) {
4053 4053
             $geodir_post_types = get_option('geodir_post_types');
4054
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4055
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4054
+            if (isset($geodir_post_types[$post->post_type]['labels']['name'])) {
4055
+                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory');
4056 4056
             }
4057 4057
 
4058 4058
         }
4059
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4059
+        $title = str_replace("%%pt_plural%%", $plural_name, $title);
4060 4060
     }
4061 4061
 
4062 4062
 
4063 4063
 
4064
-    if(strpos($title,'%%category%%') !== false){
4064
+    if (strpos($title, '%%category%%') !== false) {
4065 4065
         $cat_name = '';
4066 4066
 
4067
-        if($gd_page=='detail') {
4067
+        if ($gd_page == 'detail') {
4068 4068
             if ($post->default_category) {
4069 4069
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4070 4070
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4071 4071
             }
4072
-        }elseif($gd_page=='listing'){
4072
+        }elseif ($gd_page == 'listing') {
4073 4073
             $queried_object = get_queried_object();
4074
-            if(isset($queried_object->name)){
4074
+            if (isset($queried_object->name)) {
4075 4075
                 $cat_name = $queried_object->name;
4076 4076
             }
4077 4077
         }
4078
-        $title = str_replace("%%category%%",$cat_name,$title);
4078
+        $title = str_replace("%%category%%", $cat_name, $title);
4079 4079
     }
4080 4080
 
4081
-    if(strpos($title,'%%tag%%') !== false){
4081
+    if (strpos($title, '%%tag%%') !== false) {
4082 4082
         $cat_name = '';
4083 4083
 
4084
-        if($gd_page=='detail') {
4084
+        if ($gd_page == 'detail') {
4085 4085
             if ($post->default_category) {
4086 4086
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4087 4087
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4088 4088
             }
4089
-        }elseif($gd_page=='listing'){
4089
+        }elseif ($gd_page == 'listing') {
4090 4090
             $queried_object = get_queried_object();
4091
-            if(isset($queried_object->name)){
4091
+            if (isset($queried_object->name)) {
4092 4092
                 $cat_name = $queried_object->name;
4093 4093
             }
4094 4094
         }
4095
-        $title = str_replace("%%tag%%",$cat_name,$title);
4095
+        $title = str_replace("%%tag%%", $cat_name, $title);
4096 4096
     }
4097 4097
 
4098 4098
 
4099 4099
 
4100
-    if(strpos($title,'%%id%%') !== false){
4100
+    if (strpos($title, '%%id%%') !== false) {
4101 4101
         $ID = (isset($post->ID)) ? $post->ID : '';
4102
-        $title = str_replace("%%id%%",$ID,$title);
4102
+        $title = str_replace("%%id%%", $ID, $title);
4103 4103
     }
4104 4104
 
4105 4105
     /*
@@ -4112,8 +4112,8 @@  discard block
 block discarded – undo
4112 4112
         }
4113 4113
     */
4114 4114
 
4115
-    if(strpos($title,'%%sep%%') !== false){
4116
-        $title = str_replace("%%sep%%",$sep,$title);
4115
+    if (strpos($title, '%%sep%%') !== false) {
4116
+        $title = str_replace("%%sep%%", $sep, $title);
4117 4117
     }
4118 4118
 
4119 4119
 
@@ -4131,12 +4131,12 @@  discard block
 block discarded – undo
4131 4131
      * @param string $gd_page The page being filtered.
4132 4132
      * @param string $sep The separator, default: `|`.
4133 4133
      */
4134
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4134
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
4135 4135
     $location_titles = array();
4136
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4137
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4138
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4139
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4136
+    if ($gd_page == 'location' && get_query_var('gd_country_full')) {
4137
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4138
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4139
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4140 4140
     }
4141 4141
     $location_single = '';
4142 4142
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4208,65 +4208,65 @@  discard block
 block discarded – undo
4208 4208
     }
4209 4209
 
4210 4210
 
4211
-    if(strpos($title,'%%location%%') !== false){
4211
+    if (strpos($title, '%%location%%') !== false) {
4212 4212
         $location = '';
4213
-        if($location_titles) {
4213
+        if ($location_titles) {
4214 4214
             $location = implode(", ", $location_titles);
4215 4215
         }
4216
-        $title = str_replace("%%location%%",$location,$title);
4216
+        $title = str_replace("%%location%%", $location, $title);
4217 4217
     }
4218 4218
 
4219
-    if(strpos($title,'%%in_location%%') !== false){
4219
+    if (strpos($title, '%%in_location%%') !== false) {
4220 4220
         $location = '';
4221
-        if($location_titles) {
4221
+        if ($location_titles) {
4222 4222
             $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4223 4223
         }
4224
-        $title = str_replace("%%in_location%%",$location,$title);
4224
+        $title = str_replace("%%in_location%%", $location, $title);
4225 4225
     }
4226 4226
 
4227
-    if(strpos($title,'%%in_location_single%%') !== false){
4228
-        if($location_single) {
4229
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4227
+    if (strpos($title, '%%in_location_single%%') !== false) {
4228
+        if ($location_single) {
4229
+            $location_single = __('in', 'geodirectory') . ' ' . $location_single;
4230 4230
         }
4231
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4231
+        $title = str_replace("%%in_location_single%%", $location_single, $title);
4232 4232
     }
4233 4233
 
4234
-    if(strpos($title,'%%location_single%%') !== false){
4235
-        $title = str_replace("%%location_single%%",$location_single,$title);
4234
+    if (strpos($title, '%%location_single%%') !== false) {
4235
+        $title = str_replace("%%location_single%%", $location_single, $title);
4236 4236
     }
4237 4237
 
4238 4238
 
4239
-    if(strpos($title,'%%search_term%%') !== false){
4239
+    if (strpos($title, '%%search_term%%') !== false) {
4240 4240
         $search_term = '';
4241
-        if(isset($_REQUEST['s'])){
4241
+        if (isset($_REQUEST['s'])) {
4242 4242
             $search_term = esc_attr($_REQUEST['s']);
4243 4243
         }
4244
-        $title = str_replace("%%search_term%%",$search_term,$title);
4244
+        $title = str_replace("%%search_term%%", $search_term, $title);
4245 4245
     }
4246 4246
 
4247
-    if(strpos($title,'%%search_near%%') !== false){
4247
+    if (strpos($title, '%%search_near%%') !== false) {
4248 4248
         $search_term = '';
4249
-        if(isset($_REQUEST['snear'])){
4249
+        if (isset($_REQUEST['snear'])) {
4250 4250
             $search_term = esc_attr($_REQUEST['snear']);
4251 4251
         }
4252
-        $title = str_replace("%%search_near%%",$search_term,$title);
4252
+        $title = str_replace("%%search_near%%", $search_term, $title);
4253 4253
     }
4254 4254
 
4255
-    if(strpos($title,'%%name%%') !== false){
4255
+    if (strpos($title, '%%name%%') !== false) {
4256 4256
         $author_name = '';
4257
-        if($author_name = get_the_author()){}
4258
-        else{
4257
+        if ($author_name = get_the_author()) {}
4258
+        else {
4259 4259
             $queried_object = get_queried_object();
4260
-            if(isset($queried_object->data->user_nicename)){
4260
+            if (isset($queried_object->data->user_nicename)) {
4261 4261
                 $author_name = $queried_object->data->user_nicename;
4262 4262
             }
4263 4263
         }
4264
-        $title = str_replace("%%name%%",$author_name,$title);
4264
+        $title = str_replace("%%name%%", $author_name, $title);
4265 4265
     }
4266 4266
 
4267
-    $title = wptexturize( $title );
4268
-    $title = convert_chars( $title );
4269
-    $title = esc_html( $title );
4267
+    $title = wptexturize($title);
4268
+    $title = convert_chars($title);
4269
+    $title = esc_html($title);
4270 4270
 
4271 4271
     /**
4272 4272
      * Filter the title variables after standard ones have been filtered.
@@ -4279,7 +4279,7 @@  discard block
 block discarded – undo
4279 4279
      * @param string $sep The separator, default: `|`.
4280 4280
      */
4281 4281
 
4282
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4282
+    return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
4283 4283
 }
4284 4284
 
4285 4285
 /**
@@ -4401,14 +4401,14 @@  discard block
 block discarded – undo
4401 4401
         return;
4402 4402
     }
4403 4403
     
4404
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4404
+    $is_admin = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
4405 4405
     $inline_save = isset($_POST['action']) && $_POST['action'] == 'inline-save' ? true : false;
4406 4406
 
4407 4407
     if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4408 4408
         return;
4409 4409
     }
4410 4410
 
4411
-    $user_id = (int)get_current_user_id();
4411
+    $user_id = (int) get_current_user_id();
4412 4412
         
4413 4413
     if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4414 4414
         $author_id = !empty($post->post_author) ? $post->post_author : 0;
Please login to merge, or discard this patch.
Indentation   +2948 added lines, -2948 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin general functions
4
- *
5
- * @since 1.0.0
6
- * @package GeoDirectory
7
- */
3
+	 * Plugin general functions
4
+	 *
5
+	 * @since 1.0.0
6
+	 * @package GeoDirectory
7
+	 */
8 8
 
9 9
 
10 10
 /**
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 function geodir_plugin_url()
29 29
 {
30 30
 
31
-    if (is_ssl()) :
32
-        return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
-    else :
34
-        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
35
-    endif;
31
+	if (is_ssl()) :
32
+		return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
+	else :
34
+		return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
35
+	endif;
36 36
 }
37 37
 
38 38
 
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_plugin_path()
49 49
 {
50
-    if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
51
-        return dirname(dirname(__FILE__));
52
-    } else {
53
-        return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
54
-    }
50
+	if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
51
+		return dirname(dirname(__FILE__));
52
+	} else {
53
+		return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
54
+	}
55 55
 }
56 56
 
57 57
 /**
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
  */
66 66
 function geodir_is_plugin_active($plugin)
67 67
 {
68
-    $active_plugins = get_option('active_plugins');
69
-    foreach ($active_plugins as $key => $active_plugin) {
70
-        if (strstr($active_plugin, $plugin)) return true;
71
-    }
72
-    return false;
68
+	$active_plugins = get_option('active_plugins');
69
+	foreach ($active_plugins as $key => $active_plugin) {
70
+		if (strstr($active_plugin, $plugin)) return true;
71
+	}
72
+	return false;
73 73
 }
74 74
 
75 75
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_get_formated_date($date)
87 87
 {
88
-    return mysql2date(get_option('date_format'), $date);
88
+	return mysql2date(get_option('date_format'), $date);
89 89
 }
90 90
 
91 91
 /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_get_formated_time($time)
102 102
 {
103
-    return mysql2date(get_option('time_format'), $time, $translate = true);
103
+	return mysql2date(get_option('time_format'), $time, $translate = true);
104 104
 }
105 105
 
106 106
 
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function geodir_getlink($url, $params = array(), $use_existing_arguments = false)
120 120
 {
121
-    if ($use_existing_arguments) $params = $params + $_GET;
122
-    if (!$params) return $url;
123
-    $link = $url;
124
-    if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
-    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
126
-    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
127
-
128
-    $params_arr = array();
129
-    foreach ($params as $key => $value) {
130
-        if (gettype($value) == 'array') { //Handle array data properly
131
-            foreach ($value as $val) {
132
-                $params_arr[] = $key . '[]=' . urlencode($val);
133
-            }
134
-        } else {
135
-            $params_arr[] = $key . '=' . urlencode($value);
136
-        }
137
-    }
138
-    $link .= implode('&', $params_arr);
121
+	if ($use_existing_arguments) $params = $params + $_GET;
122
+	if (!$params) return $url;
123
+	$link = $url;
124
+	if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
+	elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
126
+	elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
127
+
128
+	$params_arr = array();
129
+	foreach ($params as $key => $value) {
130
+		if (gettype($value) == 'array') { //Handle array data properly
131
+			foreach ($value as $val) {
132
+				$params_arr[] = $key . '[]=' . urlencode($val);
133
+			}
134
+		} else {
135
+			$params_arr[] = $key . '=' . urlencode($value);
136
+		}
137
+	}
138
+	$link .= implode('&', $params_arr);
139 139
 
140
-    return $link;
140
+	return $link;
141 141
 }
142 142
 
143 143
 
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
  */
153 153
 function geodir_get_addlisting_link($post_type = '')
154 154
 {
155
-    global $wpdb;
155
+	global $wpdb;
156 156
 
157
-    //$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
158
-    $check_pkg = 1;
159
-    if (post_type_exists($post_type) && $check_pkg) {
157
+	//$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
158
+	$check_pkg = 1;
159
+	if (post_type_exists($post_type) && $check_pkg) {
160 160
 
161
-        $add_listing_link = get_page_link(geodir_add_listing_page_id());
161
+		$add_listing_link = get_page_link(geodir_add_listing_page_id());
162 162
 
163
-        return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
-    } else
165
-        return get_bloginfo('url');
163
+		return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
+	} else
165
+		return get_bloginfo('url');
166 166
 }
167 167
 
168 168
 /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
  */
176 176
 function geodir_curPageURL()
177 177
 {
178
-    $pageURL = 'http';
179
-    if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
180
-        $pageURL .= "s";
181
-    }
182
-    $pageURL .= "://";
183
-    $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
184
-    /**
185
-     * Filter the current page URL returned by function geodir_curPageURL().
186
-     *
187
-     * @since 1.4.1
188
-     * @param string $pageURL The URL of the current page.
189
-     */
190
-    return apply_filters('geodir_curPageURL', $pageURL);
178
+	$pageURL = 'http';
179
+	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
180
+		$pageURL .= "s";
181
+	}
182
+	$pageURL .= "://";
183
+	$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
184
+	/**
185
+	 * Filter the current page URL returned by function geodir_curPageURL().
186
+	 *
187
+	 * @since 1.4.1
188
+	 * @param string $pageURL The URL of the current page.
189
+	 */
190
+	return apply_filters('geodir_curPageURL', $pageURL);
191 191
 }
192 192
 
193 193
 
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 function geodir_clean($string)
205 205
 {
206 206
 
207
-    $string = trim(strip_tags(stripslashes($string)));
208
-    $string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
209
-    $string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
210
-    $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
207
+	$string = trim(strip_tags(stripslashes($string)));
208
+	$string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
209
+	$string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
210
+	$string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
211 211
 
212
-    return $string;
212
+	return $string;
213 213
 }
214 214
 
215 215
 /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  */
222 222
 function geodir_get_weekday()
223 223
 {
224
-    return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
224
+	return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
225 225
 }
226 226
 
227 227
 /**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function geodir_get_weeks()
235 235
 {
236
-    return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
236
+	return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
237 237
 }
238 238
 
239 239
 
@@ -252,103 +252,103 @@  discard block
 block discarded – undo
252 252
 function geodir_is_page($gdpage = '')
253 253
 {
254 254
 
255
-    global $wp_query, $post,$wp;
256
-    //if(!is_admin()):
257
-
258
-    switch ($gdpage):
259
-        case 'add-listing':
260
-
261
-            if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
262
-                return true;
263
-            } elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
264
-                return true;
265
-            }
266
-
267
-            break;
268
-        case 'preview':
269
-            if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270
-                && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
-            )
272
-                return true;
273
-            break;
274
-        case 'listing-success':
275
-            if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
-                return true;
277
-            break;
278
-        case 'detail':
279
-            $post_type = get_query_var('post_type');
280
-            if(is_array($post_type)){$post_type = reset($post_type);}
281
-            if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
-                return true;
283
-            break;
284
-        case 'pt':
285
-            $post_type = get_query_var('post_type');
286
-            if(is_array($post_type)){$post_type = reset($post_type);}
287
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
-                return true;
289
-
290
-            break;
291
-        case 'listing':
292
-            if (is_tax() && geodir_get_taxonomy_posttype()) {
293
-                global $current_term, $taxonomy, $term;
294
-
295
-                return true;
296
-            }
297
-            $post_type = get_query_var('post_type');
298
-            if(is_array($post_type)){$post_type = reset($post_type);}
299
-            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
-                return true;
301
-
302
-            break;
303
-        case 'home':
304
-
305
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
-                return true;
307
-
308
-            break;
309
-        case 'location':
310
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
-                return true;
312
-            break;
313
-        case 'author':
314
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
-                return true;
255
+	global $wp_query, $post,$wp;
256
+	//if(!is_admin()):
257
+
258
+	switch ($gdpage):
259
+		case 'add-listing':
260
+
261
+			if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
262
+				return true;
263
+			} elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
264
+				return true;
265
+			}
266
+
267
+			break;
268
+		case 'preview':
269
+			if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270
+				&& in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
+			)
272
+				return true;
273
+			break;
274
+		case 'listing-success':
275
+			if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
+				return true;
277
+			break;
278
+		case 'detail':
279
+			$post_type = get_query_var('post_type');
280
+			if(is_array($post_type)){$post_type = reset($post_type);}
281
+			if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
+				return true;
283
+			break;
284
+		case 'pt':
285
+			$post_type = get_query_var('post_type');
286
+			if(is_array($post_type)){$post_type = reset($post_type);}
287
+			if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
+				return true;
289
+
290
+			break;
291
+		case 'listing':
292
+			if (is_tax() && geodir_get_taxonomy_posttype()) {
293
+				global $current_term, $taxonomy, $term;
294
+
295
+				return true;
296
+			}
297
+			$post_type = get_query_var('post_type');
298
+			if(is_array($post_type)){$post_type = reset($post_type);}
299
+			if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
+				return true;
301
+
302
+			break;
303
+		case 'home':
304
+
305
+			if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
+				return true;
307
+
308
+			break;
309
+		case 'location':
310
+			if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
+				return true;
312
+			break;
313
+		case 'author':
314
+			if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
+				return true;
316 316
 			
317 317
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
318 318
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
319 319
 					return true;
320 320
 				}
321 321
 			}
322
-            break;
323
-        case 'search':
324
-            if (is_search() && isset($_REQUEST['geodir_search']))
325
-                return true;
326
-            break;
327
-        case 'info':
328
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
-                return true;
330
-            break;
331
-        case 'login':
332
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
-                return true;
334
-            break;
335
-        case 'checkout':
336
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
-                return true;
338
-            break;
339
-        case 'invoices':
340
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
-                return true;
342
-            break;
343
-        default:
344
-            return false;
345
-            break;
346
-
347
-    endswitch;
348
-
349
-    //endif;
350
-
351
-    return false;
322
+			break;
323
+		case 'search':
324
+			if (is_search() && isset($_REQUEST['geodir_search']))
325
+				return true;
326
+			break;
327
+		case 'info':
328
+			if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
+				return true;
330
+			break;
331
+		case 'login':
332
+			if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
+				return true;
334
+			break;
335
+		case 'checkout':
336
+			if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
+				return true;
338
+			break;
339
+		case 'invoices':
340
+			if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
+				return true;
342
+			break;
343
+		default:
344
+			return false;
345
+			break;
346
+
347
+	endswitch;
348
+
349
+	//endif;
350
+
351
+	return false;
352 352
 }
353 353
 
354 354
 /**
@@ -362,97 +362,97 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function geodir_set_is_geodir_page($wp)
364 364
 {
365
-    if (!is_admin()) {
366
-        //$wp->query_vars['gd_is_geodir_page'] = false;
367
-        //print_r()
368
-        if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
-            if (get_option('geodir_set_as_home'))
370
-                $wp->query_vars['gd_is_geodir_page'] = true;
371
-            if(geodir_is_page('home')){
372
-                $wp->query_vars['gd_is_geodir_page'] = true;
373
-            }
365
+	if (!is_admin()) {
366
+		//$wp->query_vars['gd_is_geodir_page'] = false;
367
+		//print_r()
368
+		if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
+			if (get_option('geodir_set_as_home'))
370
+				$wp->query_vars['gd_is_geodir_page'] = true;
371
+			if(geodir_is_page('home')){
372
+				$wp->query_vars['gd_is_geodir_page'] = true;
373
+			}
374 374
 
375 375
 
376
-        }
376
+		}
377 377
 
378
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
379
-            if (
380
-                $wp->query_vars['page_id'] == geodir_add_listing_page_id()
381
-                || $wp->query_vars['page_id'] == geodir_preview_page_id()
382
-                || $wp->query_vars['page_id'] == geodir_success_page_id()
383
-                || $wp->query_vars['page_id'] == geodir_location_page_id()
384
-                || $wp->query_vars['page_id'] == geodir_home_page_id()
385
-                || $wp->query_vars['page_id'] == geodir_info_page_id()
386
-                || $wp->query_vars['page_id'] == geodir_login_page_id()
387
-                || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388
-                || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
-            )
390
-                $wp->query_vars['gd_is_geodir_page'] = true;
391
-        }
378
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
379
+			if (
380
+				$wp->query_vars['page_id'] == geodir_add_listing_page_id()
381
+				|| $wp->query_vars['page_id'] == geodir_preview_page_id()
382
+				|| $wp->query_vars['page_id'] == geodir_success_page_id()
383
+				|| $wp->query_vars['page_id'] == geodir_location_page_id()
384
+				|| $wp->query_vars['page_id'] == geodir_home_page_id()
385
+				|| $wp->query_vars['page_id'] == geodir_info_page_id()
386
+				|| $wp->query_vars['page_id'] == geodir_login_page_id()
387
+				|| (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388
+				|| (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
+			)
390
+				$wp->query_vars['gd_is_geodir_page'] = true;
391
+		}
392 392
 
393
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
394
-            $page = get_page_by_path($wp->query_vars['pagename']);
395
-
396
-            if (!empty($page) && (
397
-                    $page->ID == geodir_add_listing_page_id()
398
-                    || $page->ID == geodir_preview_page_id()
399
-                    || $page->ID == geodir_success_page_id()
400
-                    || $page->ID == geodir_location_page_id()
401
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
402
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
403
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
404
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406
-                )
407
-            )
408
-                $wp->query_vars['gd_is_geodir_page'] = true;
409
-        }
393
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
394
+			$page = get_page_by_path($wp->query_vars['pagename']);
395
+
396
+			if (!empty($page) && (
397
+					$page->ID == geodir_add_listing_page_id()
398
+					|| $page->ID == geodir_preview_page_id()
399
+					|| $page->ID == geodir_success_page_id()
400
+					|| $page->ID == geodir_location_page_id()
401
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
402
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
403
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
404
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406
+				)
407
+			)
408
+				$wp->query_vars['gd_is_geodir_page'] = true;
409
+		}
410 410
 
411 411
 
412
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
413
-            $requested_post_type = $wp->query_vars['post_type'];
414
-            // check if this post type is geodirectory post types 
415
-            $post_type_array = geodir_get_posttypes();
416
-            if (in_array($requested_post_type, $post_type_array)) {
417
-                $wp->query_vars['gd_is_geodir_page'] = true;
418
-            }
419
-        }
412
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
413
+			$requested_post_type = $wp->query_vars['post_type'];
414
+			// check if this post type is geodirectory post types 
415
+			$post_type_array = geodir_get_posttypes();
416
+			if (in_array($requested_post_type, $post_type_array)) {
417
+				$wp->query_vars['gd_is_geodir_page'] = true;
418
+			}
419
+		}
420 420
 
421
-        if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422
-            $geodir_taxonomis = geodir_get_taxonomies('', true);
423
-            if(!empty($geodir_taxonomis)){
424
-                foreach ($geodir_taxonomis as $taxonomy) {
425
-                    if (array_key_exists($taxonomy, $wp->query_vars)) {
426
-                        $wp->query_vars['gd_is_geodir_page'] = true;
427
-                        break;
428
-                    }
429
-                }
430
-            }
421
+		if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422
+			$geodir_taxonomis = geodir_get_taxonomies('', true);
423
+			if(!empty($geodir_taxonomis)){
424
+				foreach ($geodir_taxonomis as $taxonomy) {
425
+					if (array_key_exists($taxonomy, $wp->query_vars)) {
426
+						$wp->query_vars['gd_is_geodir_page'] = true;
427
+						break;
428
+					}
429
+				}
430
+			}
431 431
 
432
-        }
432
+		}
433 433
 
434
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
-            $wp->query_vars['gd_is_geodir_page'] = true;
434
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
+			$wp->query_vars['gd_is_geodir_page'] = true;
436 436
 
437 437
 
438
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
-            $wp->query_vars['gd_is_geodir_page'] = true;
438
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
+			$wp->query_vars['gd_is_geodir_page'] = true;
440 440
 
441 441
 
442 442
 //check if homepage
443
-        if(!isset($wp->query_vars['gd_is_geodir_page'])
444
-            && !isset($wp->query_vars['page_id'])
445
-            && !isset($wp->query_vars['pagename'])
446
-            && is_page_geodir_home()){
447
-            $wp->query_vars['gd_is_geodir_page'] = true;
448
-        }
449
-        //echo $wp->query_vars['gd_is_geodir_page'] ;
450
-        /*echo "<pre>" ;
443
+		if(!isset($wp->query_vars['gd_is_geodir_page'])
444
+			&& !isset($wp->query_vars['page_id'])
445
+			&& !isset($wp->query_vars['pagename'])
446
+			&& is_page_geodir_home()){
447
+			$wp->query_vars['gd_is_geodir_page'] = true;
448
+		}
449
+		//echo $wp->query_vars['gd_is_geodir_page'] ;
450
+		/*echo "<pre>" ;
451 451
 		print_r($wp) ;
452 452
 		echo "</pre>" ;
453 453
 	//	exit();
454 454
 			*/
455
-    } // end of is admin
455
+	} // end of is admin
456 456
 }
457 457
 
458 458
 /**
@@ -465,56 +465,56 @@  discard block
 block discarded – undo
465 465
  */
466 466
 function geodir_is_geodir_page()
467 467
 {
468
-    global $wp;
469
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
-        return true;
471
-    else
472
-        return false;
468
+	global $wp;
469
+	if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
+		return true;
471
+	else
472
+		return false;
473 473
 }
474 474
 
475 475
 if (!function_exists('geodir_get_imagesize')) {
476
-    /**
477
-     * Get image size using the size key .
478
-     *
479
-     * @since 1.0.0
480
-     * @package GeoDirectory
481
-     * @param string $size The image size key.
482
-     * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
483
-     */
484
-    function geodir_get_imagesize($size = '')
485
-    {
486
-
487
-        $imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
488
-            'thumbnail' => array('w' => 125, 'h' => 125),
489
-            'widget-thumb' => array('w' => 50, 'h' => 50),
490
-            'slider-thumb' => array('w' => 100, 'h' => 100)
491
-        );
492
-
493
-        /**
494
-         * Filter the image sizes array.
495
-         *
496
-         * @since 1.0.0
497
-         * @param array $imagesizes Image size array.
498
-         */
499
-        $imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
500
-
501
-        if (!empty($size) && array_key_exists($size, $imagesizes)) {
502
-            /**
503
-             * Filters image size of the passed key.
504
-             *
505
-             * @since 1.0.0
506
-             * @param array $imagesizes[$size] Image size array of the passed key.
507
-             */
508
-            return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
509
-
510
-        } elseif (!empty($size)) {
511
-
512
-            return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
476
+	/**
477
+	 * Get image size using the size key .
478
+	 *
479
+	 * @since 1.0.0
480
+	 * @package GeoDirectory
481
+	 * @param string $size The image size key.
482
+	 * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
483
+	 */
484
+	function geodir_get_imagesize($size = '')
485
+	{
486
+
487
+		$imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
488
+			'thumbnail' => array('w' => 125, 'h' => 125),
489
+			'widget-thumb' => array('w' => 50, 'h' => 50),
490
+			'slider-thumb' => array('w' => 100, 'h' => 100)
491
+		);
492
+
493
+		/**
494
+		 * Filter the image sizes array.
495
+		 *
496
+		 * @since 1.0.0
497
+		 * @param array $imagesizes Image size array.
498
+		 */
499
+		$imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
500
+
501
+		if (!empty($size) && array_key_exists($size, $imagesizes)) {
502
+			/**
503
+			 * Filters image size of the passed key.
504
+			 *
505
+			 * @since 1.0.0
506
+			 * @param array $imagesizes[$size] Image size array of the passed key.
507
+			 */
508
+			return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
509
+
510
+		} elseif (!empty($size)) {
511
+
512
+			return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
513 513
 
514
-        }
514
+		}
515 515
 
516
-        return $imagesizes;
517
-    }
516
+		return $imagesizes;
517
+	}
518 518
 }
519 519
 
520 520
 /**
@@ -534,151 +534,151 @@  discard block
 block discarded – undo
534 534
 
535 535
 
536 536
 if (!function_exists('createRandomString')) {
537
-    /**
538
-     * Creates random string.
539
-     *
540
-     * @since 1.0.0
541
-     * @package GeoDirectory
542
-     * @return string Random string.
543
-     */
544
-    function createRandomString()
545
-    {
546
-        $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
-        srand((double)microtime() * 1000000);
548
-        $i = 0;
549
-        $rstring = '';
550
-        while ($i <= 25) {
551
-            $num = rand() % 33;
552
-            $tmp = substr($chars, $num, 1);
553
-            $rstring = $rstring . $tmp;
554
-            $i++;
555
-        }
556
-        return $rstring;
557
-    }
537
+	/**
538
+	 * Creates random string.
539
+	 *
540
+	 * @since 1.0.0
541
+	 * @package GeoDirectory
542
+	 * @return string Random string.
543
+	 */
544
+	function createRandomString()
545
+	{
546
+		$chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
+		srand((double)microtime() * 1000000);
548
+		$i = 0;
549
+		$rstring = '';
550
+		while ($i <= 25) {
551
+			$num = rand() % 33;
552
+			$tmp = substr($chars, $num, 1);
553
+			$rstring = $rstring . $tmp;
554
+			$i++;
555
+		}
556
+		return $rstring;
557
+	}
558 558
 }
559 559
 
560 560
 if (!function_exists('geodir_getDistanceRadius')) {
561
-    /**
562
-     * Calculates the distance radius.
563
-     *
564
-     * @since 1.0.0
565
-     * @package GeoDirectory
566
-     * @param string $uom Measurement unit type.
567
-     * @return float The mean radius.
568
-     */
569
-    function geodir_getDistanceRadius($uom = 'km')
570
-    {
561
+	/**
562
+	 * Calculates the distance radius.
563
+	 *
564
+	 * @since 1.0.0
565
+	 * @package GeoDirectory
566
+	 * @param string $uom Measurement unit type.
567
+	 * @return float The mean radius.
568
+	 */
569
+	function geodir_getDistanceRadius($uom = 'km')
570
+	{
571 571
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
572
-        switch (geodir_strtolower($uom)):
573
-            case 'km'    :
574
-                $earthMeanRadius = 6371.009; // km
575
-                break;
576
-            case 'm'    :
577
-            case 'meters'    :
578
-                $earthMeanRadius = 6371.009 * 1000; // km
579
-                break;
580
-            case 'miles'    :
581
-                $earthMeanRadius = 3958.761; // miles
582
-                break;
583
-            case 'yards'    :
584
-            case 'yds'    :
585
-                $earthMeanRadius = 3958.761 * 1760; // yards
586
-                break;
587
-            case 'feet'    :
588
-            case 'ft'    :
589
-                $earthMeanRadius = 3958.761 * 1760 * 3; // feet
590
-                break;
591
-            case 'nm'    :
592
-                $earthMeanRadius = 3440.069; //  miles
593
-                break;
594
-            default:
595
-                $earthMeanRadius = 3958.761; // miles
596
-                break;
597
-        endswitch;
598
-        return $earthMeanRadius;
599
-    }
572
+		switch (geodir_strtolower($uom)):
573
+			case 'km'    :
574
+				$earthMeanRadius = 6371.009; // km
575
+				break;
576
+			case 'm'    :
577
+			case 'meters'    :
578
+				$earthMeanRadius = 6371.009 * 1000; // km
579
+				break;
580
+			case 'miles'    :
581
+				$earthMeanRadius = 3958.761; // miles
582
+				break;
583
+			case 'yards'    :
584
+			case 'yds'    :
585
+				$earthMeanRadius = 3958.761 * 1760; // yards
586
+				break;
587
+			case 'feet'    :
588
+			case 'ft'    :
589
+				$earthMeanRadius = 3958.761 * 1760 * 3; // feet
590
+				break;
591
+			case 'nm'    :
592
+				$earthMeanRadius = 3440.069; //  miles
593
+				break;
594
+			default:
595
+				$earthMeanRadius = 3958.761; // miles
596
+				break;
597
+		endswitch;
598
+		return $earthMeanRadius;
599
+	}
600 600
 }
601 601
 
602 602
 
603 603
 if (!function_exists('geodir_calculateDistanceFromLatLong')) {
604
-    /**
605
-     * Calculate the great circle distance between two points identified by longitude and latitude.
606
-     *
607
-     * @since 1.0.0
608
-     * @package GeoDirectory
609
-     * @param array $point1 Latitude and Longitude of point 1.
610
-     * @param array $point2 Latitude and Longitude of point 2.
611
-     * @param string $uom Unit of measurement.
612
-     * @return float The distance.
613
-     */
614
-    function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
615
-    {
604
+	/**
605
+	 * Calculate the great circle distance between two points identified by longitude and latitude.
606
+	 *
607
+	 * @since 1.0.0
608
+	 * @package GeoDirectory
609
+	 * @param array $point1 Latitude and Longitude of point 1.
610
+	 * @param array $point2 Latitude and Longitude of point 2.
611
+	 * @param string $uom Unit of measurement.
612
+	 * @return float The distance.
613
+	 */
614
+	function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
615
+	{
616 616
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
617 617
 
618
-        $earthMeanRadius = geodir_getDistanceRadius($uom);
618
+		$earthMeanRadius = geodir_getDistanceRadius($uom);
619 619
 
620
-        $deltaLatitude = deg2rad($point2['latitude'] - $point1['latitude']);
621
-        $deltaLongitude = deg2rad($point2['longitude'] - $point1['longitude']);
622
-        $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
623
-            cos(deg2rad($point1['latitude'])) * cos(deg2rad($point2['latitude'])) *
624
-            sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
625
-        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
626
-        $distance = $earthMeanRadius * $c;
627
-        return $distance;
620
+		$deltaLatitude = deg2rad($point2['latitude'] - $point1['latitude']);
621
+		$deltaLongitude = deg2rad($point2['longitude'] - $point1['longitude']);
622
+		$a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
623
+			cos(deg2rad($point1['latitude'])) * cos(deg2rad($point2['latitude'])) *
624
+			sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
625
+		$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
626
+		$distance = $earthMeanRadius * $c;
627
+		return $distance;
628 628
 
629
-    }
629
+	}
630 630
 }
631 631
 
632 632
 
633 633
 if (!function_exists('geodir_sendEmail')) {
634
-    /**
635
-     * The main function that send transactional emails using the args provided.
636
-     *
637
-     * @since 1.0.0
638
-     * @since 1.5.7 Added db translations for notifications subject and content.
639
-     * @package GeoDirectory
640
-     * @param string $fromEmail Sender email address.
641
-     * @param string $fromEmailName Sender name.
642
-     * @param string $toEmail Receiver email address.
643
-     * @param string $toEmailName Receiver name.
644
-     * @param string $to_subject Email subject.
645
-     * @param string $to_message Email content.
646
-     * @param string $extra Not being used.
647
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
648
-     * @param string $post_id The post ID.
649
-     * @param string $user_id The user ID.
650
-     */
651
-    function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
652
-        $login_details = '';
653
-
654
-        // strip slashes from subject & message text
655
-        $to_subject = stripslashes_deep($to_subject);
656
-        $to_message = stripslashes_deep($to_message);
657
-
658
-        if ($message_type == 'send_friend') {
659
-            $subject = get_option('geodir_email_friend_subject');
660
-            $message = get_option('geodir_email_friend_content');
661
-        } elseif ($message_type == 'send_enquiry') {
662
-            $subject = get_option('geodir_email_enquiry_subject');
663
-            $message = get_option('geodir_email_enquiry_content');
664
-        } elseif ($message_type == 'forgot_password') {
665
-            $subject = get_option('geodir_forgot_password_subject');
666
-            $message = get_option('geodir_forgot_password_content');
667
-            $login_details = $to_message;
668
-        } elseif ($message_type == 'registration') {
669
-            $subject = get_option('geodir_registration_success_email_subject');
670
-            $message = get_option('geodir_registration_success_email_content');
671
-            $login_details = $to_message;
672
-        } elseif ($message_type == 'post_submit') {
673
-            $subject = get_option('geodir_post_submited_success_email_subject');
674
-            $message = get_option('geodir_post_submited_success_email_content');
675
-        } elseif ($message_type == 'listing_published') {
676
-            $subject = get_option('geodir_post_published_email_subject');
677
-            $message = get_option('geodir_post_published_email_content');
678
-        } elseif ($message_type == 'listing_edited') {
679
-            $subject = get_option('geodir_post_edited_email_subject_admin');
680
-            $message = get_option('geodir_post_edited_email_content_admin');
681
-        }
634
+	/**
635
+	 * The main function that send transactional emails using the args provided.
636
+	 *
637
+	 * @since 1.0.0
638
+	 * @since 1.5.7 Added db translations for notifications subject and content.
639
+	 * @package GeoDirectory
640
+	 * @param string $fromEmail Sender email address.
641
+	 * @param string $fromEmailName Sender name.
642
+	 * @param string $toEmail Receiver email address.
643
+	 * @param string $toEmailName Receiver name.
644
+	 * @param string $to_subject Email subject.
645
+	 * @param string $to_message Email content.
646
+	 * @param string $extra Not being used.
647
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
648
+	 * @param string $post_id The post ID.
649
+	 * @param string $user_id The user ID.
650
+	 */
651
+	function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
652
+		$login_details = '';
653
+
654
+		// strip slashes from subject & message text
655
+		$to_subject = stripslashes_deep($to_subject);
656
+		$to_message = stripslashes_deep($to_message);
657
+
658
+		if ($message_type == 'send_friend') {
659
+			$subject = get_option('geodir_email_friend_subject');
660
+			$message = get_option('geodir_email_friend_content');
661
+		} elseif ($message_type == 'send_enquiry') {
662
+			$subject = get_option('geodir_email_enquiry_subject');
663
+			$message = get_option('geodir_email_enquiry_content');
664
+		} elseif ($message_type == 'forgot_password') {
665
+			$subject = get_option('geodir_forgot_password_subject');
666
+			$message = get_option('geodir_forgot_password_content');
667
+			$login_details = $to_message;
668
+		} elseif ($message_type == 'registration') {
669
+			$subject = get_option('geodir_registration_success_email_subject');
670
+			$message = get_option('geodir_registration_success_email_content');
671
+			$login_details = $to_message;
672
+		} elseif ($message_type == 'post_submit') {
673
+			$subject = get_option('geodir_post_submited_success_email_subject');
674
+			$message = get_option('geodir_post_submited_success_email_content');
675
+		} elseif ($message_type == 'listing_published') {
676
+			$subject = get_option('geodir_post_published_email_subject');
677
+			$message = get_option('geodir_post_published_email_content');
678
+		} elseif ($message_type == 'listing_edited') {
679
+			$subject = get_option('geodir_post_edited_email_subject_admin');
680
+			$message = get_option('geodir_post_edited_email_content_admin');
681
+		}
682 682
 		
683 683
 		if (!empty($subject)) {
684 684
 			$subject = __(stripslashes_deep($subject),'geodirectory');
@@ -688,129 +688,129 @@  discard block
 block discarded – undo
688 688
 			$message = __(stripslashes_deep($message),'geodirectory');
689 689
 		}
690 690
 
691
-        $to_message = nl2br($to_message);
692
-        $sitefromEmail = get_option('site_email');
693
-        $sitefromEmailName = get_site_emailName();
694
-        $productlink = get_permalink($post_id);
691
+		$to_message = nl2br($to_message);
692
+		$sitefromEmail = get_option('site_email');
693
+		$sitefromEmailName = get_site_emailName();
694
+		$productlink = get_permalink($post_id);
695 695
 
696
-        $user_login = '';
697
-        if ($user_id > 0 && $user_info = get_userdata($user_id)) {
698
-            $user_login = $user_info->user_login;
699
-        }
696
+		$user_login = '';
697
+		if ($user_id > 0 && $user_info = get_userdata($user_id)) {
698
+			$user_login = $user_info->user_login;
699
+		}
700 700
 
701
-        $posted_date = '';
702
-        $listingLink = '';
701
+		$posted_date = '';
702
+		$listingLink = '';
703 703
 
704
-        $post_info = get_post($post_id);
704
+		$post_info = get_post($post_id);
705 705
 
706
-        if ($post_info) {
707
-            $posted_date = $post_info->post_date;
708
-            $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
709
-        }
710
-        $siteurl = home_url();
711
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
712
-        $loginurl = geodir_login_url();
713
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
706
+		if ($post_info) {
707
+			$posted_date = $post_info->post_date;
708
+			$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
709
+		}
710
+		$siteurl = home_url();
711
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
712
+		$loginurl = geodir_login_url();
713
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
714 714
         
715
-        $post_author_id = !empty($post_info) ? $post_info->post_author : 0;
716
-        $post_author_name = geodir_get_client_name($post_author_id);
717
-        $current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
715
+		$post_author_id = !empty($post_info) ? $post_info->post_author : 0;
716
+		$post_author_name = geodir_get_client_name($post_author_id);
717
+		$current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
718 718
 
719
-        if ($fromEmail == '') {
720
-            $fromEmail = get_option('site_email');
721
-        }
719
+		if ($fromEmail == '') {
720
+			$fromEmail = get_option('site_email');
721
+		}
722 722
 
723
-        if ($fromEmailName == '') {
724
-            $fromEmailName = get_option('site_email_name');
725
-        }
723
+		if ($fromEmailName == '') {
724
+			$fromEmailName = get_option('site_email_name');
725
+		}
726 726
 
727
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729
-        $message = str_replace($search_array, $replace_array, $message);
730
-
731
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733
-        $subject = str_replace($search_array, $replace_array, $subject);
734
-
735
-        $headers = 'MIME-Version: 1.0' . "\r\n";
736
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
737
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
738
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
739
-
740
-        $to = $toEmail;
741
-        $sent = wp_mail($to, $subject, $message, $headers);
742
-
743
-        if( ! $sent ) {
744
-            if ( is_array( $to ) ) {
745
-                $to = implode( ',', $to );
746
-            }
747
-            $log_message = sprintf(
748
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
749
-                $message_type,
750
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
751
-                $to,
752
-                $subject
753
-            );
754
-            geodir_error_log( $log_message );
755
-        }
727
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729
+		$message = str_replace($search_array, $replace_array, $message);
756 730
 
757
-        ///////// ADMIN BCC EMIALS
758
-        $adminEmail = get_bloginfo('admin_email');
759
-        $to = $adminEmail;
731
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733
+		$subject = str_replace($search_array, $replace_array, $subject);
760 734
 
761
-        $admin_bcc = false;
762
-        if ($message_type == 'post_submit') {
763
-            $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
764
-            $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
735
+		$headers = 'MIME-Version: 1.0' . "\r\n";
736
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
737
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
738
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
765 739
 
766
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
767
-            $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login);
768
-            $message = str_replace($search_array, $replace_array, $message);
740
+		$to = $toEmail;
741
+		$sent = wp_mail($to, $subject, $message, $headers);
769 742
 
770
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
771
-            $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
772
-            $subject = str_replace($search_array, $replace_array, $subject);
743
+		if( ! $sent ) {
744
+			if ( is_array( $to ) ) {
745
+				$to = implode( ',', $to );
746
+			}
747
+			$log_message = sprintf(
748
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
749
+				$message_type,
750
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
751
+				$to,
752
+				$subject
753
+			);
754
+			geodir_error_log( $log_message );
755
+		}
773 756
 
774
-            $subject .= ' - ADMIN BCC COPY';
775
-            $admin_bcc = true;
757
+		///////// ADMIN BCC EMIALS
758
+		$adminEmail = get_bloginfo('admin_email');
759
+		$to = $adminEmail;
776 760
 
777
-        }
778
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
779
-            $subject .= ' - ADMIN BCC COPY';
780
-            $admin_bcc = true;
781
-        }
782
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
783
-            $subject .= ' - ADMIN BCC COPY';
784
-            $admin_bcc = true;
785
-        }
786
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
787
-            $subject .= ' - ADMIN BCC COPY';
788
-            $admin_bcc = true;
789
-        }
790
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
791
-            $subject .= ' - ADMIN BCC COPY';
792
-            $admin_bcc = true;
793
-        }
761
+		$admin_bcc = false;
762
+		if ($message_type == 'post_submit') {
763
+			$subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
764
+			$message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
794 765
 
795
-        if($admin_bcc===true){
796
-            $sent = wp_mail($to, $subject, $message, $headers);
797
-
798
-            if( ! $sent ) {
799
-                if ( is_array( $to ) ) {
800
-                    $to = implode( ',', $to );
801
-                }
802
-                $log_message = sprintf(
803
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
804
-                    $message_type,
805
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
806
-                    $to,
807
-                    $subject
808
-                );
809
-                geodir_error_log( $log_message );
810
-            }
811
-        }
766
+			$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
767
+			$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login);
768
+			$message = str_replace($search_array, $replace_array, $message);
769
+
770
+			$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
771
+			$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
772
+			$subject = str_replace($search_array, $replace_array, $subject);
773
+
774
+			$subject .= ' - ADMIN BCC COPY';
775
+			$admin_bcc = true;
812 776
 
813
-    }
777
+		}
778
+		elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
779
+			$subject .= ' - ADMIN BCC COPY';
780
+			$admin_bcc = true;
781
+		}
782
+		elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
783
+			$subject .= ' - ADMIN BCC COPY';
784
+			$admin_bcc = true;
785
+		}
786
+		elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
787
+			$subject .= ' - ADMIN BCC COPY';
788
+			$admin_bcc = true;
789
+		}
790
+		elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
791
+			$subject .= ' - ADMIN BCC COPY';
792
+			$admin_bcc = true;
793
+		}
794
+
795
+		if($admin_bcc===true){
796
+			$sent = wp_mail($to, $subject, $message, $headers);
797
+
798
+			if( ! $sent ) {
799
+				if ( is_array( $to ) ) {
800
+					$to = implode( ',', $to );
801
+				}
802
+				$log_message = sprintf(
803
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
804
+					$message_type,
805
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
806
+					$to,
807
+					$subject
808
+				);
809
+				geodir_error_log( $log_message );
810
+			}
811
+		}
812
+
813
+	}
814 814
 }
815 815
 
816 816
 
@@ -823,27 +823,27 @@  discard block
 block discarded – undo
823 823
 function geodir_taxonomy_breadcrumb()
824 824
 {
825 825
 
826
-    $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
827
-    $parent = $term->parent;
826
+	$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
827
+	$parent = $term->parent;
828 828
 
829
-    while ($parent):
830
-        $parents[] = $parent;
831
-        $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
832
-        $parent = $new_parent->parent;
833
-    endwhile;
829
+	while ($parent):
830
+		$parents[] = $parent;
831
+		$new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
832
+		$parent = $new_parent->parent;
833
+	endwhile;
834 834
 
835
-    if (!empty($parents)):
836
-        $parents = array_reverse($parents);
835
+	if (!empty($parents)):
836
+		$parents = array_reverse($parents);
837 837
 
838
-        foreach ($parents as $parent):
839
-            $item = get_term_by('id', $parent, get_query_var('taxonomy'));
840
-            $url = get_term_link($item, get_query_var('taxonomy'));
841
-            echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
842
-        endforeach;
838
+		foreach ($parents as $parent):
839
+			$item = get_term_by('id', $parent, get_query_var('taxonomy'));
840
+			$url = get_term_link($item, get_query_var('taxonomy'));
841
+			echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
842
+		endforeach;
843 843
 
844
-    endif;
844
+	endif;
845 845
 
846
-    echo '<li> > ' . $term->name . '</li>';
846
+	echo '<li> > ' . $term->name . '</li>';
847 847
 }
848 848
 
849 849
 
@@ -859,365 +859,365 @@  discard block
 block discarded – undo
859 859
  */
860 860
 function geodir_breadcrumb()
861 861
 {
862
-    global $wp_query, $geodir_add_location_url;
863
-
864
-    /**
865
-     * Filter breadcrumb separator.
866
-     *
867
-     * @since 1.0.0
868
-     */
869
-    $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
870
-
871
-    if (!geodir_is_page('home')) {
872
-        $breadcrumb = '';
873
-        $url_categoris = '';
874
-        $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
875
-        /**
876
-         * Filter breadcrumb's first link.
877
-         *
878
-         * @since 1.0.0
879
-         */
880
-        $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
862
+	global $wp_query, $geodir_add_location_url;
863
+
864
+	/**
865
+	 * Filter breadcrumb separator.
866
+	 *
867
+	 * @since 1.0.0
868
+	 */
869
+	$separator = apply_filters('geodir_breadcrumb_separator', ' > ');
870
+
871
+	if (!geodir_is_page('home')) {
872
+		$breadcrumb = '';
873
+		$url_categoris = '';
874
+		$breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
875
+		/**
876
+		 * Filter breadcrumb's first link.
877
+		 *
878
+		 * @since 1.0.0
879
+		 */
880
+		$breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
881
+
882
+		$gd_post_type = geodir_get_current_posttype();
883
+		$post_type_info = get_post_type_object($gd_post_type);
884
+
885
+		remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
886
+
887
+		$listing_link = get_post_type_archive_link($gd_post_type);
888
+
889
+		add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
890
+		$listing_link = rtrim($listing_link, '/');
891
+		$listing_link .= '/';
892
+
893
+		$post_type_for_location_link = $listing_link;
894
+		$location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
895
+
896
+		global $wp, $gd_session;
897
+		$location_link = $post_type_for_location_link;
898
+
899
+		if (geodir_is_page('detail') || geodir_is_page('listing')) {
900
+			global $post;
901
+			$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
902
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
903
+				
904
+			if(geodir_is_page('detail') && isset($post->country_slug)){
905
+				$location_terms = array(
906
+					'gd_country' => $post->country_slug,
907
+					'gd_region' => $post->region_slug,
908
+					'gd_city' => $post->city_slug
909
+				);
910
+				
911
+				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
912
+					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
913
+				}
914
+			}
881 915
 
882
-        $gd_post_type = geodir_get_current_posttype();
883
-        $post_type_info = get_post_type_object($gd_post_type);
916
+			$geodir_show_location_url = get_option('geodir_show_location_url');
884 917
 
885
-        remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
918
+			$hide_url_part = array();
919
+			if ($location_manager) {
920
+				$hide_country_part = get_option('geodir_location_hide_country_part');
921
+				$hide_region_part = get_option('geodir_location_hide_region_part');
886 922
 
887
-        $listing_link = get_post_type_archive_link($gd_post_type);
923
+				if ($hide_region_part && $hide_country_part) {
924
+					$hide_url_part = array('gd_country', 'gd_region');
925
+				} else if ($hide_region_part && !$hide_country_part) {
926
+					$hide_url_part = array('gd_region');
927
+				} else if (!$hide_region_part && $hide_country_part) {
928
+					$hide_url_part = array('gd_country');
929
+				}
930
+			}
888 931
 
889
-        add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
890
-        $listing_link = rtrim($listing_link, '/');
891
-        $listing_link .= '/';
932
+			$hide_text_part = array();
933
+			if ($geodir_show_location_url == 'country_city') {
934
+				$hide_text_part = array('gd_region');
892 935
 
893
-        $post_type_for_location_link = $listing_link;
894
-        $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
936
+				if (isset($location_terms['gd_region']) && !$location_manager) {
937
+					unset($location_terms['gd_region']);
938
+				}
939
+			} else if ($geodir_show_location_url == 'region_city') {
940
+				$hide_text_part = array('gd_country');
895 941
 
896
-        global $wp, $gd_session;
897
-        $location_link = $post_type_for_location_link;
942
+				if (isset($location_terms['gd_country']) && !$location_manager) {
943
+					unset($location_terms['gd_country']);
944
+				}
945
+			} else if ($geodir_show_location_url == 'city') {
946
+				$hide_text_part = array('gd_country', 'gd_region');
898 947
 
899
-        if (geodir_is_page('detail') || geodir_is_page('listing')) {
900
-            global $post;
901
-            $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
902
-			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
903
-				
904
-			if(geodir_is_page('detail') && isset($post->country_slug)){
905
-                $location_terms = array(
906
-                    'gd_country' => $post->country_slug,
907
-                    'gd_region' => $post->region_slug,
908
-                    'gd_city' => $post->city_slug
909
-                );
910
-				
911
-				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
912
-					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
948
+				if (isset($location_terms['gd_country']) && !$location_manager) {
949
+					unset($location_terms['gd_country']);
913 950
 				}
914
-            }
915
-
916
-            $geodir_show_location_url = get_option('geodir_show_location_url');
917
-
918
-            $hide_url_part = array();
919
-            if ($location_manager) {
920
-                $hide_country_part = get_option('geodir_location_hide_country_part');
921
-                $hide_region_part = get_option('geodir_location_hide_region_part');
922
-
923
-                if ($hide_region_part && $hide_country_part) {
924
-                    $hide_url_part = array('gd_country', 'gd_region');
925
-                } else if ($hide_region_part && !$hide_country_part) {
926
-                    $hide_url_part = array('gd_region');
927
-                } else if (!$hide_region_part && $hide_country_part) {
928
-                    $hide_url_part = array('gd_country');
929
-                }
930
-            }
931
-
932
-            $hide_text_part = array();
933
-            if ($geodir_show_location_url == 'country_city') {
934
-                $hide_text_part = array('gd_region');
935
-
936
-                if (isset($location_terms['gd_region']) && !$location_manager) {
937
-                    unset($location_terms['gd_region']);
938
-                }
939
-            } else if ($geodir_show_location_url == 'region_city') {
940
-                $hide_text_part = array('gd_country');
941
-
942
-                if (isset($location_terms['gd_country']) && !$location_manager) {
943
-                    unset($location_terms['gd_country']);
944
-                }
945
-            } else if ($geodir_show_location_url == 'city') {
946
-                $hide_text_part = array('gd_country', 'gd_region');
947
-
948
-                if (isset($location_terms['gd_country']) && !$location_manager) {
949
-                    unset($location_terms['gd_country']);
950
-                }
951
-                if (isset($location_terms['gd_region']) && !$location_manager) {
952
-                    unset($location_terms['gd_region']);
953
-                }
954
-            }
955
-
956
-            $is_location_last = '';
957
-            $is_taxonomy_last = '';
958
-            $breadcrumb .= '<li>';
959
-            if (get_query_var($gd_post_type . 'category'))
960
-                $gd_taxonomy = $gd_post_type . 'category';
961
-            elseif (get_query_var($gd_post_type . '_tags'))
962
-                $gd_taxonomy = $gd_post_type . '_tags';
963
-
964
-            $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
965
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
966
-                $is_location_last = false;
967
-            else
968
-                $is_location_last = true;
969
-
970
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
971
-                $is_taxonomy_last = true;
972
-            else
973
-                $is_taxonomy_last = false;
974
-
975
-            if (!empty($location_terms)) {
976
-                $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
977
-
978
-                foreach ($location_terms as $key => $location_term) {
979
-                    if ($location_term != '') {
980
-                        if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
981
-                            continue;
982
-                        }
983
-
984
-                        $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
985
-                        $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
986
-                        $gd_location_link_text = ucfirst($gd_location_link_text);
987
-
988
-                        $location_term_actual_country = '';
989
-                        $location_term_actual_region = '';
990
-                        $location_term_actual_city = '';
991
-                        if ($geodir_get_locations) {
992
-                            if ($key == 'gd_country') {
993
-                                $location_term_actual_country = get_actual_location_name('country', $location_term, true);
994
-                            } else if ($key == 'gd_region') {
995
-                                $location_term_actual_region = get_actual_location_name('region', $location_term, true);
996
-                            } else if ($key == 'gd_city') {
997
-                                $location_term_actual_city = get_actual_location_name('city', $location_term, true);
998
-                            }
999
-                        } else {
1000
-                            $location_info = geodir_get_location();
1001
-
1002
-                            if (!empty($location_info) && isset($location_info->location_id)) {
1003
-                                if ($key == 'gd_country') {
1004
-                                    $location_term_actual_country = __($location_info->country, 'geodirectory');
1005
-                                } else if ($key == 'gd_region') {
1006
-                                    $location_term_actual_region = __($location_info->region, 'geodirectory');
1007
-                                } else if ($key == 'gd_city') {
1008
-                                    $location_term_actual_city = __($location_info->city, 'geodirectory');
1009
-                                }
1010
-                            }
1011
-                        }
1012
-
1013
-                        if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1014
-                            $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1015
-                        } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1016
-                            $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1017
-                        } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1018
-                            $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1019
-                        } else if ($is_location_last && $key == 'gd_neighbourhood') {
1020
-                            $breadcrumb .= $separator . $gd_location_link_text;
1021
-                        } else {
1022
-                            if (get_option('permalink_structure') != '') {
1023
-                                $location_link .= $location_term . '/';
1024
-                            } else {
1025
-                                $location_link .= "&$key=" . $location_term;
1026
-                            }
951
+				if (isset($location_terms['gd_region']) && !$location_manager) {
952
+					unset($location_terms['gd_region']);
953
+				}
954
+			}
1027 955
 
1028
-                            if ($key == 'gd_country' && $location_term_actual_country != '') {
1029
-                                $gd_location_link_text = $location_term_actual_country;
1030
-                            } else if ($key == 'gd_region' && $location_term_actual_region != '') {
1031
-                                $gd_location_link_text = $location_term_actual_region;
1032
-                            } else if ($key == 'gd_city' && $location_term_actual_city != '') {
1033
-                                $gd_location_link_text = $location_term_actual_city;
1034
-                            }
956
+			$is_location_last = '';
957
+			$is_taxonomy_last = '';
958
+			$breadcrumb .= '<li>';
959
+			if (get_query_var($gd_post_type . 'category'))
960
+				$gd_taxonomy = $gd_post_type . 'category';
961
+			elseif (get_query_var($gd_post_type . '_tags'))
962
+				$gd_taxonomy = $gd_post_type . '_tags';
963
+
964
+			$breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
965
+			if (!empty($gd_taxonomy) || geodir_is_page('detail'))
966
+				$is_location_last = false;
967
+			else
968
+				$is_location_last = true;
969
+
970
+			if (!empty($gd_taxonomy) && geodir_is_page('listing'))
971
+				$is_taxonomy_last = true;
972
+			else
973
+				$is_taxonomy_last = false;
974
+
975
+			if (!empty($location_terms)) {
976
+				$geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
977
+
978
+				foreach ($location_terms as $key => $location_term) {
979
+					if ($location_term != '') {
980
+						if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
981
+							continue;
982
+						}
983
+
984
+						$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
985
+						$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
986
+						$gd_location_link_text = ucfirst($gd_location_link_text);
987
+
988
+						$location_term_actual_country = '';
989
+						$location_term_actual_region = '';
990
+						$location_term_actual_city = '';
991
+						if ($geodir_get_locations) {
992
+							if ($key == 'gd_country') {
993
+								$location_term_actual_country = get_actual_location_name('country', $location_term, true);
994
+							} else if ($key == 'gd_region') {
995
+								$location_term_actual_region = get_actual_location_name('region', $location_term, true);
996
+							} else if ($key == 'gd_city') {
997
+								$location_term_actual_city = get_actual_location_name('city', $location_term, true);
998
+							}
999
+						} else {
1000
+							$location_info = geodir_get_location();
1001
+
1002
+							if (!empty($location_info) && isset($location_info->location_id)) {
1003
+								if ($key == 'gd_country') {
1004
+									$location_term_actual_country = __($location_info->country, 'geodirectory');
1005
+								} else if ($key == 'gd_region') {
1006
+									$location_term_actual_region = __($location_info->region, 'geodirectory');
1007
+								} else if ($key == 'gd_city') {
1008
+									$location_term_actual_city = __($location_info->city, 'geodirectory');
1009
+								}
1010
+							}
1011
+						}
1035 1012
 
1036
-                            /*
1013
+						if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1014
+							$breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1015
+						} else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1016
+							$breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1017
+						} else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1018
+							$breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1019
+						} else if ($is_location_last && $key == 'gd_neighbourhood') {
1020
+							$breadcrumb .= $separator . $gd_location_link_text;
1021
+						} else {
1022
+							if (get_option('permalink_structure') != '') {
1023
+								$location_link .= $location_term . '/';
1024
+							} else {
1025
+								$location_link .= "&$key=" . $location_term;
1026
+							}
1027
+
1028
+							if ($key == 'gd_country' && $location_term_actual_country != '') {
1029
+								$gd_location_link_text = $location_term_actual_country;
1030
+							} else if ($key == 'gd_region' && $location_term_actual_region != '') {
1031
+								$gd_location_link_text = $location_term_actual_region;
1032
+							} else if ($key == 'gd_city' && $location_term_actual_city != '') {
1033
+								$gd_location_link_text = $location_term_actual_city;
1034
+							}
1035
+
1036
+							/*
1037 1037
                             if (geodir_is_page('detail') && !empty($hide_text_part) && in_array($key, $hide_text_part)) {
1038 1038
                                 continue;
1039 1039
                             }
1040 1040
                             */
1041 1041
 
1042
-                            $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1043
-                        }
1044
-                    }
1045
-                }
1046
-            }
1047
-
1048
-            if (!empty($gd_taxonomy)) {
1049
-                $term_index = 1;
1050
-
1051
-                //if(get_option('geodir_add_categories_url'))
1052
-                {
1053
-                    if (get_query_var($gd_post_type . '_tags')) {
1054
-                        $cat_link = $listing_link . 'tags/';
1055
-                    } else
1056
-                        $cat_link = $listing_link;
1057
-
1058
-                    foreach ($location_terms as $key => $location_term) {
1059
-                        if ($location_manager && in_array($key, $hide_url_part)) {
1060
-                            continue;
1061
-                        }
1062
-
1063
-                        if ($location_term != '') {
1064
-                            if (get_option('permalink_structure') != '') {
1065
-                                $cat_link .= $location_term . '/';
1066
-                            }
1067
-                        }
1068
-                    }
1069
-
1070
-                    $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1071
-                    foreach ($term_array as $term) {
1072
-                        $term_link_text = preg_replace('/-(\d+)$/', '', $term);
1073
-                        $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1074
-
1075
-                        // get term actual name
1076
-                        $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1077
-                        if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1078
-                            $term_link_text = urldecode($term_info['name']);
1079
-                        } else {
1080
-                            $term_link_text = geodir_ucwords(urldecode($term_link_text));
1081
-                        }
1082
-
1083
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1084
-                            $breadcrumb .= $separator . $term_link_text;
1085
-                        else {
1086
-                            $cat_link .= $term . '/';
1087
-                            $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1088
-                        }
1089
-                        $term_index++;
1090
-                    }
1091
-                }
1092
-
1093
-
1094
-            }
1095
-
1096
-            if (geodir_is_page('detail'))
1097
-                $breadcrumb .= $separator . get_the_title();
1098
-
1099
-            $breadcrumb .= '</li>';
1100
-
1101
-
1102
-        } elseif (geodir_is_page('author')) {
1103
-            $user_id = get_current_user_id();
1104
-            $author_link = get_author_posts_url($user_id);
1105
-            $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1106
-
1107
-            /**
1108
-             * Filter author page link.
1109
-             *
1110
-             * @since 1.0.0
1111
-             * @param string $default_author_link Default author link.
1112
-             * @param int $user_id Author ID.
1113
-             */
1114
-            $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1115
-
1116
-            $breadcrumb .= '<li>';
1117
-            $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1118
-
1119
-            if (isset($_REQUEST['list'])) {
1120
-                $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1121
-
1122
-                /**
1123
-                 * Filter author page link.
1124
-                 *
1125
-                 * @since 1.0.0
1126
-                 * @param string $author_link Author page link.
1127
-                 * @param int $user_id Author ID.
1128
-                 * @param string $_REQUEST['stype'] Post type.
1129
-                 */
1130
-                $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1131
-
1132
-                $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1133
-                $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1134
-            } else
1135
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1136
-
1137
-            $breadcrumb .= '</li>';
1138
-        } elseif (is_category() || is_single()) {
1139
-            $category = get_the_category();
1140
-            if (is_category()) {
1141
-                $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1142
-            }
1143
-            if (is_single()) {
1144
-                $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1145
-                $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1146
-            }
1147
-            /* End of my version ##################################################### */
1148
-        } else if (is_page()) {
1149
-            $page_title = get_the_title();
1150
-
1151
-            if (geodir_is_page('location')) {
1152
-                $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1153
-            }
1154
-
1155
-            $breadcrumb .= '<li>' . $separator;
1156
-            $breadcrumb .= stripslashes_deep($page_title);
1157
-            $breadcrumb .= '</li>';
1158
-        } else if (is_tag()) {
1159
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1160
-        } else if (is_day()) {
1161
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1162
-            the_time('F jS, Y');
1163
-            $breadcrumb .= '</li>';
1164
-        } else if (is_month()) {
1165
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1166
-            the_time('F, Y');
1167
-            $breadcrumb .= '</li>';
1168
-        } else if (is_year()) {
1169
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1170
-            the_time('Y');
1171
-            $breadcrumb .= '</li>';
1172
-        } else if (is_author()) {
1173
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1174
-            $breadcrumb .= '</li>';
1175
-        } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1176
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1177
-            $breadcrumb .= '</li>';
1178
-        } else if (is_search()) {
1179
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1180
-            $breadcrumb .= '</li>';
1181
-        }
1182
-        $breadcrumb .= '</ul></div>';
1183
-
1184
-        /**
1185
-         * Filter breadcrumb html output.
1186
-         *
1187
-         * @since 1.0.0
1188
-         * @param string $breadcrumb Breadcrumb HTML.
1189
-         * @param string $separator Breadcrumb separator.
1190
-         */
1191
-        echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1192
-    }
1042
+							$breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1043
+						}
1044
+					}
1045
+				}
1046
+			}
1047
+
1048
+			if (!empty($gd_taxonomy)) {
1049
+				$term_index = 1;
1050
+
1051
+				//if(get_option('geodir_add_categories_url'))
1052
+				{
1053
+					if (get_query_var($gd_post_type . '_tags')) {
1054
+						$cat_link = $listing_link . 'tags/';
1055
+					} else
1056
+						$cat_link = $listing_link;
1057
+
1058
+					foreach ($location_terms as $key => $location_term) {
1059
+						if ($location_manager && in_array($key, $hide_url_part)) {
1060
+							continue;
1061
+						}
1062
+
1063
+						if ($location_term != '') {
1064
+							if (get_option('permalink_structure') != '') {
1065
+								$cat_link .= $location_term . '/';
1066
+							}
1067
+						}
1068
+					}
1069
+
1070
+					$term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1071
+					foreach ($term_array as $term) {
1072
+						$term_link_text = preg_replace('/-(\d+)$/', '', $term);
1073
+						$term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1074
+
1075
+						// get term actual name
1076
+						$term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1077
+						if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1078
+							$term_link_text = urldecode($term_info['name']);
1079
+						} else {
1080
+							$term_link_text = geodir_ucwords(urldecode($term_link_text));
1081
+						}
1082
+
1083
+						if ($term_index == count($term_array) && $is_taxonomy_last)
1084
+							$breadcrumb .= $separator . $term_link_text;
1085
+						else {
1086
+							$cat_link .= $term . '/';
1087
+							$breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1088
+						}
1089
+						$term_index++;
1090
+					}
1091
+				}
1092
+
1093
+
1094
+			}
1095
+
1096
+			if (geodir_is_page('detail'))
1097
+				$breadcrumb .= $separator . get_the_title();
1098
+
1099
+			$breadcrumb .= '</li>';
1100
+
1101
+
1102
+		} elseif (geodir_is_page('author')) {
1103
+			$user_id = get_current_user_id();
1104
+			$author_link = get_author_posts_url($user_id);
1105
+			$default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1106
+
1107
+			/**
1108
+			 * Filter author page link.
1109
+			 *
1110
+			 * @since 1.0.0
1111
+			 * @param string $default_author_link Default author link.
1112
+			 * @param int $user_id Author ID.
1113
+			 */
1114
+			$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1115
+
1116
+			$breadcrumb .= '<li>';
1117
+			$breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1118
+
1119
+			if (isset($_REQUEST['list'])) {
1120
+				$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1121
+
1122
+				/**
1123
+				 * Filter author page link.
1124
+				 *
1125
+				 * @since 1.0.0
1126
+				 * @param string $author_link Author page link.
1127
+				 * @param int $user_id Author ID.
1128
+				 * @param string $_REQUEST['stype'] Post type.
1129
+				 */
1130
+				$author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1131
+
1132
+				$breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1133
+				$breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1134
+			} else
1135
+				$breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1136
+
1137
+			$breadcrumb .= '</li>';
1138
+		} elseif (is_category() || is_single()) {
1139
+			$category = get_the_category();
1140
+			if (is_category()) {
1141
+				$breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1142
+			}
1143
+			if (is_single()) {
1144
+				$breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1145
+				$breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1146
+			}
1147
+			/* End of my version ##################################################### */
1148
+		} else if (is_page()) {
1149
+			$page_title = get_the_title();
1150
+
1151
+			if (geodir_is_page('location')) {
1152
+				$page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1153
+			}
1154
+
1155
+			$breadcrumb .= '<li>' . $separator;
1156
+			$breadcrumb .= stripslashes_deep($page_title);
1157
+			$breadcrumb .= '</li>';
1158
+		} else if (is_tag()) {
1159
+			$breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1160
+		} else if (is_day()) {
1161
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1162
+			the_time('F jS, Y');
1163
+			$breadcrumb .= '</li>';
1164
+		} else if (is_month()) {
1165
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1166
+			the_time('F, Y');
1167
+			$breadcrumb .= '</li>';
1168
+		} else if (is_year()) {
1169
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1170
+			the_time('Y');
1171
+			$breadcrumb .= '</li>';
1172
+		} else if (is_author()) {
1173
+			$breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1174
+			$breadcrumb .= '</li>';
1175
+		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1176
+			$breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1177
+			$breadcrumb .= '</li>';
1178
+		} else if (is_search()) {
1179
+			$breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1180
+			$breadcrumb .= '</li>';
1181
+		}
1182
+		$breadcrumb .= '</ul></div>';
1183
+
1184
+		/**
1185
+		 * Filter breadcrumb html output.
1186
+		 *
1187
+		 * @since 1.0.0
1188
+		 * @param string $breadcrumb Breadcrumb HTML.
1189
+		 * @param string $separator Breadcrumb separator.
1190
+		 */
1191
+		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1192
+	}
1193 1193
 }
1194 1194
 
1195 1195
 
1196 1196
 add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
1197 1197
 if (!function_exists('geodir_allow_wpadmin')) {
1198
-    /**
1199
-     * Allow only admins to access wp-admin.
1200
-     *
1201
-     * Normal users will be redirected to home page.
1202
-     *
1203
-     * @since 1.0.0
1204
-     * @package GeoDirectory
1205
-     * @global object $wpdb WordPress Database object.
1206
-     */
1207
-    function geodir_allow_wpadmin()
1208
-    {
1209
-        global $wpdb;
1210
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1211
-        {
1212
-            if (current_user_can('manage_options')) {
1213
-            } else {
1214
-
1215
-                wp_redirect(home_url());
1216
-                exit;
1217
-            }
1198
+	/**
1199
+	 * Allow only admins to access wp-admin.
1200
+	 *
1201
+	 * Normal users will be redirected to home page.
1202
+	 *
1203
+	 * @since 1.0.0
1204
+	 * @package GeoDirectory
1205
+	 * @global object $wpdb WordPress Database object.
1206
+	 */
1207
+	function geodir_allow_wpadmin()
1208
+	{
1209
+		global $wpdb;
1210
+		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1211
+		{
1212
+			if (current_user_can('manage_options')) {
1213
+			} else {
1214
+
1215
+				wp_redirect(home_url());
1216
+				exit;
1217
+			}
1218 1218
 
1219
-        }
1220
-    }
1219
+		}
1220
+	}
1221 1221
 }
1222 1222
 
1223 1223
 
@@ -1231,50 +1231,50 @@  discard block
 block discarded – undo
1231 1231
  */
1232 1232
 function fetch_remote_file($url)
1233 1233
 {
1234
-    // extract the file name and extension from the url
1235
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1236
-    $file_name = basename($url);
1237
-    if (strpos($file_name, '?') !== false) {
1238
-        list($file_name) = explode('?', $file_name);
1239
-    }
1240
-
1241
-
1242
-    // get placeholder file in the upload dir with a unique, sanitized filename
1243
-
1244
-    $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1245
-
1246
-    $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1247
-    if ($upload['error'])
1248
-        return new WP_Error('upload_dir_error', $upload['error']);
1249
-
1250
-    // fetch the remote url and write it to the placeholder file
1251
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1252
-
1253
-    $log_message = '';
1254
-    $filesize = filesize($upload['file']);
1255
-    // request failed
1256
-    if (!$headers) {
1257
-        $log_message = __('Remote server did not respond', 'geodirectory');
1258
-    }
1259
-    // make sure the fetch was successful
1260
-    elseif ($headers['response']['code'] != '200') {
1261
-        $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1262
-    }
1263
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1264
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1265
-    }
1266
-    elseif (0 == $filesize) {
1267
-        $log_message = __('Zero size file downloaded', 'geodirectory');
1268
-    }
1269
-
1270
-    if($log_message){
1271
-        $del = unlink($upload['file']);
1272
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1273
-        return new WP_Error('import_file_error',$log_message );
1274
-    }
1275
-
1276
-
1277
-    return $upload;
1234
+	// extract the file name and extension from the url
1235
+	require_once(ABSPATH . 'wp-includes/pluggable.php');
1236
+	$file_name = basename($url);
1237
+	if (strpos($file_name, '?') !== false) {
1238
+		list($file_name) = explode('?', $file_name);
1239
+	}
1240
+
1241
+
1242
+	// get placeholder file in the upload dir with a unique, sanitized filename
1243
+
1244
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1245
+
1246
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1247
+	if ($upload['error'])
1248
+		return new WP_Error('upload_dir_error', $upload['error']);
1249
+
1250
+	// fetch the remote url and write it to the placeholder file
1251
+	$headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1252
+
1253
+	$log_message = '';
1254
+	$filesize = filesize($upload['file']);
1255
+	// request failed
1256
+	if (!$headers) {
1257
+		$log_message = __('Remote server did not respond', 'geodirectory');
1258
+	}
1259
+	// make sure the fetch was successful
1260
+	elseif ($headers['response']['code'] != '200') {
1261
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1262
+	}
1263
+	elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1264
+		$log_message =  __('Remote file is incorrect size', 'geodirectory');
1265
+	}
1266
+	elseif (0 == $filesize) {
1267
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1268
+	}
1269
+
1270
+	if($log_message){
1271
+		$del = unlink($upload['file']);
1272
+		if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1273
+		return new WP_Error('import_file_error',$log_message );
1274
+	}
1275
+
1276
+
1277
+	return $upload;
1278 1278
 }
1279 1279
 
1280 1280
 /**
@@ -1286,21 +1286,21 @@  discard block
 block discarded – undo
1286 1286
  */
1287 1287
 function geodir_max_upload_size()
1288 1288
 {
1289
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1290
-
1291
-    if ($max_filesize > 0 && $max_filesize < 1) {
1292
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1293
-    } else {
1294
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1295
-    }
1296
-
1297
-    /**
1298
-     * Filter default image upload size limit.
1299
-     *
1300
-     * @since 1.0.0
1301
-     * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1302
-     */
1303
-    return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1289
+	$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1290
+
1291
+	if ($max_filesize > 0 && $max_filesize < 1) {
1292
+		$max_filesize = (int)($max_filesize * 1024) . 'kb';
1293
+	} else {
1294
+		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1295
+	}
1296
+
1297
+	/**
1298
+	 * Filter default image upload size limit.
1299
+	 *
1300
+	 * @since 1.0.0
1301
+	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1302
+	 */
1303
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1304 1304
 }
1305 1305
 
1306 1306
 /**
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
  */
1315 1315
 function geodir_dummy_folder_exists()
1316 1316
 {
1317
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1318
-    if (!is_dir($path))
1319
-        return false;
1320
-    else
1321
-        return true;
1317
+	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1318
+	if (!is_dir($path))
1319
+		return false;
1320
+	else
1321
+		return true;
1322 1322
 
1323 1323
 }
1324 1324
 
@@ -1333,237 +1333,237 @@  discard block
 block discarded – undo
1333 1333
  */
1334 1334
 function  geodir_get_author_info($aid)
1335 1335
 {
1336
-    global $wpdb;
1337
-    /*$infosql = "select * from $wpdb->users where ID=$aid";*/
1338
-    $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1339
-    $info = $wpdb->get_results($infosql);
1340
-    if ($info) {
1341
-        return $info[0];
1342
-    }
1336
+	global $wpdb;
1337
+	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1338
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1339
+	$info = $wpdb->get_results($infosql);
1340
+	if ($info) {
1341
+		return $info[0];
1342
+	}
1343 1343
 }
1344 1344
 
1345 1345
 if (!function_exists('adminEmail')) {
1346
-    /**
1347
-     * Send emails to client on post submission, renew etc.
1348
-     *
1349
-     * @since 1.0.0
1350
-     * @package GeoDirectory
1351
-     * @global object $wpdb WordPress Database object.
1352
-     * @param int|string $page_id Page ID.
1353
-     * @param int|string $user_id User ID.
1354
-     * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1355
-     * @param string $custom_1 Custom data to be sent.
1356
-     */
1357
-    function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1358
-    {
1359
-        global $wpdb;
1360
-        if ($message_type == 'expiration') {
1361
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1362
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1363
-        } elseif ($message_type == 'post_submited') {
1364
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1365
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1366
-        } elseif ($message_type == 'renew') {
1367
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1368
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1369
-        } elseif ($message_type == 'upgrade') {
1370
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1371
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1372
-        } elseif ($message_type == 'claim_approved') {
1373
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1374
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1375
-        } elseif ($message_type == 'claim_rejected') {
1376
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1377
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1378
-        } elseif ($message_type == 'claim_requested') {
1379
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1380
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1381
-        } elseif ($message_type == 'auto_claim') {
1382
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1383
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1384
-        } elseif ($message_type == 'payment_success') {
1385
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1386
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1387
-        } elseif ($message_type == 'payment_fail') {
1388
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1389
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1390
-        }
1391
-        $transaction_details = $custom_1;
1392
-        $fromEmail = get_option('site_email');
1393
-        $fromEmailName = get_site_emailName();
1346
+	/**
1347
+	 * Send emails to client on post submission, renew etc.
1348
+	 *
1349
+	 * @since 1.0.0
1350
+	 * @package GeoDirectory
1351
+	 * @global object $wpdb WordPress Database object.
1352
+	 * @param int|string $page_id Page ID.
1353
+	 * @param int|string $user_id User ID.
1354
+	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1355
+	 * @param string $custom_1 Custom data to be sent.
1356
+	 */
1357
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1358
+	{
1359
+		global $wpdb;
1360
+		if ($message_type == 'expiration') {
1361
+			$subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1362
+			$client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1363
+		} elseif ($message_type == 'post_submited') {
1364
+			$subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1365
+			$client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1366
+		} elseif ($message_type == 'renew') {
1367
+			$subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1368
+			$client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1369
+		} elseif ($message_type == 'upgrade') {
1370
+			$subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1371
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1372
+		} elseif ($message_type == 'claim_approved') {
1373
+			$subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1374
+			$client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1375
+		} elseif ($message_type == 'claim_rejected') {
1376
+			$subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1377
+			$client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1378
+		} elseif ($message_type == 'claim_requested') {
1379
+			$subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1380
+			$client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1381
+		} elseif ($message_type == 'auto_claim') {
1382
+			$subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1383
+			$client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1384
+		} elseif ($message_type == 'payment_success') {
1385
+			$subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1386
+			$client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1387
+		} elseif ($message_type == 'payment_fail') {
1388
+			$subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1389
+			$client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1390
+		}
1391
+		$transaction_details = $custom_1;
1392
+		$fromEmail = get_option('site_email');
1393
+		$fromEmailName = get_site_emailName();
1394 1394
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1395
-        $pkg_limit = get_property_price_info_listing($page_id);
1396
-        $alivedays = $pkg_limit['days'];
1397
-        $productlink = get_permalink($page_id);
1398
-        $post_info = get_post($page_id);
1399
-        $post_date = date('dS F,Y', strtotime($post_info->post_date));
1400
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1401
-        $loginurl = geodir_login_url();
1402
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1403
-        $siteurl = home_url();
1404
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1405
-        $user_info = get_userdata($user_id);
1406
-        $user_email = $user_info->user_email;
1407
-        $display_name = geodir_get_client_name($user_id);
1408
-        $user_login = $user_info->user_login;
1409
-        $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1410
-        if ($number_of_grace_days == '') {
1411
-            $number_of_grace_days = 1;
1412
-        }
1413
-        if ($post_info->post_type == 'event') {
1414
-            $post_type = 'event';
1415
-        } else {
1416
-            $post_type = 'listing';
1417
-        }
1418
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1419
-        $search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]');
1420
-        $replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details);
1421
-        $client_message = str_replace($search_array, $replace_array, $client_message);
1422
-        $subject = str_replace($search_array, $replace_array, $subject);
1423
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1424
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1425
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1426
-
1427
-        $to = $fromEmail;
1428
-        $message = $client_message;
1429
-        $sent = wp_mail($to, $subject, $message, $headers);
1430
-        if( ! $sent ) {
1431
-            if ( is_array( $to ) ) {
1432
-                $to = implode( ',', $to );
1433
-            }
1434
-            $log_message = sprintf(
1435
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1436
-                $message_type,
1437
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1438
-                $to,
1439
-                $subject
1440
-            );
1441
-            geodir_error_log( $log_message );
1442
-        }
1443
-    }
1395
+		$pkg_limit = get_property_price_info_listing($page_id);
1396
+		$alivedays = $pkg_limit['days'];
1397
+		$productlink = get_permalink($page_id);
1398
+		$post_info = get_post($page_id);
1399
+		$post_date = date('dS F,Y', strtotime($post_info->post_date));
1400
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1401
+		$loginurl = geodir_login_url();
1402
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1403
+		$siteurl = home_url();
1404
+		$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1405
+		$user_info = get_userdata($user_id);
1406
+		$user_email = $user_info->user_email;
1407
+		$display_name = geodir_get_client_name($user_id);
1408
+		$user_login = $user_info->user_login;
1409
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1410
+		if ($number_of_grace_days == '') {
1411
+			$number_of_grace_days = 1;
1412
+		}
1413
+		if ($post_info->post_type == 'event') {
1414
+			$post_type = 'event';
1415
+		} else {
1416
+			$post_type = 'listing';
1417
+		}
1418
+		$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1419
+		$search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]');
1420
+		$replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details);
1421
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1422
+		$subject = str_replace($search_array, $replace_array, $subject);
1423
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1424
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1425
+		$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1426
+
1427
+		$to = $fromEmail;
1428
+		$message = $client_message;
1429
+		$sent = wp_mail($to, $subject, $message, $headers);
1430
+		if( ! $sent ) {
1431
+			if ( is_array( $to ) ) {
1432
+				$to = implode( ',', $to );
1433
+			}
1434
+			$log_message = sprintf(
1435
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1436
+				$message_type,
1437
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1438
+				$to,
1439
+				$subject
1440
+			);
1441
+			geodir_error_log( $log_message );
1442
+		}
1443
+	}
1444 1444
 }
1445 1445
 
1446 1446
 if (!function_exists('sendEmail')) {
1447
-    /**
1448
-     * @todo could be a duplicate of geodir_sendEmail.
1449
-     *
1450
-     * @since 1.0.0
1451
-     * @package GeoDirectory
1452
-     * @param string $fromEmail Sender email address.
1453
-     * @param string $fromEmailName Sender name.
1454
-     * @param string $toEmail Receiver email address.
1455
-     * @param string $toEmailName Receiver name.
1456
-     * @param string $to_subject Email subject.
1457
-     * @param string $to_message Email content.
1458
-     * @param string $extra Not being used.
1459
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1460
-     * @param string $post_id The post ID.
1461
-     * @param string $user_id The user ID.
1462
-     */
1463
-    function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1464
-    {
1465
-        $login_details = '';
1466
-        if ($message_type == 'send_friend') {
1467
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1468
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1469
-        } elseif ($message_type == 'send_enquiry') {
1470
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1471
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1472
-        } elseif ($message_type == 'forgot_password') {
1473
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1474
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1475
-            $login_details = $to_message;
1476
-        } elseif ($message_type == 'registration') {
1477
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1478
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1479
-            $login_details = $to_message;
1480
-        }
1481
-        $to_message = nl2br($to_message);
1482
-        $sitefromEmail = get_option('site_email');
1483
-        $sitefromEmailName = get_site_emailName();
1484
-        $productlink = get_permalink($post_id);
1485
-        $post_info = get_post($post_id);
1486
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1487
-        $siteurl = home_url();
1488
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1489
-        $loginurl = geodir_login_url();
1490
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1491
-        if ($fromEmail == '') {
1492
-            $fromEmail = get_option('site_email');
1493
-        }
1494
-        if ($fromEmailName == '') {
1495
-            $fromEmailName = get_option('site_email_name');
1496
-        }
1497
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1498
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1499
-        $message = str_replace($search_array, $replace_array, $message);
1500
-
1501
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1502
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1503
-        $subject = str_replace($search_array, $replace_array, $subject);
1504
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1505
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1506
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1507
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1508
-
1509
-        $to = $toEmail;
1510
-
1511
-        $sent = wp_mail($to, $subject, $message, $headers);
1512
-        if( ! $sent ) {
1513
-            if ( is_array( $to ) ) {
1514
-                $to = implode( ',', $to );
1515
-            }
1516
-            $log_message = sprintf(
1517
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1518
-                $message_type,
1519
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1520
-                $to,
1521
-                $subject
1522
-            );
1523
-            geodir_error_log( $log_message );
1524
-        }
1447
+	/**
1448
+	 * @todo could be a duplicate of geodir_sendEmail.
1449
+	 *
1450
+	 * @since 1.0.0
1451
+	 * @package GeoDirectory
1452
+	 * @param string $fromEmail Sender email address.
1453
+	 * @param string $fromEmailName Sender name.
1454
+	 * @param string $toEmail Receiver email address.
1455
+	 * @param string $toEmailName Receiver name.
1456
+	 * @param string $to_subject Email subject.
1457
+	 * @param string $to_message Email content.
1458
+	 * @param string $extra Not being used.
1459
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1460
+	 * @param string $post_id The post ID.
1461
+	 * @param string $user_id The user ID.
1462
+	 */
1463
+	function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1464
+	{
1465
+		$login_details = '';
1466
+		if ($message_type == 'send_friend') {
1467
+			$subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1468
+			$message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1469
+		} elseif ($message_type == 'send_enquiry') {
1470
+			$subject = __(get_option('email_enquiry_subject'),'geodirectory');
1471
+			$message = __(get_option('email_enquiry_content'),'geodirectory');
1472
+		} elseif ($message_type == 'forgot_password') {
1473
+			$subject = __(get_option('forgot_password_subject'),'geodirectory');
1474
+			$message = __(get_option('forgot_password_content'),'geodirectory');
1475
+			$login_details = $to_message;
1476
+		} elseif ($message_type == 'registration') {
1477
+			$subject = __(get_option('registration_success_email_subject'),'geodirectory');
1478
+			$message = __(get_option('registration_success_email_content'),'geodirectory');
1479
+			$login_details = $to_message;
1480
+		}
1481
+		$to_message = nl2br($to_message);
1482
+		$sitefromEmail = get_option('site_email');
1483
+		$sitefromEmailName = get_site_emailName();
1484
+		$productlink = get_permalink($post_id);
1485
+		$post_info = get_post($post_id);
1486
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1487
+		$siteurl = home_url();
1488
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1489
+		$loginurl = geodir_login_url();
1490
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1491
+		if ($fromEmail == '') {
1492
+			$fromEmail = get_option('site_email');
1493
+		}
1494
+		if ($fromEmailName == '') {
1495
+			$fromEmailName = get_option('site_email_name');
1496
+		}
1497
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1498
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1499
+		$message = str_replace($search_array, $replace_array, $message);
1500
+
1501
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1502
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1503
+		$subject = str_replace($search_array, $replace_array, $subject);
1504
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1505
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1506
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
1507
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1508
+
1509
+		$to = $toEmail;
1510
+
1511
+		$sent = wp_mail($to, $subject, $message, $headers);
1512
+		if( ! $sent ) {
1513
+			if ( is_array( $to ) ) {
1514
+				$to = implode( ',', $to );
1515
+			}
1516
+			$log_message = sprintf(
1517
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1518
+				$message_type,
1519
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1520
+				$to,
1521
+				$subject
1522
+			);
1523
+			geodir_error_log( $log_message );
1524
+		}
1525 1525
 
1526
-        ///////// ADMIN BCC EMIALS
1527
-        $admin_bcc = false;
1528
-        if ($message_type == 'registration') {
1529
-            $message_raw = explode(__("Password:", 'geodirectory'), $message);
1530
-            $message_raw2 = explode("</p>", $message_raw[1], 2);
1531
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1532
-        }
1533
-        $adminEmail = get_bloginfo('admin_email');
1534
-        $to = $adminEmail;
1526
+		///////// ADMIN BCC EMIALS
1527
+		$admin_bcc = false;
1528
+		if ($message_type == 'registration') {
1529
+			$message_raw = explode(__("Password:", 'geodirectory'), $message);
1530
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1531
+			$message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1532
+		}
1533
+		$adminEmail = get_bloginfo('admin_email');
1534
+		$to = $adminEmail;
1535 1535
 
1536
-        if ($message_type == 'registration' && get_option('bcc_new_user')) {
1537
-            $subject .= ' - ADMIN BCC COPY';
1538
-            $admin_bcc = true;
1539
-        }
1540
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1541
-            $subject .= ' - ADMIN BCC COPY';
1542
-            $admin_bcc = true;
1543
-        }
1544
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1545
-            $subject .= ' - ADMIN BCC COPY';
1546
-            $admin_bcc = true;
1547
-        }
1536
+		if ($message_type == 'registration' && get_option('bcc_new_user')) {
1537
+			$subject .= ' - ADMIN BCC COPY';
1538
+			$admin_bcc = true;
1539
+		}
1540
+		elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1541
+			$subject .= ' - ADMIN BCC COPY';
1542
+			$admin_bcc = true;
1543
+		}
1544
+		elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1545
+			$subject .= ' - ADMIN BCC COPY';
1546
+			$admin_bcc = true;
1547
+		}
1548 1548
 
1549
-        if($admin_bcc === true){
1550
-            $sent = wp_mail($to, $subject, $message, $headers);
1551
-            if( ! $sent ) {
1552
-                if ( is_array( $to ) ) {
1553
-                    $to = implode( ',', $to );
1554
-                }
1555
-                $log_message = sprintf(
1556
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1557
-                    $message_type,
1558
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1559
-                    $to,
1560
-                    $subject
1561
-                );
1562
-                geodir_error_log( $log_message );
1563
-            }
1564
-        }
1549
+		if($admin_bcc === true){
1550
+			$sent = wp_mail($to, $subject, $message, $headers);
1551
+			if( ! $sent ) {
1552
+				if ( is_array( $to ) ) {
1553
+					$to = implode( ',', $to );
1554
+				}
1555
+				$log_message = sprintf(
1556
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1557
+					$message_type,
1558
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1559
+					$to,
1560
+					$subject
1561
+				);
1562
+				geodir_error_log( $log_message );
1563
+			}
1564
+		}
1565 1565
 
1566
-    }
1566
+	}
1567 1567
 }
1568 1568
 
1569 1569
 /*
@@ -1581,16 +1581,16 @@  discard block
 block discarded – undo
1581 1581
  */
1582 1582
 function gd_lang_object_ids($ids_array, $type)
1583 1583
 {
1584
-    if (function_exists('icl_object_id')) {
1585
-        $res = array();
1586
-        foreach ($ids_array as $id) {
1587
-            $xlat = icl_object_id($id, $type, false);
1588
-            if (!is_null($xlat)) $res[] = $xlat;
1589
-        }
1590
-        return $res;
1591
-    } else {
1592
-        return $ids_array;
1593
-    }
1584
+	if (function_exists('icl_object_id')) {
1585
+		$res = array();
1586
+		foreach ($ids_array as $id) {
1587
+			$xlat = icl_object_id($id, $type, false);
1588
+			if (!is_null($xlat)) $res[] = $xlat;
1589
+		}
1590
+		return $res;
1591
+	} else {
1592
+		return $ids_array;
1593
+	}
1594 1594
 }
1595 1595
 
1596 1596
 
@@ -1605,31 +1605,31 @@  discard block
 block discarded – undo
1605 1605
  * @return array Modified Body CSS classes.
1606 1606
  */
1607 1607
 function geodir_custom_posts_body_class($classes) {
1608
-    global $wpdb, $wp;
1609
-    $post_types = geodir_get_posttypes('object');
1610
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1611
-        $classes[] = 'geodir_custom_posts';
1612
-    }
1613
-
1614
-    // fix body class for signup page
1615
-    if (geodir_is_page('login')) {
1616
-        $new_classes = array();
1617
-        $new_classes[] = 'signup page-geodir-signup';
1618
-        if (!empty($classes)) {
1619
-            foreach ($classes as $class) {
1620
-                if ($class && $class != 'home' && $class != 'blog') {
1621
-                    $new_classes[] = $class;
1622
-                }
1623
-            }
1624
-        }
1625
-        $classes = $new_classes;
1626
-    }
1608
+	global $wpdb, $wp;
1609
+	$post_types = geodir_get_posttypes('object');
1610
+	if (!empty($post_types) && count((array)$post_types) > 1) {
1611
+		$classes[] = 'geodir_custom_posts';
1612
+	}
1627 1613
 
1628
-    if (geodir_is_geodir_page()) {
1629
-        $classes[] = 'geodir-page';
1630
-    }
1614
+	// fix body class for signup page
1615
+	if (geodir_is_page('login')) {
1616
+		$new_classes = array();
1617
+		$new_classes[] = 'signup page-geodir-signup';
1618
+		if (!empty($classes)) {
1619
+			foreach ($classes as $class) {
1620
+				if ($class && $class != 'home' && $class != 'blog') {
1621
+					$new_classes[] = $class;
1622
+				}
1623
+			}
1624
+		}
1625
+		$classes = $new_classes;
1626
+	}
1631 1627
 
1632
-    return $classes;
1628
+	if (geodir_is_geodir_page()) {
1629
+		$classes[] = 'geodir-page';
1630
+	}
1631
+
1632
+	return $classes;
1633 1633
 }
1634 1634
 
1635 1635
 add_filter('body_class', 'geodir_custom_posts_body_class'); // let's add a class to the body so we can style the new addition to the search
@@ -1644,12 +1644,12 @@  discard block
 block discarded – undo
1644 1644
  */
1645 1645
 function geodir_map_zoom_level()
1646 1646
 {
1647
-    /**
1648
-     * Filter GD map zoom level.
1649
-     *
1650
-     * @since 1.0.0
1651
-     */
1652
-    return apply_filters('geodir_map_zoom_level', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
1647
+	/**
1648
+	 * Filter GD map zoom level.
1649
+	 *
1650
+	 * @since 1.0.0
1651
+	 */
1652
+	return apply_filters('geodir_map_zoom_level', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
1653 1653
 
1654 1654
 }
1655 1655
 
@@ -1663,12 +1663,12 @@  discard block
 block discarded – undo
1663 1663
  */
1664 1664
 function geodir_option_version_backup($geodir_option_name)
1665 1665
 {
1666
-    $version_date = time();
1667
-    $geodir_option = get_option($geodir_option_name);
1666
+	$version_date = time();
1667
+	$geodir_option = get_option($geodir_option_name);
1668 1668
 
1669
-    if (!empty($geodir_option)) {
1670
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1671
-    }
1669
+	if (!empty($geodir_option)) {
1670
+		add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1671
+	}
1672 1672
 }
1673 1673
 
1674 1674
 /**
@@ -1681,11 +1681,11 @@  discard block
 block discarded – undo
1681 1681
  */
1682 1682
 function get_page_id_geodir_add_listing_page($page_id)
1683 1683
 {
1684
-    if (geodir_wpml_multilingual_status()) {
1685
-        $post_type = 'post_page';
1686
-        $page_id = geodir_get_wpml_element_id($page_id, $post_type);
1687
-    }
1688
-    return $page_id;
1684
+	if (geodir_wpml_multilingual_status()) {
1685
+		$post_type = 'post_page';
1686
+		$page_id = geodir_get_wpml_element_id($page_id, $post_type);
1687
+	}
1688
+	return $page_id;
1689 1689
 }
1690 1690
 
1691 1691
 /**
@@ -1697,10 +1697,10 @@  discard block
 block discarded – undo
1697 1697
  */
1698 1698
 function geodir_wpml_multilingual_status()
1699 1699
 {
1700
-    if (function_exists('icl_object_id')) {
1701
-        return true;
1702
-    }
1703
-    return false;
1700
+	if (function_exists('icl_object_id')) {
1701
+		return true;
1702
+	}
1703
+	return false;
1704 1704
 }
1705 1705
 
1706 1706
 /**
@@ -1714,22 +1714,22 @@  discard block
 block discarded – undo
1714 1714
  */
1715 1715
 function geodir_get_wpml_element_id($page_id, $post_type)
1716 1716
 {
1717
-    global $sitepress;
1718
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1719
-        $trid = $sitepress->get_element_trid($page_id, $post_type);
1717
+	global $sitepress;
1718
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1719
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
1720 1720
 
1721
-        if ($trid > 0) {
1722
-            $translations = $sitepress->get_element_translations($trid, $post_type);
1721
+		if ($trid > 0) {
1722
+			$translations = $sitepress->get_element_translations($trid, $post_type);
1723 1723
 
1724
-            $lang = $sitepress->get_current_language();
1725
-            $lang = $lang ? $lang : $sitepress->get_default_language();
1724
+			$lang = $sitepress->get_current_language();
1725
+			$lang = $lang ? $lang : $sitepress->get_default_language();
1726 1726
 
1727
-            if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1728
-                $page_id = $translations[$lang]->element_id;
1729
-            }
1730
-        }
1731
-    }
1732
-    return $page_id;
1727
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1728
+				$page_id = $translations[$lang]->element_id;
1729
+			}
1730
+		}
1731
+	}
1732
+	return $page_id;
1733 1733
 }
1734 1734
 
1735 1735
 /**
@@ -1741,20 +1741,20 @@  discard block
 block discarded – undo
1741 1741
  */
1742 1742
 function geodir_wpml_check_element_id()
1743 1743
 {
1744
-    global $sitepress;
1745
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1746
-        $el_type = 'post_page';
1747
-        $el_id = get_option('geodir_add_listing_page');
1748
-        $default_lang = $sitepress->get_default_language();
1749
-        $el_details = $sitepress->get_element_language_details($el_id, $el_type);
1750
-
1751
-        if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1752
-            if (!$el_details->source_language_code) {
1753
-                $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1754
-                $sitepress->icl_translations_cache->clear();
1755
-            }
1756
-        }
1757
-    }
1744
+	global $sitepress;
1745
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1746
+		$el_type = 'post_page';
1747
+		$el_id = get_option('geodir_add_listing_page');
1748
+		$default_lang = $sitepress->get_default_language();
1749
+		$el_details = $sitepress->get_element_language_details($el_id, $el_type);
1750
+
1751
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1752
+			if (!$el_details->source_language_code) {
1753
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1754
+				$sitepress->icl_translations_cache->clear();
1755
+			}
1756
+		}
1757
+	}
1758 1758
 }
1759 1759
 
1760 1760
 /**
@@ -1769,44 +1769,44 @@  discard block
 block discarded – undo
1769 1769
  */
1770 1770
 function geodir_widget_listings_get_order($query_args)
1771 1771
 {
1772
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1773
-
1774
-    $query_args = $gd_query_args_widgets;
1775
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1776
-        return $wpdb->posts . ".post_date DESC, ";
1777
-    }
1778
-
1779
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1780
-    $table = $plugin_prefix . $post_type . '_detail';
1781
-
1782
-    $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1783
-
1784
-    switch ($sort_by) {
1785
-        case 'latest':
1786
-        case 'newest':
1787
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1788
-            break;
1789
-        case 'featured':
1790
-            $orderby = $table . ".is_featured ASC, ";
1791
-            break;
1792
-        case 'az':
1793
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1794
-            break;
1795
-        case 'high_review':
1796
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1797
-            break;
1798
-        case 'high_rating':
1799
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1800
-            break;
1801
-        case 'random':
1802
-            $orderby = "RAND(), ";
1803
-            break;
1804
-        default:
1805
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1806
-            break;
1807
-    }
1808
-
1809
-    return $orderby;
1772
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1773
+
1774
+	$query_args = $gd_query_args_widgets;
1775
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1776
+		return $wpdb->posts . ".post_date DESC, ";
1777
+	}
1778
+
1779
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1780
+	$table = $plugin_prefix . $post_type . '_detail';
1781
+
1782
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1783
+
1784
+	switch ($sort_by) {
1785
+		case 'latest':
1786
+		case 'newest':
1787
+			$orderby = $wpdb->posts . ".post_date DESC, ";
1788
+			break;
1789
+		case 'featured':
1790
+			$orderby = $table . ".is_featured ASC, ";
1791
+			break;
1792
+		case 'az':
1793
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1794
+			break;
1795
+		case 'high_review':
1796
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1797
+			break;
1798
+		case 'high_rating':
1799
+			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
1800
+			break;
1801
+		case 'random':
1802
+			$orderby = "RAND(), ";
1803
+			break;
1804
+		default:
1805
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1806
+			break;
1807
+	}
1808
+
1809
+	return $orderby;
1810 1810
 }
1811 1811
 
1812 1812
 /**
@@ -1824,127 +1824,127 @@  discard block
 block discarded – undo
1824 1824
  */
1825 1825
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
1826 1826
 {
1827
-    global $wpdb, $plugin_prefix, $table_prefix;
1828
-    $GLOBALS['gd_query_args_widgets'] = $query_args;
1829
-    $gd_query_args_widgets = $query_args;
1830
-
1831
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1832
-    $table = $plugin_prefix . $post_type . '_detail';
1833
-
1834
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1835
-    /**
1836
-     * Filter widget listing fields string part that is being used for query.
1837
-     *
1838
-     * @since 1.0.0
1839
-     * @param string $fields Fields string.
1840
-     * @param string $table Table name.
1841
-     * @param string $post_type Post type.
1842
-     */
1843
-    $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1844
-
1845
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1846
-
1847
-    ########### WPML ###########
1848
-
1849
-    if (function_exists('icl_object_id')) {
1850
-        global $sitepress;
1851
-        $lang_code = ICL_LANGUAGE_CODE;
1852
-        $default_lang_code = $sitepress->get_default_language();
1853
-        if ($lang_code) {
1854
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1855
-        }
1856
-    }
1857
-
1858
-    ########### WPML ###########
1827
+	global $wpdb, $plugin_prefix, $table_prefix;
1828
+	$GLOBALS['gd_query_args_widgets'] = $query_args;
1829
+	$gd_query_args_widgets = $query_args;
1830
+
1831
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1832
+	$table = $plugin_prefix . $post_type . '_detail';
1833
+
1834
+	$fields = $wpdb->posts . ".*, " . $table . ".*";
1835
+	/**
1836
+	 * Filter widget listing fields string part that is being used for query.
1837
+	 *
1838
+	 * @since 1.0.0
1839
+	 * @param string $fields Fields string.
1840
+	 * @param string $table Table name.
1841
+	 * @param string $post_type Post type.
1842
+	 */
1843
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1844
+
1845
+	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1846
+
1847
+	########### WPML ###########
1848
+
1849
+	if (function_exists('icl_object_id')) {
1850
+		global $sitepress;
1851
+		$lang_code = ICL_LANGUAGE_CODE;
1852
+		$default_lang_code = $sitepress->get_default_language();
1853
+		if ($lang_code) {
1854
+			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1855
+		}
1856
+	}
1859 1857
 
1860
-    /**
1861
-     * Filter widget listing join clause string part that is being used for query.
1862
-     *
1863
-     * @since 1.0.0
1864
-     * @param string $join Join clause string.
1865
-     * @param string $post_type Post type.
1866
-     */
1867
-    $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1858
+	########### WPML ###########
1868 1859
 
1869
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1860
+	/**
1861
+	 * Filter widget listing join clause string part that is being used for query.
1862
+	 *
1863
+	 * @since 1.0.0
1864
+	 * @param string $join Join clause string.
1865
+	 * @param string $post_type Post type.
1866
+	 */
1867
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1870 1868
 
1871
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
1869
+	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1872 1870
 
1873
-    ########### WPML ###########
1874
-    if (function_exists('icl_object_id')) {
1875
-        if ($lang_code) {
1876
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
1877
-        }
1878
-    }
1879
-    ########### WPML ###########
1880
-    /**
1881
-     * Filter widget listing where clause string part that is being used for query.
1882
-     *
1883
-     * @since 1.0.0
1884
-     * @param string $where Where clause string.
1885
-     * @param string $post_type Post type.
1886
-     */
1887
-    $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
1888
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
1889
-
1890
-    $groupby = " GROUP BY $wpdb->posts.ID ";
1891
-    /**
1892
-     * Filter widget listing groupby clause string part that is being used for query.
1893
-     *
1894
-     * @since 1.0.0
1895
-     * @param string $groupby Group by clause string.
1896
-     * @param string $post_type Post type.
1897
-     */
1898
-    $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
1871
+	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
1899 1872
 
1900
-    if ($count_only) {
1901
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1873
+	########### WPML ###########
1874
+	if (function_exists('icl_object_id')) {
1875
+		if ($lang_code) {
1876
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
1877
+		}
1878
+	}
1879
+	########### WPML ###########
1880
+	/**
1881
+	 * Filter widget listing where clause string part that is being used for query.
1882
+	 *
1883
+	 * @since 1.0.0
1884
+	 * @param string $where Where clause string.
1885
+	 * @param string $post_type Post type.
1886
+	 */
1887
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
1888
+	$where = $where != '' ? " WHERE 1=1 " . $where : '';
1889
+
1890
+	$groupby = " GROUP BY $wpdb->posts.ID ";
1891
+	/**
1892
+	 * Filter widget listing groupby clause string part that is being used for query.
1893
+	 *
1894
+	 * @since 1.0.0
1895
+	 * @param string $groupby Group by clause string.
1896
+	 * @param string $post_type Post type.
1897
+	 */
1898
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
1899
+
1900
+	if ($count_only) {
1901
+		$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1902 1902
 			" . $join . "
1903 1903
 			" . $where;
1904
-        $rows = (int)$wpdb->get_var($sql);
1905
-    } else {
1906
-        $orderby = geodir_widget_listings_get_order($query_args);
1907
-        /**
1908
-         * Filter widget listing orderby clause string part that is being used for query.
1909
-         *
1910
-         * @since 1.0.0
1911
-         * @param string $orderby Order by clause string.
1912
-         * @param string $table Table name.
1913
-         * @param string $post_type Post type.
1914
-         */
1915
-        $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
1916
-        $orderby .= $wpdb->posts . ".post_title ASC";
1917
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
1918
-
1919
-        $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
1920
-        /**
1921
-         * Filter widget listing limit that is being used for query.
1922
-         *
1923
-         * @since 1.0.0
1924
-         * @param int $limit Query results limit.
1925
-         * @param string $post_type Post type.
1926
-         */
1927
-        $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1928
-
1929
-        $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1930
-        if ( !$page )
1931
-            $page = 1;
1932
-
1933
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1934
-
1935
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
1904
+		$rows = (int)$wpdb->get_var($sql);
1905
+	} else {
1906
+		$orderby = geodir_widget_listings_get_order($query_args);
1907
+		/**
1908
+		 * Filter widget listing orderby clause string part that is being used for query.
1909
+		 *
1910
+		 * @since 1.0.0
1911
+		 * @param string $orderby Order by clause string.
1912
+		 * @param string $table Table name.
1913
+		 * @param string $post_type Post type.
1914
+		 */
1915
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
1916
+		$orderby .= $wpdb->posts . ".post_title ASC";
1917
+		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
1918
+
1919
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
1920
+		/**
1921
+		 * Filter widget listing limit that is being used for query.
1922
+		 *
1923
+		 * @since 1.0.0
1924
+		 * @param int $limit Query results limit.
1925
+		 * @param string $post_type Post type.
1926
+		 */
1927
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1928
+
1929
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1930
+		if ( !$page )
1931
+			$page = 1;
1932
+
1933
+		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1934
+
1935
+		$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
1936 1936
 			" . $join . "
1937 1937
 			" . $where . "
1938 1938
 			" . $groupby . "
1939 1939
 			" . $orderby . "
1940 1940
 			" . $limit;
1941
-        $rows = $wpdb->get_results($sql);
1942
-    }
1941
+		$rows = $wpdb->get_results($sql);
1942
+	}
1943 1943
 
1944
-    unset($GLOBALS['gd_query_args_widgets']);
1945
-    unset($gd_query_args_widgets);
1944
+	unset($GLOBALS['gd_query_args_widgets']);
1945
+	unset($gd_query_args_widgets);
1946 1946
 
1947
-    return $rows;
1947
+	return $rows;
1948 1948
 }
1949 1949
 
1950 1950
 /**
@@ -1959,21 +1959,21 @@  discard block
 block discarded – undo
1959 1959
  */
1960 1960
 function geodir_function_widget_listings_fields($fields)
1961 1961
 {
1962
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1962
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1963 1963
 
1964
-    $query_args = $gd_query_args_widgets;
1965
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1966
-        return $fields;
1967
-    }
1968
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1969
-    $table = $plugin_prefix . $post_type . '_detail';
1964
+	$query_args = $gd_query_args_widgets;
1965
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1966
+		return $fields;
1967
+	}
1968
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1969
+	$table = $plugin_prefix . $post_type . '_detail';
1970 1970
 
1971
-    /*
1971
+	/*
1972 1972
 	if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
1973 1973
 		$fields .= $fields != '' ? ", " . EVENT_SCHEDULE . ".*" : EVENT_SCHEDULE . ".*";
1974 1974
 	}
1975 1975
 	*/
1976
-    return $fields;
1976
+	return $fields;
1977 1977
 }
1978 1978
 
1979 1979
 /**
@@ -1988,34 +1988,34 @@  discard block
 block discarded – undo
1988 1988
  */
1989 1989
 function geodir_function_widget_listings_join($join)
1990 1990
 {
1991
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1991
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1992 1992
 
1993
-    $query_args = $gd_query_args_widgets;
1994
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1995
-        return $where;
1996
-    }
1993
+	$query_args = $gd_query_args_widgets;
1994
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1995
+		return $where;
1996
+	}
1997 1997
 
1998
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1999
-    $table = $plugin_prefix . $post_type . '_detail';
1998
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1999
+	$table = $plugin_prefix . $post_type . '_detail';
2000 2000
 
2001
-    if (!empty($query_args['with_pics_only'])) {
2002
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2003
-    }
2001
+	if (!empty($query_args['with_pics_only'])) {
2002
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2003
+	}
2004 2004
 
2005
-    /*
2005
+	/*
2006 2006
 	if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
2007 2007
 		$join .= " INNER JOIN " . EVENT_SCHEDULE ." ON (" . EVENT_SCHEDULE .".event_id = " . $wpdb->posts . ".ID)";
2008 2008
 	}
2009 2009
 	*/
2010 2010
 
2011
-    if (!empty($query_args['tax_query'])) {
2012
-        $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2013
-        if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2014
-            $join .= $tax_queries['join'];
2015
-        }
2016
-    }
2011
+	if (!empty($query_args['tax_query'])) {
2012
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2013
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2014
+			$join .= $tax_queries['join'];
2015
+		}
2016
+	}
2017 2017
 
2018
-    return $join;
2018
+	return $join;
2019 2019
 }
2020 2020
 
2021 2021
 /**
@@ -2030,54 +2030,54 @@  discard block
 block discarded – undo
2030 2030
  */
2031 2031
 function geodir_function_widget_listings_where($where)
2032 2032
 {
2033
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2034
-
2035
-    $query_args = $gd_query_args_widgets;
2036
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2037
-        return $where;
2038
-    }
2039
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2040
-    $table = $plugin_prefix . $post_type . '_detail';
2041
-
2042
-    if (!empty($query_args)) {
2043
-        if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2044
-            $where = geodir_default_location_where($where, $table);
2045
-        }
2033
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2046 2034
 
2047
-        if (!empty($query_args['post_author'])) {
2048
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2049
-        }
2035
+	$query_args = $gd_query_args_widgets;
2036
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2037
+		return $where;
2038
+	}
2039
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2040
+	$table = $plugin_prefix . $post_type . '_detail';
2041
+
2042
+	if (!empty($query_args)) {
2043
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2044
+			$where = geodir_default_location_where($where, $table);
2045
+		}
2046
+
2047
+		if (!empty($query_args['post_author'])) {
2048
+			$where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2049
+		}
2050 2050
         
2051
-        if (!empty($query_args['show_featured_only'])) {
2052
-            $where .= " AND " . $table . ".is_featured = '1'";
2053
-        }
2051
+		if (!empty($query_args['show_featured_only'])) {
2052
+			$where .= " AND " . $table . ".is_featured = '1'";
2053
+		}
2054 2054
 
2055
-        if (!empty($query_args['show_special_only'])) {
2056
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2057
-        }
2055
+		if (!empty($query_args['show_special_only'])) {
2056
+			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2057
+		}
2058 2058
 
2059
-        if (!empty($query_args['with_pics_only'])) {
2060
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2061
-        }
2059
+		if (!empty($query_args['with_pics_only'])) {
2060
+			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2061
+		}
2062 2062
 
2063
-        if (!empty($query_args['featured_image_only'])) {
2064
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2065
-        }
2063
+		if (!empty($query_args['featured_image_only'])) {
2064
+			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2065
+		}
2066 2066
 
2067
-        if (!empty($query_args['with_videos_only'])) {
2068
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2069
-        }
2067
+		if (!empty($query_args['with_videos_only'])) {
2068
+			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2069
+		}
2070 2070
 
2071
-        if (!empty($query_args['tax_query'])) {
2072
-            $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2071
+		if (!empty($query_args['tax_query'])) {
2072
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2073 2073
 
2074
-            if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2075
-                $where .= $tax_queries['where'];
2076
-            }
2077
-        }
2078
-    }
2074
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2075
+				$where .= $tax_queries['where'];
2076
+			}
2077
+		}
2078
+	}
2079 2079
 
2080
-    return $where;
2080
+	return $where;
2081 2081
 }
2082 2082
 
2083 2083
 /**
@@ -2092,23 +2092,23 @@  discard block
 block discarded – undo
2092 2092
  */
2093 2093
 function geodir_function_widget_listings_orderby($orderby)
2094 2094
 {
2095
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2095
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2096 2096
 
2097
-    $query_args = $gd_query_args_widgets;
2098
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2099
-        return $orderby;
2100
-    }
2097
+	$query_args = $gd_query_args_widgets;
2098
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2099
+		return $orderby;
2100
+	}
2101 2101
 
2102
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2103
-    $table = $plugin_prefix . $post_type . '_detail';
2102
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2103
+	$table = $plugin_prefix . $post_type . '_detail';
2104 2104
 
2105
-    /*
2105
+	/*
2106 2106
 	if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
2107 2107
 		$orderby .= EVENT_SCHEDULE . ".event_date ASC, " . EVENT_SCHEDULE . ".event_starttime ASC , " . $table . ".is_featured ASC, ";
2108 2108
 	}
2109 2109
 	*/
2110 2110
 
2111
-    return $orderby;
2111
+	return $orderby;
2112 2112
 }
2113 2113
 
2114 2114
 /**
@@ -2123,18 +2123,18 @@  discard block
 block discarded – undo
2123 2123
  */
2124 2124
 function geodir_function_widget_listings_limit($limit)
2125 2125
 {
2126
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2126
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2127 2127
 
2128
-    $query_args = $gd_query_args_widgets;
2129
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2130
-        return $limit;
2131
-    }
2128
+	$query_args = $gd_query_args_widgets;
2129
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2130
+		return $limit;
2131
+	}
2132 2132
 
2133
-    if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2134
-        $limit = (int)$query_args['posts_per_page'];
2135
-    }
2133
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2134
+		$limit = (int)$query_args['posts_per_page'];
2135
+	}
2136 2136
 
2137
-    return $limit;
2137
+	return $limit;
2138 2138
 }
2139 2139
 
2140 2140
 /**
@@ -2148,24 +2148,24 @@  discard block
 block discarded – undo
2148 2148
  */
2149 2149
 function geodir_media_image_large_width($default = 800, $params = '')
2150 2150
 {
2151
-    $large_size_w = get_option('large_size_w');
2152
-    $large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2153
-    $large_size_w = absint($large_size_w);
2154
-
2155
-    if (!get_option('geodir_use_wp_media_large_size')) {
2156
-        $large_size_w = 800;
2157
-    }
2158
-
2159
-    /**
2160
-     * Filter large image width.
2161
-     *
2162
-     * @since 1.0.0
2163
-     * @param int $large_size_w Large image width.
2164
-     * @param int $default Default width.
2165
-     * @param string|array $params Image parameters.
2166
-     */
2167
-    $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2168
-    return $large_size_w;
2151
+	$large_size_w = get_option('large_size_w');
2152
+	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2153
+	$large_size_w = absint($large_size_w);
2154
+
2155
+	if (!get_option('geodir_use_wp_media_large_size')) {
2156
+		$large_size_w = 800;
2157
+	}
2158
+
2159
+	/**
2160
+	 * Filter large image width.
2161
+	 *
2162
+	 * @since 1.0.0
2163
+	 * @param int $large_size_w Large image width.
2164
+	 * @param int $default Default width.
2165
+	 * @param string|array $params Image parameters.
2166
+	 */
2167
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2168
+	return $large_size_w;
2169 2169
 }
2170 2170
 
2171 2171
 /**
@@ -2179,25 +2179,25 @@  discard block
 block discarded – undo
2179 2179
  */
2180 2180
 function geodir_media_image_large_height($default = 800, $params = '')
2181 2181
 {
2182
-    $large_size_h = get_option('large_size_h');
2183
-    $large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2184
-    $large_size_h = absint($large_size_h);
2185
-
2186
-    if (!get_option('geodir_use_wp_media_large_size')) {
2187
-        $large_size_h = 800;
2188
-    }
2189
-
2190
-    /**
2191
-     * Filter large image height.
2192
-     *
2193
-     * @since 1.0.0
2194
-     * @param int $large_size_h Large image height.
2195
-     * @param int $default Default height.
2196
-     * @param string|array $params Image parameters.
2197
-     */
2198
-    $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2182
+	$large_size_h = get_option('large_size_h');
2183
+	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2184
+	$large_size_h = absint($large_size_h);
2185
+
2186
+	if (!get_option('geodir_use_wp_media_large_size')) {
2187
+		$large_size_h = 800;
2188
+	}
2199 2189
 
2200
-    return $large_size_h;
2190
+	/**
2191
+	 * Filter large image height.
2192
+	 *
2193
+	 * @since 1.0.0
2194
+	 * @param int $large_size_h Large image height.
2195
+	 * @param int $default Default height.
2196
+	 * @param string|array $params Image parameters.
2197
+	 */
2198
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2199
+
2200
+	return $large_size_h;
2201 2201
 }
2202 2202
 
2203 2203
 /**
@@ -2212,25 +2212,25 @@  discard block
 block discarded – undo
2212 2212
  */
2213 2213
 function geodir_sanitize_location_name($type, $name, $translate = true)
2214 2214
 {
2215
-    if ($name == '') {
2216
-        return NULL;
2217
-    }
2218
-
2219
-    $type = $type == 'gd_country' ? 'country' : $type;
2220
-    $type = $type == 'gd_region' ? 'region' : $type;
2221
-    $type = $type == 'gd_city' ? 'city' : $type;
2222
-
2223
-    $return = $name;
2224
-    if (function_exists('get_actual_location_name')) {
2225
-        $return = get_actual_location_name($type, $name, $translate);
2226
-    } else {
2227
-        $return = preg_replace('/-(\d+)$/', '', $return);
2228
-        $return = preg_replace('/[_-]/', ' ', $return);
2229
-        $return = geodir_ucwords($return);
2230
-        $return = $translate ? __($return, 'geodirectory') : $return;
2231
-    }
2232
-
2233
-    return $return;
2215
+	if ($name == '') {
2216
+		return NULL;
2217
+	}
2218
+
2219
+	$type = $type == 'gd_country' ? 'country' : $type;
2220
+	$type = $type == 'gd_region' ? 'region' : $type;
2221
+	$type = $type == 'gd_city' ? 'city' : $type;
2222
+
2223
+	$return = $name;
2224
+	if (function_exists('get_actual_location_name')) {
2225
+		$return = get_actual_location_name($type, $name, $translate);
2226
+	} else {
2227
+		$return = preg_replace('/-(\d+)$/', '', $return);
2228
+		$return = preg_replace('/[_-]/', ' ', $return);
2229
+		$return = geodir_ucwords($return);
2230
+		$return = $translate ? __($return, 'geodirectory') : $return;
2231
+	}
2232
+
2233
+	return $return;
2234 2234
 }
2235 2235
 
2236 2236
 
@@ -2244,14 +2244,14 @@  discard block
 block discarded – undo
2244 2244
 function geodir_comments_number($number)
2245 2245
 {
2246 2246
 
2247
-    if ($number > 1) {
2248
-        $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2249
-    } elseif ($number == 0 || $number == '') {
2250
-        $output = __('No Reviews', 'geodirectory');
2251
-    } else { // must be one
2252
-        $output = __('1 Review', 'geodirectory');
2253
-    }
2254
-    echo $output;
2247
+	if ($number > 1) {
2248
+		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2249
+	} elseif ($number == 0 || $number == '') {
2250
+		$output = __('No Reviews', 'geodirectory');
2251
+	} else { // must be one
2252
+		$output = __('1 Review', 'geodirectory');
2253
+	}
2254
+	echo $output;
2255 2255
 }
2256 2256
 
2257 2257
 /**
@@ -2264,23 +2264,23 @@  discard block
 block discarded – undo
2264 2264
  */
2265 2265
 function is_page_geodir_home()
2266 2266
 {
2267
-    global $wpdb;
2268
-    $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2269
-    if (function_exists('geodir_location_geo_home_link')) {
2270
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2271
-    }
2272
-    $home_url = home_url('', 'http');
2273
-    if (function_exists('geodir_location_geo_home_link')) {
2274
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2275
-    }
2276
-    $home_url = str_replace("www.", "", $home_url);
2277
-    if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
2278
-        return true;
2279
-    }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2280
-        return true;
2281
-    } else {
2282
-        return false;
2283
-    }
2267
+	global $wpdb;
2268
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2269
+	if (function_exists('geodir_location_geo_home_link')) {
2270
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2271
+	}
2272
+	$home_url = home_url('', 'http');
2273
+	if (function_exists('geodir_location_geo_home_link')) {
2274
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2275
+	}
2276
+	$home_url = str_replace("www.", "", $home_url);
2277
+	if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
2278
+		return true;
2279
+	}elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2280
+		return true;
2281
+	} else {
2282
+		return false;
2283
+	}
2284 2284
 
2285 2285
 }
2286 2286
 
@@ -2296,13 +2296,13 @@  discard block
 block discarded – undo
2296 2296
  */
2297 2297
 function geodir_wpseo_homepage_canonical($url)
2298 2298
 {
2299
-    global $post;
2299
+	global $post;
2300 2300
 
2301
-    if (is_page_geodir_home()) {
2302
-        return home_url();
2303
-    }
2301
+	if (is_page_geodir_home()) {
2302
+		return home_url();
2303
+	}
2304 2304
 
2305
-    return $url;
2305
+	return $url;
2306 2306
 }
2307 2307
 
2308 2308
 add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
@@ -2319,16 +2319,16 @@  discard block
 block discarded – undo
2319 2319
  */
2320 2320
 function geodir_googlemap_script_extra_details_page($extra)
2321 2321
 {
2322
-    global $post;
2323
-    $add_google_places_api = false;
2324
-    if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2325
-        $add_google_places_api = true;
2326
-    }
2327
-    if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2328
-        $extra .= "&amp;libraries=places";
2329
-    }
2330
-
2331
-    return $extra;
2322
+	global $post;
2323
+	$add_google_places_api = false;
2324
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2325
+		$add_google_places_api = true;
2326
+	}
2327
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2328
+		$extra .= "&amp;libraries=places";
2329
+	}
2330
+
2331
+	return $extra;
2332 2332
 }
2333 2333
 
2334 2334
 add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
@@ -2348,91 +2348,91 @@  discard block
 block discarded – undo
2348 2348
  */
2349 2349
 function geodir_popular_post_category_output($args = '', $instance = '')
2350 2350
 {
2351
-    // prints the widget
2352
-    global $wpdb, $plugin_prefix, $geodir_post_category_str;
2353
-    extract($args, EXTR_SKIP);
2351
+	// prints the widget
2352
+	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2353
+	extract($args, EXTR_SKIP);
2354 2354
 
2355
-    echo $before_widget;
2355
+	echo $before_widget;
2356 2356
 
2357
-    /** This filter is documented in geodirectory_widgets.php */
2358
-    $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2357
+	/** This filter is documented in geodirectory_widgets.php */
2358
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2359 2359
 
2360
-    $gd_post_type = geodir_get_current_posttype();
2360
+	$gd_post_type = geodir_get_current_posttype();
2361 2361
 
2362
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2363
-    $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2362
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2363
+	$default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2364 2364
 
2365
-    $taxonomy = array();
2366
-    if (!empty($gd_post_type)) {
2367
-        $taxonomy[] = $gd_post_type . "category";
2368
-    } else {
2369
-        $taxonomy = geodir_get_taxonomies($gd_post_type);
2370
-    }
2365
+	$taxonomy = array();
2366
+	if (!empty($gd_post_type)) {
2367
+		$taxonomy[] = $gd_post_type . "category";
2368
+	} else {
2369
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2370
+	}
2371 2371
 
2372
-    $terms = get_terms($taxonomy);
2373
-    $a_terms = array();
2374
-    $b_terms = array();
2372
+	$terms = get_terms($taxonomy);
2373
+	$a_terms = array();
2374
+	$b_terms = array();
2375 2375
 
2376
-    foreach ($terms as $term) {
2377
-        if ($term->count > 0) {
2378
-            $a_terms[$term->taxonomy][] = $term;
2379
-        }
2380
-    }
2376
+	foreach ($terms as $term) {
2377
+		if ($term->count > 0) {
2378
+			$a_terms[$term->taxonomy][] = $term;
2379
+		}
2380
+	}
2381 2381
 
2382
-    if (!empty($a_terms)) {
2383
-        foreach ($a_terms as $b_key => $b_val) {
2384
-            $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2385
-        }
2382
+	if (!empty($a_terms)) {
2383
+		foreach ($a_terms as $b_key => $b_val) {
2384
+			$b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2385
+		}
2386 2386
 
2387
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2388
-
2389
-        $tax_change_output = '';
2390
-        if (count($b_terms) > 1) {
2391
-            $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2392
-            foreach ($b_terms as $key => $val) {
2393
-                $ptype = get_post_type_object(str_replace("category", "", $key));
2394
-                $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2395
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2396
-            }
2397
-            $tax_change_output .= "</select>";
2398
-        }
2387
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2388
+
2389
+		$tax_change_output = '';
2390
+		if (count($b_terms) > 1) {
2391
+			$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2392
+			foreach ($b_terms as $key => $val) {
2393
+				$ptype = get_post_type_object(str_replace("category", "", $key));
2394
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2395
+				$tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2396
+			}
2397
+			$tax_change_output .= "</select>";
2398
+		}
2399 2399
 
2400
-        if (!empty($b_terms)) {
2401
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2402
-            global $cat_count;//make global so we can change via function
2403
-            $cat_count = 0;
2404
-            ?>
2400
+		if (!empty($b_terms)) {
2401
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2402
+			global $cat_count;//make global so we can change via function
2403
+			$cat_count = 0;
2404
+			?>
2405 2405
             <div class="geodir-category-list-in clearfix">
2406 2406
                 <div class="geodir-cat-list clearfix">
2407 2407
                     <?php
2408
-                    echo $before_title . __($title) . $after_title;
2408
+					echo $before_title . __($title) . $after_title;
2409 2409
 
2410
-                    echo $tax_change_output;
2410
+					echo $tax_change_output;
2411 2411
 
2412
-                    echo '<ul class="geodir-popular-cat-list">';
2412
+					echo '<ul class="geodir-popular-cat-list">';
2413 2413
 
2414
-                    geodir_helper_cat_list_output($terms, $category_limit);
2414
+					geodir_helper_cat_list_output($terms, $category_limit);
2415 2415
 
2416
-                    echo '</ul>';
2417
-                    ?>
2416
+					echo '</ul>';
2417
+					?>
2418 2418
                 </div>
2419 2419
                 <?php
2420
-                $hide = '';
2421
-                if ($cat_count < $category_limit) {
2422
-                    $hide = 'style="display:none;"';
2423
-                }
2424
-                echo "<div class='geodir-cat-list-more' $hide >";
2425
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2426
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2427
-                echo "</div>";
2428
-                /* add scripts */
2429
-                add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2430
-                ?>
2420
+				$hide = '';
2421
+				if ($cat_count < $category_limit) {
2422
+					$hide = 'style="display:none;"';
2423
+				}
2424
+				echo "<div class='geodir-cat-list-more' $hide >";
2425
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2426
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2427
+				echo "</div>";
2428
+				/* add scripts */
2429
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2430
+				?>
2431 2431
             </div>
2432 2432
         <?php
2433
-        }
2434
-    }
2435
-    echo $after_widget;
2433
+		}
2434
+	}
2435
+	echo $after_widget;
2436 2436
 }
2437 2437
 
2438 2438
 /**
@@ -2446,38 +2446,38 @@  discard block
 block discarded – undo
2446 2446
  */
2447 2447
 function geodir_helper_cat_list_output($terms, $category_limit)
2448 2448
 {
2449
-    global $geodir_post_category_str, $cat_count;
2450
-    $term_icons = geodir_get_term_icon();
2449
+	global $geodir_post_category_str, $cat_count;
2450
+	$term_icons = geodir_get_term_icon();
2451 2451
 
2452
-    $geodir_post_category_str = array();
2452
+	$geodir_post_category_str = array();
2453 2453
 
2454 2454
 
2455
-    foreach ($terms as $cat) {
2456
-        $post_type = str_replace("category", "", $cat->taxonomy);
2457
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2455
+	foreach ($terms as $cat) {
2456
+		$post_type = str_replace("category", "", $cat->taxonomy);
2457
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2458 2458
 
2459
-        $cat_count++;
2459
+		$cat_count++;
2460 2460
 
2461
-        $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2461
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2462 2462
 
2463
-        $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2464
-        $total_post = $cat->count;
2463
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2464
+		$total_post = $cat->count;
2465 2465
 
2466
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2467
-        /**
2468
-         * Filer the category term link.
2469
-         *
2470
-         * @since 1.4.5
2471
-         * @param string $term_link The term permalink.
2472
-         * @param int    $cat->term_id The term id.
2473
-         * @param string $post_type Wordpress post type.
2474
-         */
2475
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2466
+		$term_link = get_term_link( $cat, $cat->taxonomy );
2467
+		/**
2468
+		 * Filer the category term link.
2469
+		 *
2470
+		 * @since 1.4.5
2471
+		 * @param string $term_link The term permalink.
2472
+		 * @param int    $cat->term_id The term id.
2473
+		 * @param string $post_type Wordpress post type.
2474
+		 */
2475
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2476 2476
 
2477
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2478
-        echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
2479
-        echo '</a></li>';
2480
-    }
2477
+		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2478
+		echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
2479
+		echo '</a></li>';
2480
+	}
2481 2481
 }
2482 2482
 
2483 2483
 /**
@@ -2490,109 +2490,109 @@  discard block
 block discarded – undo
2490 2490
  * @param array|string $instance The settings for the particular instance of the widget.
2491 2491
  */
2492 2492
 function geodir_listing_slider_widget_output($args = '', $instance = '')
2493
-{
2494
-    // prints the widget
2495
-    extract($args, EXTR_SKIP);
2496
-
2497
-    echo $before_widget;
2498
-
2499
-    /** This filter is documented in geodirectory_widgets.php */
2500
-    $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2501
-    /**
2502
-     * Filter the widget post type.
2503
-     *
2504
-     * @since 1.0.0
2505
-     * @param string $instance['post_type'] Post type of listing.
2506
-     */
2507
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2508
-    /**
2509
-     * Filter the widget's term.
2510
-     *
2511
-     * @since 1.0.0
2512
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2513
-     */
2514
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2515
-    /**
2516
-     * Filter the widget listings limit.
2517
-     *
2518
-     * @since 1.0.0
2519
-     * @param string $instance['post_number'] Number of listings to display.
2520
-     */
2521
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2522
-    /**
2523
-     * Filter the widget listings limit shown at one time.
2524
-     *
2525
-     * @since 1.5.0
2526
-     * @param string $instance['max_show'] Number of listings to display on screen.
2527
-     */
2528
-    $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2529
-    /**
2530
-     * Filter the widget slide width.
2531
-     *
2532
-     * @since 1.5.0
2533
-     * @param string $instance['slide_width'] Width of the slides shown.
2534
-     */
2535
-    $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2536
-    /**
2537
-     * Filter widget's "show title" value.
2538
-     *
2539
-     * @since 1.0.0
2540
-     * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2541
-     */
2542
-    $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2543
-    /**
2544
-     * Filter widget's "slideshow" value.
2545
-     *
2546
-     * @since 1.0.0
2547
-     * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2548
-     */
2549
-    $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2550
-    /**
2551
-     * Filter widget's "animationLoop" value.
2552
-     *
2553
-     * @since 1.0.0
2554
-     * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2555
-     */
2556
-    $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2557
-    /**
2558
-     * Filter widget's "directionNav" value.
2559
-     *
2560
-     * @since 1.0.0
2561
-     * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2562
-     */
2563
-    $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2564
-    /**
2565
-     * Filter widget's "slideshowSpeed" value.
2566
-     *
2567
-     * @since 1.0.0
2568
-     * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2569
-     */
2570
-    $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2571
-    /**
2572
-     * Filter widget's "animationSpeed" value.
2573
-     *
2574
-     * @since 1.0.0
2575
-     * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2576
-     */
2577
-    $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2578
-    /**
2579
-     * Filter widget's "animation" value.
2580
-     *
2581
-     * @since 1.0.0
2582
-     * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2583
-     */
2584
-    $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2585
-    /**
2586
-     * Filter widget's "list_sort" type.
2587
-     *
2588
-     * @since 1.0.0
2589
-     * @param string $instance['list_sort'] Listing sort by type.
2590
-     */
2591
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2592
-    $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2593
-
2594
-    wp_enqueue_script('geodirectory-jquery-flexslider-js');
2595
-    ?>
2493
+{
2494
+	// prints the widget
2495
+	extract($args, EXTR_SKIP);
2496
+
2497
+	echo $before_widget;
2498
+
2499
+	/** This filter is documented in geodirectory_widgets.php */
2500
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2501
+	/**
2502
+	 * Filter the widget post type.
2503
+	 *
2504
+	 * @since 1.0.0
2505
+	 * @param string $instance['post_type'] Post type of listing.
2506
+	 */
2507
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2508
+	/**
2509
+	 * Filter the widget's term.
2510
+	 *
2511
+	 * @since 1.0.0
2512
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2513
+	 */
2514
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2515
+	/**
2516
+	 * Filter the widget listings limit.
2517
+	 *
2518
+	 * @since 1.0.0
2519
+	 * @param string $instance['post_number'] Number of listings to display.
2520
+	 */
2521
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2522
+	/**
2523
+	 * Filter the widget listings limit shown at one time.
2524
+	 *
2525
+	 * @since 1.5.0
2526
+	 * @param string $instance['max_show'] Number of listings to display on screen.
2527
+	 */
2528
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2529
+	/**
2530
+	 * Filter the widget slide width.
2531
+	 *
2532
+	 * @since 1.5.0
2533
+	 * @param string $instance['slide_width'] Width of the slides shown.
2534
+	 */
2535
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2536
+	/**
2537
+	 * Filter widget's "show title" value.
2538
+	 *
2539
+	 * @since 1.0.0
2540
+	 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2541
+	 */
2542
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2543
+	/**
2544
+	 * Filter widget's "slideshow" value.
2545
+	 *
2546
+	 * @since 1.0.0
2547
+	 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2548
+	 */
2549
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2550
+	/**
2551
+	 * Filter widget's "animationLoop" value.
2552
+	 *
2553
+	 * @since 1.0.0
2554
+	 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2555
+	 */
2556
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2557
+	/**
2558
+	 * Filter widget's "directionNav" value.
2559
+	 *
2560
+	 * @since 1.0.0
2561
+	 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2562
+	 */
2563
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2564
+	/**
2565
+	 * Filter widget's "slideshowSpeed" value.
2566
+	 *
2567
+	 * @since 1.0.0
2568
+	 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2569
+	 */
2570
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2571
+	/**
2572
+	 * Filter widget's "animationSpeed" value.
2573
+	 *
2574
+	 * @since 1.0.0
2575
+	 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2576
+	 */
2577
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2578
+	/**
2579
+	 * Filter widget's "animation" value.
2580
+	 *
2581
+	 * @since 1.0.0
2582
+	 * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2583
+	 */
2584
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2585
+	/**
2586
+	 * Filter widget's "list_sort" type.
2587
+	 *
2588
+	 * @since 1.0.0
2589
+	 * @param string $instance['list_sort'] Listing sort by type.
2590
+	 */
2591
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2592
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2593
+
2594
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
2595
+	?>
2596 2596
     <script type="text/javascript">
2597 2597
         jQuery(window).load(function () {
2598 2598
             jQuery('#geodir_widget_carousel').flexslider({
@@ -2633,73 +2633,73 @@  discard block
 block discarded – undo
2633 2633
         });
2634 2634
     </script>
2635 2635
     <?php
2636
-    $query_args = array(
2637
-        'posts_per_page' => $post_number,
2638
-        'is_geodir_loop' => true,
2639
-        'post_type' => $post_type,
2640
-        'order_by' => $list_sort
2641
-    );
2642
-    if ($show_featured_only) {
2643
-        $query_args['show_featured_only'] = 1;
2644
-    }
2645
-
2646
-    if ($category != 0 || $category != '') {
2647
-        $category_taxonomy = geodir_get_taxonomies($post_type);
2648
-        $tax_query = array(
2649
-            'taxonomy' => $category_taxonomy[0],
2650
-            'field' => 'id',
2651
-            'terms' => $category
2652
-        );
2653
-
2654
-        $query_args['tax_query'] = array($tax_query);
2655
-    }
2656
-
2657
-    // we want listings with featured image only
2658
-    $query_args['featured_image_only'] = 1;
2659
-
2660
-    if ($post_type == 'gd_event') {
2661
-        $query_args['gedir_event_listing_filter'] = 'upcoming';
2662
-    }// show only upcomming events
2663
-
2664
-    $widget_listings = geodir_get_widget_listings($query_args);
2665
-    if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2666
-        if ($title) {
2667
-            echo $before_title . $title . $after_title;
2668
-        }
2636
+	$query_args = array(
2637
+		'posts_per_page' => $post_number,
2638
+		'is_geodir_loop' => true,
2639
+		'post_type' => $post_type,
2640
+		'order_by' => $list_sort
2641
+	);
2642
+	if ($show_featured_only) {
2643
+		$query_args['show_featured_only'] = 1;
2644
+	}
2645
+
2646
+	if ($category != 0 || $category != '') {
2647
+		$category_taxonomy = geodir_get_taxonomies($post_type);
2648
+		$tax_query = array(
2649
+			'taxonomy' => $category_taxonomy[0],
2650
+			'field' => 'id',
2651
+			'terms' => $category
2652
+		);
2669 2653
 
2670
-        global $post;
2654
+		$query_args['tax_query'] = array($tax_query);
2655
+	}
2656
+
2657
+	// we want listings with featured image only
2658
+	$query_args['featured_image_only'] = 1;
2671 2659
 
2672
-        $current_post = $post;// keep current post info
2660
+	if ($post_type == 'gd_event') {
2661
+		$query_args['gedir_event_listing_filter'] = 'upcoming';
2662
+	}// show only upcomming events
2673 2663
 
2674
-        $widget_main_slides = '';
2675
-        $nav_slides = '';
2676
-        $widget_slides = 0;
2664
+	$widget_listings = geodir_get_widget_listings($query_args);
2665
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2666
+		if ($title) {
2667
+			echo $before_title . $title . $after_title;
2668
+		}
2677 2669
 
2678
-        foreach ($widget_listings as $widget_listing) {
2679
-            global $gd_widget_listing_type;
2680
-            $post = $widget_listing;
2681
-            $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2670
+		global $post;
2682 2671
 
2683
-            if (!empty($widget_image)) {
2684
-                if ($widget_image->height >= 200) {
2685
-                    $widget_spacer_height = 0;
2686
-                } else {
2687
-                    $widget_spacer_height = ((200 - $widget_image->height) / 2);
2688
-                }
2672
+		$current_post = $post;// keep current post info
2689 2673
 
2690
-                $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />';
2674
+		$widget_main_slides = '';
2675
+		$nav_slides = '';
2676
+		$widget_slides = 0;
2691 2677
 
2692
-                $title = '';
2693
-                if ($show_title) {
2694
-                    $title = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2695
-                }
2678
+		foreach ($widget_listings as $widget_listing) {
2679
+			global $gd_widget_listing_type;
2680
+			$post = $widget_listing;
2681
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2696 2682
 
2697
-                $widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>';
2698
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2699
-                $widget_slides++;
2700
-            }
2701
-        }
2702
-        ?>
2683
+			if (!empty($widget_image)) {
2684
+				if ($widget_image->height >= 200) {
2685
+					$widget_spacer_height = 0;
2686
+				} else {
2687
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
2688
+				}
2689
+
2690
+				$widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />';
2691
+
2692
+				$title = '';
2693
+				if ($show_title) {
2694
+					$title = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2695
+				}
2696
+
2697
+				$widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>';
2698
+				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2699
+				$widget_slides++;
2700
+			}
2701
+		}
2702
+		?>
2703 2703
         <div class="flex-container" style="min-height:200px;">
2704 2704
             <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
2705 2705
             <div id="geodir_widget_slider" class="geodir_flexslider">
@@ -2712,10 +2712,10 @@  discard block
 block discarded – undo
2712 2712
             <?php } ?>
2713 2713
         </div>
2714 2714
         <?php
2715
-        $GLOBALS['post'] = $current_post;
2716
-        setup_postdata($current_post);
2717
-    }
2718
-    echo $after_widget;
2715
+		$GLOBALS['post'] = $current_post;
2716
+		setup_postdata($current_post);
2717
+	}
2718
+	echo $after_widget;
2719 2719
 }
2720 2720
 
2721 2721
 
@@ -2730,68 +2730,68 @@  discard block
 block discarded – undo
2730 2730
  */
2731 2731
 function geodir_loginwidget_output($args = '', $instance = '')
2732 2732
 {
2733
-    //print_r($args);
2734
-    //print_r($instance);
2735
-    // prints the widget
2736
-    extract($args, EXTR_SKIP);
2733
+	//print_r($args);
2734
+	//print_r($instance);
2735
+	// prints the widget
2736
+	extract($args, EXTR_SKIP);
2737 2737
 
2738
-    /** This filter is documented in geodirectory_widgets.php */
2739
-    $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2738
+	/** This filter is documented in geodirectory_widgets.php */
2739
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2740 2740
 
2741
-    echo $before_widget;
2742
-    echo $before_title . $title . $after_title;
2741
+	echo $before_widget;
2742
+	echo $before_title . $title . $after_title;
2743 2743
 
2744
-    if (is_user_logged_in()) {
2745
-        global $current_user;
2744
+	if (is_user_logged_in()) {
2745
+		global $current_user;
2746 2746
 
2747
-        $login_url = geodir_login_url();
2748
-        $add_listurl = get_permalink(geodir_add_listing_page_id());
2749
-        $add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place'));
2750
-        $author_link = get_author_posts_url($current_user->data->ID);
2751
-        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2747
+		$login_url = geodir_login_url();
2748
+		$add_listurl = get_permalink(geodir_add_listing_page_id());
2749
+		$add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place'));
2750
+		$author_link = get_author_posts_url($current_user->data->ID);
2751
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2752 2752
 
2753
-        echo '<ul class="geodir-loginbox-list">';
2754
-        ob_start();
2755
-        ?>
2753
+		echo '<ul class="geodir-loginbox-list">';
2754
+		ob_start();
2755
+		?>
2756 2756
         <li><a class="signin"
2757 2757
                href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
2758 2758
         <?php
2759
-        $post_types = geodir_get_posttypes('object');
2760
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2761
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2759
+		$post_types = geodir_get_posttypes('object');
2760
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2761
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2762 2762
 
2763
-        if (!empty($show_add_listing_post_types_main_nav)) {
2764
-            $addlisting_links = '';
2765
-            foreach ($post_types as $key => $postobj) {
2763
+		if (!empty($show_add_listing_post_types_main_nav)) {
2764
+			$addlisting_links = '';
2765
+			foreach ($post_types as $key => $postobj) {
2766 2766
 
2767
-                if (in_array($key, $show_add_listing_post_types_main_nav)) {
2767
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
2768 2768
 
2769
-                    if ($add_link = geodir_get_addlisting_link($key)) {
2769
+					if ($add_link = geodir_get_addlisting_link($key)) {
2770 2770
 
2771
-                        $name = $postobj->labels->name;
2771
+						$name = $postobj->labels->name;
2772 2772
 
2773
-                        $selected = '';
2774
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2775
-                            $selected = 'selected="selected"';
2773
+						$selected = '';
2774
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2775
+							$selected = 'selected="selected"';
2776 2776
 
2777
-                        /**
2778
-                         * Filter add listing link.
2779
-                         *
2780
-                         * @since 1.0.0
2781
-                         * @param string $add_link Add listing link.
2782
-                         * @param string $key Add listing array key.
2783
-                         * @param int $current_user->ID Current user ID.
2784
-                         */
2785
-                        $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2777
+						/**
2778
+						 * Filter add listing link.
2779
+						 *
2780
+						 * @since 1.0.0
2781
+						 * @param string $add_link Add listing link.
2782
+						 * @param string $key Add listing array key.
2783
+						 * @param int $current_user->ID Current user ID.
2784
+						 */
2785
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2786 2786
 
2787
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2787
+						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2788 2788
 
2789
-                    }
2790
-                }
2789
+					}
2790
+				}
2791 2791
 
2792
-            }
2792
+			}
2793 2793
 
2794
-            if ($addlisting_links != '') { ?>
2794
+			if ($addlisting_links != '') { ?>
2795 2795
 
2796 2796
                 <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
2797 2797
                             option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
@@ -2800,42 +2800,42 @@  discard block
 block discarded – undo
2800 2800
                         <?php echo $addlisting_links; ?>
2801 2801
                     </select></li> <?php
2802 2802
 
2803
-            }
2803
+			}
2804
+
2805
+		}
2806
+		// My Favourites in Dashboard
2807
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2808
+		$user_favourite = geodir_user_favourite_listing_count();
2809
+
2810
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2811
+			$favourite_links = '';
2804 2812
 
2805
-        }
2806
-        // My Favourites in Dashboard
2807
-        $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2808
-        $user_favourite = geodir_user_favourite_listing_count();
2809
-
2810
-        if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2811
-            $favourite_links = '';
2812
-
2813
-            foreach ($post_types as $key => $postobj) {
2814
-                if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2815
-                    $name = $postobj->labels->name;
2816
-                    $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2817
-
2818
-                    $selected = '';
2819
-
2820
-                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2821
-                        $selected = 'selected="selected"';
2822
-                    }
2823
-                    /**
2824
-                     * Filter favorite listing link.
2825
-                     *
2826
-                     * @since 1.0.0
2827
-                     * @param string $post_type_link Favorite listing link.
2828
-                     * @param string $key Favorite listing array key.
2829
-                     * @param int $current_user->ID Current user ID.
2830
-                     */
2831
-                    $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2832
-
2833
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2834
-                }
2835
-            }
2836
-
2837
-            if ($favourite_links != '') {
2838
-                ?>
2813
+			foreach ($post_types as $key => $postobj) {
2814
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2815
+					$name = $postobj->labels->name;
2816
+					$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2817
+
2818
+					$selected = '';
2819
+
2820
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2821
+						$selected = 'selected="selected"';
2822
+					}
2823
+					/**
2824
+					 * Filter favorite listing link.
2825
+					 *
2826
+					 * @since 1.0.0
2827
+					 * @param string $post_type_link Favorite listing link.
2828
+					 * @param string $key Favorite listing array key.
2829
+					 * @param int $current_user->ID Current user ID.
2830
+					 */
2831
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2832
+
2833
+					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2834
+				}
2835
+			}
2836
+
2837
+			if ($favourite_links != '') {
2838
+				?>
2839 2839
                 <li>
2840 2840
                     <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
2841 2841
                             option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
@@ -2845,42 +2845,42 @@  discard block
 block discarded – undo
2845 2845
                     </select>
2846 2846
                 </li>
2847 2847
             <?php
2848
-            }
2849
-        }
2850
-
2848
+			}
2849
+		}
2851 2850
 
2852
-        $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2853
-        $user_listing = geodir_user_post_listing_count();
2854 2851
 
2855
-        if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2856
-            $listing_links = '';
2852
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2853
+		$user_listing = geodir_user_post_listing_count();
2857 2854
 
2858
-            foreach ($post_types as $key => $postobj) {
2859
-                if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2860
-                    $name = $postobj->labels->name;
2861
-                    $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2855
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2856
+			$listing_links = '';
2862 2857
 
2863
-                    $selected = '';
2864
-                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2865
-                        $selected = 'selected="selected"';
2866
-                    }
2858
+			foreach ($post_types as $key => $postobj) {
2859
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2860
+					$name = $postobj->labels->name;
2861
+					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2867 2862
 
2868
-                    /**
2869
-                     * Filter my listing link.
2870
-                     *
2871
-                     * @since 1.0.0
2872
-                     * @param string $listing_link My listing link.
2873
-                     * @param string $key My listing array key.
2874
-                     * @param int $current_user->ID Current user ID.
2875
-                     */
2876
-                    $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2863
+					$selected = '';
2864
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2865
+						$selected = 'selected="selected"';
2866
+					}
2877 2867
 
2878
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2879
-                }
2880
-            }
2868
+					/**
2869
+					 * Filter my listing link.
2870
+					 *
2871
+					 * @since 1.0.0
2872
+					 * @param string $listing_link My listing link.
2873
+					 * @param string $key My listing array key.
2874
+					 * @param int $current_user->ID Current user ID.
2875
+					 */
2876
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2877
+
2878
+					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2879
+				}
2880
+			}
2881 2881
 
2882
-            if ($listing_links != '') {
2883
-                ?>
2882
+			if ($listing_links != '') {
2883
+				?>
2884 2884
                 <li>
2885 2885
                     <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
2886 2886
                             option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
@@ -2890,27 +2890,27 @@  discard block
 block discarded – undo
2890 2890
                     </select>
2891 2891
                 </li>
2892 2892
             <?php
2893
-            }
2894
-        }
2893
+			}
2894
+		}
2895 2895
 
2896
-        $dashboard_link = ob_get_clean();
2897
-        /**
2898
-         * Filter dashboard links HTML.
2899
-         *
2900
-         * @since 1.0.0
2901
-         * @param string $dashboard_link Dashboard links HTML.
2902
-         */
2903
-        echo apply_filters('geodir_dashboard_links', $dashboard_link);
2904
-        echo '</ul>';
2905
-    } else {
2906
-        ?>
2896
+		$dashboard_link = ob_get_clean();
2897
+		/**
2898
+		 * Filter dashboard links HTML.
2899
+		 *
2900
+		 * @since 1.0.0
2901
+		 * @param string $dashboard_link Dashboard links HTML.
2902
+		 */
2903
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
2904
+		echo '</ul>';
2905
+	} else {
2906
+		?>
2907 2907
         <?php
2908
-        /**
2909
-         * Filter signup form action link.
2910
-         *
2911
-         * @since 1.0.0
2912
-         */
2913
-        ?>
2908
+		/**
2909
+		 * Filter signup form action link.
2910
+		 *
2911
+		 * @since 1.0.0
2912
+		 */
2913
+		?>
2914 2914
         <form name="loginform" class="loginform1"
2915 2915
               action="<?php echo geodir_login_url(); ?>"
2916 2916
               method="post">
@@ -2930,28 +2930,28 @@  discard block
 block discarded – undo
2930 2930
 
2931 2931
                 <p class="geodir-new-forgot-link">
2932 2932
                     <?php
2933
-                    /**
2934
-                     * Filter signup page register form link.
2935
-                     *
2936
-                     * @since 1.0.0
2937
-                     */
2938
-                    ?>
2933
+					/**
2934
+					 * Filter signup page register form link.
2935
+					 *
2936
+					 * @since 1.0.0
2937
+					 */
2938
+					?>
2939 2939
                     <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
2940 2940
                        class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
2941 2941
 
2942 2942
                     <?php
2943
-                    /**
2944
-                     * Filter signup page forgot password form link.
2945
-                     *
2946
-                     * @since 1.0.0
2947
-                     */
2948
-                    ?>
2943
+					/**
2944
+					 * Filter signup page forgot password form link.
2945
+					 *
2946
+					 * @since 1.0.0
2947
+					 */
2948
+					?>
2949 2949
                     <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
2950 2950
                        class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
2951 2951
         </form>
2952 2952
     <?php }
2953 2953
 
2954
-    echo $after_widget;
2954
+	echo $after_widget;
2955 2955
 }
2956 2956
 
2957 2957
 
@@ -2970,284 +2970,284 @@  discard block
 block discarded – undo
2970 2970
  * @param array|string $instance The settings for the particular instance of the widget.
2971 2971
  */
2972 2972
 function geodir_popular_postview_output($args = '', $instance = '') {
2973
-    global $gd_session;
2973
+	global $gd_session;
2974 2974
 	
2975
-    // prints the widget
2976
-    extract($args, EXTR_SKIP);
2977
-
2978
-    echo $before_widget;
2979
-
2980
-    /** This filter is documented in geodirectory_widgets.php */
2981
-    $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2982
-    /**
2983
-     * Filter the widget post type.
2984
-     *
2985
-     * @since 1.0.0
2986
-     * @param string $instance['post_type'] Post type of listing.
2987
-     */
2988
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2989
-    /**
2990
-     * Filter the widget's term.
2991
-     *
2992
-     * @since 1.0.0
2993
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2994
-     */
2995
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2996
-    /**
2997
-     * Filter the widget listings limit.
2998
-     *
2999
-     * @since 1.0.0
3000
-     * @param string $instance['post_number'] Number of listings to display.
3001
-     */
3002
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3003
-    /**
3004
-     * Filter widget's "layout" type.
3005
-     *
3006
-     * @since 1.0.0
3007
-     * @param string $instance['layout'] Widget layout type.
3008
-     */
3009
-    $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3010
-    /**
3011
-     * Filter widget's "add_location_filter" value.
3012
-     *
3013
-     * @since 1.0.0
3014
-     * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3015
-     */
3016
-    $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3017
-    /**
3018
-     * Filter widget's listing width.
3019
-     *
3020
-     * @since 1.0.0
3021
-     * @param string $instance['listing_width'] Listing width.
3022
-     */
3023
-    $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3024
-    /**
3025
-     * Filter widget's "list_sort" type.
3026
-     *
3027
-     * @since 1.0.0
3028
-     * @param string $instance['list_sort'] Listing sort by type.
3029
-     */
3030
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3031
-    $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3032
-
3033
-    // set post type to current viewing post type
3034
-    if ($use_viewing_post_type) {
3035
-        $current_post_type = geodir_get_current_posttype();
3036
-        if ($current_post_type != '' && $current_post_type != $post_type) {
3037
-            $post_type = $current_post_type;
3038
-            $category = array(); // old post type category will not work for current changed post type
3039
-        }
3040
-    }
3041
-    // replace widget title dynamically
3042
-    $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3043
-    $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3044
-
3045
-    $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3046
-    $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3047
-
3048
-    if (isset($instance['character_count'])) {
3049
-        /**
3050
-         * Filter the widget's excerpt character count.
3051
-         *
3052
-         * @since 1.0.0
3053
-         * @param int $instance['character_count'] Excerpt character count.
3054
-         */
3055
-        $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3056
-    } else {
3057
-        $character_count = '';
3058
-    }
3059
-
3060
-    if (empty($title) || $title == 'All') {
3061
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3062
-    }
3063
-
3064
-    $location_url = array();
3065
-    $city = get_query_var('gd_city');
3066
-    if (!empty($city)) {
3067
-        $country = get_query_var('gd_country');
3068
-        $region = get_query_var('gd_region');
3069
-
3070
-        $geodir_show_location_url = get_option('geodir_show_location_url');
3071
-
3072
-        if ($geodir_show_location_url == 'all') {
3073
-            if ($country != '') {
3074
-                $location_url[] = $country;
3075
-            }
3076
-
3077
-            if ($region != '') {
3078
-                $location_url[] = $region;
3079
-            }
3080
-        } else if ($geodir_show_location_url == 'country_city') {
3081
-            if ($country != '') {
3082
-                $location_url[] = $country;
3083
-            }
3084
-        } else if ($geodir_show_location_url == 'region_city') {
3085
-            if ($region != '') {
3086
-                $location_url[] = $region;
3087
-            }
3088
-        }
2975
+	// prints the widget
2976
+	extract($args, EXTR_SKIP);
2977
+
2978
+	echo $before_widget;
2979
+
2980
+	/** This filter is documented in geodirectory_widgets.php */
2981
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2982
+	/**
2983
+	 * Filter the widget post type.
2984
+	 *
2985
+	 * @since 1.0.0
2986
+	 * @param string $instance['post_type'] Post type of listing.
2987
+	 */
2988
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2989
+	/**
2990
+	 * Filter the widget's term.
2991
+	 *
2992
+	 * @since 1.0.0
2993
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2994
+	 */
2995
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2996
+	/**
2997
+	 * Filter the widget listings limit.
2998
+	 *
2999
+	 * @since 1.0.0
3000
+	 * @param string $instance['post_number'] Number of listings to display.
3001
+	 */
3002
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3003
+	/**
3004
+	 * Filter widget's "layout" type.
3005
+	 *
3006
+	 * @since 1.0.0
3007
+	 * @param string $instance['layout'] Widget layout type.
3008
+	 */
3009
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3010
+	/**
3011
+	 * Filter widget's "add_location_filter" value.
3012
+	 *
3013
+	 * @since 1.0.0
3014
+	 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3015
+	 */
3016
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3017
+	/**
3018
+	 * Filter widget's listing width.
3019
+	 *
3020
+	 * @since 1.0.0
3021
+	 * @param string $instance['listing_width'] Listing width.
3022
+	 */
3023
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3024
+	/**
3025
+	 * Filter widget's "list_sort" type.
3026
+	 *
3027
+	 * @since 1.0.0
3028
+	 * @param string $instance['list_sort'] Listing sort by type.
3029
+	 */
3030
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3031
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3032
+
3033
+	// set post type to current viewing post type
3034
+	if ($use_viewing_post_type) {
3035
+		$current_post_type = geodir_get_current_posttype();
3036
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3037
+			$post_type = $current_post_type;
3038
+			$category = array(); // old post type category will not work for current changed post type
3039
+		}
3040
+	}
3041
+	// replace widget title dynamically
3042
+	$posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3043
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3044
+
3045
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3046
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3047
+
3048
+	if (isset($instance['character_count'])) {
3049
+		/**
3050
+		 * Filter the widget's excerpt character count.
3051
+		 *
3052
+		 * @since 1.0.0
3053
+		 * @param int $instance['character_count'] Excerpt character count.
3054
+		 */
3055
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3056
+	} else {
3057
+		$character_count = '';
3058
+	}
3089 3059
 
3090
-        $location_url[] = $city;
3091
-    }
3060
+	if (empty($title) || $title == 'All') {
3061
+		$title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3062
+	}
3063
+
3064
+	$location_url = array();
3065
+	$city = get_query_var('gd_city');
3066
+	if (!empty($city)) {
3067
+		$country = get_query_var('gd_country');
3068
+		$region = get_query_var('gd_region');
3092 3069
 
3093
-    $location_url = implode('/', $location_url);
3094
-    $skip_location = false;
3095
-    if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3096
-        $skip_location = true;
3097
-        $gd_session->un_set('gd_multi_location');
3098
-    }
3070
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3071
+
3072
+		if ($geodir_show_location_url == 'all') {
3073
+			if ($country != '') {
3074
+				$location_url[] = $country;
3075
+			}
3099 3076
 
3100
-    if (get_option('permalink_structure')) {
3101
-        $viewall_url = get_post_type_archive_link($post_type);
3102
-    } else {
3103
-        $viewall_url = get_post_type_archive_link($post_type);
3104
-    }
3077
+			if ($region != '') {
3078
+				$location_url[] = $region;
3079
+			}
3080
+		} else if ($geodir_show_location_url == 'country_city') {
3081
+			if ($country != '') {
3082
+				$location_url[] = $country;
3083
+			}
3084
+		} else if ($geodir_show_location_url == 'region_city') {
3085
+			if ($region != '') {
3086
+				$location_url[] = $region;
3087
+			}
3088
+		}
3105 3089
 
3106
-    if (!empty($category) && $category[0] != '0') {
3107
-        global $geodir_add_location_url;
3090
+		$location_url[] = $city;
3091
+	}
3108 3092
 
3109
-        $geodir_add_location_url = '0';
3093
+	$location_url = implode('/', $location_url);
3094
+	$skip_location = false;
3095
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3096
+		$skip_location = true;
3097
+		$gd_session->un_set('gd_multi_location');
3098
+	}
3110 3099
 
3111
-        if ($add_location_filter != '0') {
3112
-            $geodir_add_location_url = '1';
3113
-        }
3100
+	if (get_option('permalink_structure')) {
3101
+		$viewall_url = get_post_type_archive_link($post_type);
3102
+	} else {
3103
+		$viewall_url = get_post_type_archive_link($post_type);
3104
+	}
3114 3105
 
3115
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3106
+	if (!empty($category) && $category[0] != '0') {
3107
+		global $geodir_add_location_url;
3116 3108
 
3117
-        $geodir_add_location_url = NULL;
3118
-    }
3119
-    if ($skip_location) {
3120
-        $gd_session->set('gd_multi_location', 1);
3121
-    }
3109
+		$geodir_add_location_url = '0';
3122 3110
 
3123
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3111
+		if ($add_location_filter != '0') {
3112
+			$geodir_add_location_url = '1';
3113
+		}
3124 3114
 
3125
-    $query_args = array(
3126
-        'posts_per_page' => $post_number,
3127
-        'is_geodir_loop' => true,
3128
-        'gd_location' => $add_location_filter ? true : false,
3129
-        'post_type' => $post_type,
3130
-        'order_by' => $list_sort
3131
-    );
3115
+		$viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3132 3116
 
3133
-    if ($character_count) {
3134
-        $query_args['excerpt_length'] = $character_count;
3135
-    }
3117
+		$geodir_add_location_url = NULL;
3118
+	}
3119
+	if ($skip_location) {
3120
+		$gd_session->set('gd_multi_location', 1);
3121
+	}
3136 3122
 
3137
-    if (!empty($instance['show_featured_only'])) {
3138
-        $query_args['show_featured_only'] = 1;
3139
-    }
3123
+	if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3140 3124
 
3141
-    if (!empty($instance['show_special_only'])) {
3142
-        $query_args['show_special_only'] = 1;
3143
-    }
3125
+	$query_args = array(
3126
+		'posts_per_page' => $post_number,
3127
+		'is_geodir_loop' => true,
3128
+		'gd_location' => $add_location_filter ? true : false,
3129
+		'post_type' => $post_type,
3130
+		'order_by' => $list_sort
3131
+	);
3144 3132
 
3145
-    if (!empty($instance['with_pics_only'])) {
3146
-        $query_args['with_pics_only'] = 0;
3147
-        $query_args['featured_image_only'] = 1;
3148
-    }
3133
+	if ($character_count) {
3134
+		$query_args['excerpt_length'] = $character_count;
3135
+	}
3149 3136
 
3150
-    if (!empty($instance['with_videos_only'])) {
3151
-        $query_args['with_videos_only'] = 1;
3152
-    }
3153
-    $with_no_results = !empty($instance['without_no_results']) ? false : true;
3137
+	if (!empty($instance['show_featured_only'])) {
3138
+		$query_args['show_featured_only'] = 1;
3139
+	}
3154 3140
 
3155
-    if (!empty($category) && $category[0] != '0') {
3156
-        $category_taxonomy = geodir_get_taxonomies($post_type);
3141
+	if (!empty($instance['show_special_only'])) {
3142
+		$query_args['show_special_only'] = 1;
3143
+	}
3157 3144
 
3158
-        ######### WPML #########
3159
-        if (function_exists('icl_object_id')) {
3160
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
3161
-        }
3162
-        ######### WPML #########
3145
+	if (!empty($instance['with_pics_only'])) {
3146
+		$query_args['with_pics_only'] = 0;
3147
+		$query_args['featured_image_only'] = 1;
3148
+	}
3163 3149
 
3164
-        $tax_query = array(
3165
-            'taxonomy' => $category_taxonomy[0],
3166
-            'field' => 'id',
3167
-            'terms' => $category
3168
-        );
3150
+	if (!empty($instance['with_videos_only'])) {
3151
+		$query_args['with_videos_only'] = 1;
3152
+	}
3153
+	$with_no_results = !empty($instance['without_no_results']) ? false : true;
3154
+
3155
+	if (!empty($category) && $category[0] != '0') {
3156
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3157
+
3158
+		######### WPML #########
3159
+		if (function_exists('icl_object_id')) {
3160
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3161
+		}
3162
+		######### WPML #########
3169 3163
 
3170
-        $query_args['tax_query'] = array($tax_query);
3171
-    }
3164
+		$tax_query = array(
3165
+			'taxonomy' => $category_taxonomy[0],
3166
+			'field' => 'id',
3167
+			'terms' => $category
3168
+		);
3172 3169
 
3173
-    global $gridview_columns_widget, $geodir_is_widget_listing;
3170
+		$query_args['tax_query'] = array($tax_query);
3171
+	}
3172
+
3173
+	global $gridview_columns_widget, $geodir_is_widget_listing;
3174 3174
 
3175
-    $widget_listings = geodir_get_widget_listings($query_args);
3175
+	$widget_listings = geodir_get_widget_listings($query_args);
3176 3176
 
3177
-    if (!empty($widget_listings) || $with_no_results) {
3178
-        ?>
3177
+	if (!empty($widget_listings) || $with_no_results) {
3178
+		?>
3179 3179
         <div class="geodir_locations geodir_location_listing">
3180 3180
 
3181 3181
             <?php
3182
-            /**
3183
-             * Called before the div containing the title and view all link in popular post view widget.
3184
-             *
3185
-             * @since 1.0.0
3186
-             */
3187
-            do_action('geodir_before_view_all_link_in_widget'); ?>
3182
+			/**
3183
+			 * Called before the div containing the title and view all link in popular post view widget.
3184
+			 *
3185
+			 * @since 1.0.0
3186
+			 */
3187
+			do_action('geodir_before_view_all_link_in_widget'); ?>
3188 3188
             <div class="geodir_list_heading clearfix">
3189 3189
                 <?php echo $before_title . $title . $after_title; ?>
3190 3190
                 <a href="<?php echo $viewall_url; ?>"
3191 3191
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3192 3192
             </div>
3193 3193
             <?php
3194
-            /**
3195
-             * Called after the div containing the title and view all link in popular post view widget.
3196
-             *
3197
-             * @since 1.0.0
3198
-             */
3199
-            do_action('geodir_after_view_all_link_in_widget'); ?>
3194
+			/**
3195
+			 * Called after the div containing the title and view all link in popular post view widget.
3196
+			 *
3197
+			 * @since 1.0.0
3198
+			 */
3199
+			do_action('geodir_after_view_all_link_in_widget'); ?>
3200 3200
             <?php
3201
-            if (strstr($layout, 'gridview')) {
3202
-                $listing_view_exp = explode('_', $layout);
3203
-                $gridview_columns_widget = $layout;
3204
-                $layout = $listing_view_exp[0];
3205
-            } else {
3206
-                $gridview_columns_widget = '';
3207
-            }
3208
-
3209
-            /**
3210
-             * Filter the widget listing listview template path.
3211
-             *
3212
-             * @since 1.0.0
3213
-             */
3214
-            $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3215
-            if (!isset($character_count)) {
3216
-                /**
3217
-                 * Filter the widget's excerpt character count.
3218
-                 *
3219
-                 * @since 1.0.0
3220
-                 * @param int $instance['character_count'] Excerpt character count.
3221
-                 */
3222
-                $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3223
-            }
3224
-
3225
-            global $post, $map_jason, $map_canvas_arr;
3226
-
3227
-            $current_post = $post;
3228
-            $current_map_jason = $map_jason;
3229
-            $current_map_canvas_arr = $map_canvas_arr;
3230
-            $geodir_is_widget_listing = true;
3231
-
3232
-            /**
3233
-             * Includes related listing listview template.
3234
-             *
3235
-             * @since 1.0.0
3236
-             */
3237
-            include($template);
3238
-
3239
-            $geodir_is_widget_listing = false;
3240
-
3241
-            $GLOBALS['post'] = $current_post;
3242
-            if (!empty($current_post))
3243
-                setup_postdata($current_post);
3244
-            $map_jason = $current_map_jason;
3245
-            $map_canvas_arr = $current_map_canvas_arr;
3246
-            ?>
3201
+			if (strstr($layout, 'gridview')) {
3202
+				$listing_view_exp = explode('_', $layout);
3203
+				$gridview_columns_widget = $layout;
3204
+				$layout = $listing_view_exp[0];
3205
+			} else {
3206
+				$gridview_columns_widget = '';
3207
+			}
3208
+
3209
+			/**
3210
+			 * Filter the widget listing listview template path.
3211
+			 *
3212
+			 * @since 1.0.0
3213
+			 */
3214
+			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3215
+			if (!isset($character_count)) {
3216
+				/**
3217
+				 * Filter the widget's excerpt character count.
3218
+				 *
3219
+				 * @since 1.0.0
3220
+				 * @param int $instance['character_count'] Excerpt character count.
3221
+				 */
3222
+				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3223
+			}
3224
+
3225
+			global $post, $map_jason, $map_canvas_arr;
3226
+
3227
+			$current_post = $post;
3228
+			$current_map_jason = $map_jason;
3229
+			$current_map_canvas_arr = $map_canvas_arr;
3230
+			$geodir_is_widget_listing = true;
3231
+
3232
+			/**
3233
+			 * Includes related listing listview template.
3234
+			 *
3235
+			 * @since 1.0.0
3236
+			 */
3237
+			include($template);
3238
+
3239
+			$geodir_is_widget_listing = false;
3240
+
3241
+			$GLOBALS['post'] = $current_post;
3242
+			if (!empty($current_post))
3243
+				setup_postdata($current_post);
3244
+			$map_jason = $current_map_jason;
3245
+			$map_canvas_arr = $current_map_canvas_arr;
3246
+			?>
3247 3247
         </div>
3248 3248
     <?php
3249
-    }
3250
-    echo $after_widget;
3249
+	}
3250
+	echo $after_widget;
3251 3251
 
3252 3252
 }
3253 3253
 
@@ -3270,26 +3270,26 @@  discard block
 block discarded – undo
3270 3270
  */
3271 3271
 function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type)
3272 3272
 {
3273
-    global $wpdb, $plugin_prefix;
3273
+	global $wpdb, $plugin_prefix;
3274 3274
 
3275
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3275
+	$detail_table = $plugin_prefix . $post_type . '_detail';
3276 3276
 
3277
-    $sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
3277
+	$sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
3278 3278
 
3279
-    /**
3280
-     * Filter count review sql query.
3281
-     *
3282
-     * @since 1.5.1
3283
-     * @param string $sql Database sql query..
3284
-     * @param int $term_id The term ID.
3285
-     * @param int $taxonomy The taxonomy Id.
3286
-     * @param string $post_type The post type.
3287
-     */
3288
-    $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3279
+	/**
3280
+	 * Filter count review sql query.
3281
+	 *
3282
+	 * @since 1.5.1
3283
+	 * @param string $sql Database sql query..
3284
+	 * @param int $term_id The term ID.
3285
+	 * @param int $taxonomy The taxonomy Id.
3286
+	 * @param string $post_type The post type.
3287
+	 */
3288
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3289 3289
 
3290
-    $count = $wpdb->get_var($sql);
3290
+	$count = $wpdb->get_var($sql);
3291 3291
 
3292
-    return $count;
3292
+	return $count;
3293 3293
 }
3294 3294
 
3295 3295
 /**
@@ -3302,53 +3302,53 @@  discard block
 block discarded – undo
3302 3302
  */
3303 3303
 function geodir_count_reviews_by_terms($force_update = false)
3304 3304
 {
3305
-    /**
3306
-     * Filter review count option data.
3307
-     *
3308
-     * @since 1.0.0
3309
-     * @param bool $force_update Force update option value?. Default.false.
3310
-     */
3311
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update);
3312
-    if (!empty($option_data)) {
3313
-        return $option_data;
3314
-    }
3305
+	/**
3306
+	 * Filter review count option data.
3307
+	 *
3308
+	 * @since 1.0.0
3309
+	 * @param bool $force_update Force update option value?. Default.false.
3310
+	 */
3311
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update);
3312
+	if (!empty($option_data)) {
3313
+		return $option_data;
3314
+	}
3315 3315
 
3316
-    $option_data = get_option('geodir_global_review_count');
3316
+	$option_data = get_option('geodir_global_review_count');
3317 3317
 
3318
-    if (!$option_data OR $force_update) {
3319
-        $post_types = geodir_get_posttypes();
3320
-        $term_array = array();
3321
-        foreach ($post_types as $post_type) {
3318
+	if (!$option_data OR $force_update) {
3319
+		$post_types = geodir_get_posttypes();
3320
+		$term_array = array();
3321
+		foreach ($post_types as $post_type) {
3322 3322
 
3323
-            $taxonomy = geodir_get_taxonomies($post_type);
3324
-            $taxonomy = $taxonomy[0];
3323
+			$taxonomy = geodir_get_taxonomies($post_type);
3324
+			$taxonomy = $taxonomy[0];
3325 3325
 
3326
-            $args = array(
3327
-                'hide_empty' => false
3328
-            );
3326
+			$args = array(
3327
+				'hide_empty' => false
3328
+			);
3329 3329
 
3330
-            $terms = get_terms($taxonomy, $args);
3330
+			$terms = get_terms($taxonomy, $args);
3331 3331
 
3332
-            foreach ($terms as $term) {
3333
-                $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3334
-                $children = get_term_children($term->term_id, $taxonomy);
3335
-                /*if ( is_array( $children ) ) {
3332
+			foreach ($terms as $term) {
3333
+				$count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3334
+				$children = get_term_children($term->term_id, $taxonomy);
3335
+				/*if ( is_array( $children ) ) {
3336 3336
 					foreach ( $children as $child_id ) {
3337 3337
 						$child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
3338 3338
 						$count = $count + $child_count;
3339 3339
 					}
3340 3340
 				}*/
3341
-                $term_array[$term->term_id] = $count;
3342
-            }
3343
-        }
3341
+				$term_array[$term->term_id] = $count;
3342
+			}
3343
+		}
3344 3344
 
3345
-        update_option('geodir_global_review_count', $term_array);
3346
-        //clear cache
3347
-        wp_cache_delete('geodir_global_review_count');
3348
-        return $term_array;
3349
-    } else {
3350
-        return $option_data;
3351
-    }
3345
+		update_option('geodir_global_review_count', $term_array);
3346
+		//clear cache
3347
+		wp_cache_delete('geodir_global_review_count');
3348
+		return $term_array;
3349
+	} else {
3350
+		return $option_data;
3351
+	}
3352 3352
 }
3353 3353
 
3354 3354
 /**
@@ -3360,15 +3360,15 @@  discard block
 block discarded – undo
3360 3360
  */
3361 3361
 function geodir_term_review_count_force_update($new_status, $old_status='', $post='')
3362 3362
 {
3363
-    if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
3364
-
3365
-    if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
3366
-        return;
3367
-    }
3368
-    if($new_status!=$old_status) {
3369
-        geodir_count_reviews_by_terms(true);
3370
-    }
3371
-    return true;
3363
+	if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
3364
+
3365
+	if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
3366
+		return;
3367
+	}
3368
+	if($new_status!=$old_status) {
3369
+		geodir_count_reviews_by_terms(true);
3370
+	}
3371
+	return true;
3372 3372
 }
3373 3373
 
3374 3374
 
@@ -3387,15 +3387,15 @@  discard block
 block discarded – undo
3387 3387
 function geodir_count_posts_by_term($data, $term)
3388 3388
 {
3389 3389
 
3390
-    if ($data) {
3391
-        if (isset($data[$term->term_id])) {
3392
-            return $data[$term->term_id];
3393
-        } else {
3394
-            return 0;
3395
-        }
3396
-    } else {
3397
-        return $term->count;
3398
-    }
3390
+	if ($data) {
3391
+		if (isset($data[$term->term_id])) {
3392
+			return $data[$term->term_id];
3393
+		} else {
3394
+			return 0;
3395
+		}
3396
+	} else {
3397
+		return $term->count;
3398
+	}
3399 3399
 }
3400 3400
 
3401 3401
 /**
@@ -3408,8 +3408,8 @@  discard block
 block discarded – undo
3408 3408
  */
3409 3409
 function geodir_sort_terms_by_count($terms)
3410 3410
 {
3411
-    usort($terms, "geodir_sort_by_count_obj");
3412
-    return $terms;
3411
+	usort($terms, "geodir_sort_by_count_obj");
3412
+	return $terms;
3413 3413
 }
3414 3414
 
3415 3415
 /**
@@ -3422,8 +3422,8 @@  discard block
 block discarded – undo
3422 3422
  */
3423 3423
 function geodir_sort_terms_by_review_count($terms)
3424 3424
 {
3425
-    usort($terms, "geodir_sort_by_review_count_obj");
3426
-    return $terms;
3425
+	usort($terms, "geodir_sort_by_review_count_obj");
3426
+	return $terms;
3427 3427
 }
3428 3428
 
3429 3429
 /**
@@ -3437,12 +3437,12 @@  discard block
 block discarded – undo
3437 3437
  */
3438 3438
 function geodir_sort_terms($terms, $sort = 'count')
3439 3439
 {
3440
-    if ($sort == 'count') {
3441
-        return geodir_sort_terms_by_count($terms);
3442
-    }
3443
-    if ($sort == 'review_count') {
3444
-        return geodir_sort_terms_by_review_count($terms);
3445
-    }
3440
+	if ($sort == 'count') {
3441
+		return geodir_sort_terms_by_count($terms);
3442
+	}
3443
+	if ($sort == 'review_count') {
3444
+		return geodir_sort_terms_by_review_count($terms);
3445
+	}
3446 3446
 }
3447 3447
 
3448 3448
 /*-----------------------------------------------------------------------------------*/
@@ -3459,7 +3459,7 @@  discard block
 block discarded – undo
3459 3459
  */
3460 3460
 function geodir_sort_by_count($a, $b)
3461 3461
 {
3462
-    return $a['count'] < $b['count'];
3462
+	return $a['count'] < $b['count'];
3463 3463
 }
3464 3464
 
3465 3465
 /**
@@ -3473,7 +3473,7 @@  discard block
 block discarded – undo
3473 3473
  */
3474 3474
 function geodir_sort_by_count_obj($a, $b)
3475 3475
 {
3476
-    return $a->count < $b->count;
3476
+	return $a->count < $b->count;
3477 3477
 }
3478 3478
 
3479 3479
 /**
@@ -3487,7 +3487,7 @@  discard block
 block discarded – undo
3487 3487
  */
3488 3488
 function geodir_sort_by_review_count_obj($a, $b)
3489 3489
 {
3490
-    return $a->review_count < $b->review_count;
3490
+	return $a->review_count < $b->review_count;
3491 3491
 }
3492 3492
 
3493 3493
 /**
@@ -3497,43 +3497,43 @@  discard block
 block discarded – undo
3497 3497
  * @package GeoDirectory
3498 3498
  */
3499 3499
 function geodir_load_textdomain() {
3500
-    /**
3501
-     * Filter the plugin locale.
3502
-     *
3503
-     * @since 1.4.2
3504
-     * @package GeoDirectory
3505
-     */
3506
-    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3507
-
3508
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3509
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3500
+	/**
3501
+	 * Filter the plugin locale.
3502
+	 *
3503
+	 * @since 1.4.2
3504
+	 * @package GeoDirectory
3505
+	 */
3506
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3507
+
3508
+	load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3509
+	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3510
+
3511
+	/**
3512
+	 * Define language constants.
3513
+	 *
3514
+	 * @since 1.0.0
3515
+	 */
3516
+	require_once(geodir_plugin_path() . '/language.php');
3517
+
3518
+	$language_file = geodir_plugin_path() . '/db-language.php';
3519
+
3520
+	// Load language string file if not created yet
3521
+	if (!file_exists($language_file)) {
3522
+		geodirectory_load_db_language();
3523
+	}
3510 3524
 
3511
-    /**
3512
-     * Define language constants.
3513
-     *
3514
-     * @since 1.0.0
3515
-     */
3516
-    require_once(geodir_plugin_path() . '/language.php');
3517
-
3518
-    $language_file = geodir_plugin_path() . '/db-language.php';
3519
-
3520
-    // Load language string file if not created yet
3521
-    if (!file_exists($language_file)) {
3522
-        geodirectory_load_db_language();
3523
-    }
3524
-
3525
-    if (file_exists($language_file)) {
3526
-        /**
3527
-         * Language strings from database.
3528
-         *
3529
-         * @since 1.4.2
3530
-         */
3531
-        try {
3532
-            require_once($language_file);
3533
-        } catch(Exception $e) {
3534
-            error_log('Language Error: ' . $e->getMessage());
3535
-        }
3536
-    }
3525
+	if (file_exists($language_file)) {
3526
+		/**
3527
+		 * Language strings from database.
3528
+		 *
3529
+		 * @since 1.4.2
3530
+		 */
3531
+		try {
3532
+			require_once($language_file);
3533
+		} catch(Exception $e) {
3534
+			error_log('Language Error: ' . $e->getMessage());
3535
+		}
3536
+	}
3537 3537
 }
3538 3538
 
3539 3539
 /**
@@ -3547,66 +3547,66 @@  discard block
 block discarded – undo
3547 3547
  * @return bool True if file created otherwise false
3548 3548
  */
3549 3549
 function geodirectory_load_db_language() {
3550
-    global $wp_filesystem;
3551
-    if( empty( $wp_filesystem ) ) {
3552
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3553
-        WP_Filesystem();
3554
-        global $wp_filesystem;
3555
-    }
3556
-
3557
-    $language_file = geodir_plugin_path() . '/db-language.php';
3558
-
3559
-    if(is_file($language_file) && !is_writable($language_file))
3560
-        return false; // Not possible to create.
3561
-
3562
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3563
-        return false; // Not possible to create.
3564
-
3565
-    $contents_strings = array();
3550
+	global $wp_filesystem;
3551
+	if( empty( $wp_filesystem ) ) {
3552
+		require_once( ABSPATH .'/wp-admin/includes/file.php' );
3553
+		WP_Filesystem();
3554
+		global $wp_filesystem;
3555
+	}
3566 3556
 
3567
-    /**
3568
-     * Filter the language string from database to translate via po editor
3569
-     *
3570
-     * @since 1.4.2
3571
-     *
3572
-     * @param array $contents_strings Array of strings.
3573
-     */
3574
-    $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3575
-
3576
-    $contents_strings = array_unique($contents_strings);
3577
-
3578
-    $contents_head = array();
3579
-    $contents_head[] = "<?php";
3580
-    $contents_head[] = "/**";
3581
-    $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3582
-    $contents_head[] = " *";
3583
-    $contents_head[] = " * @package GeoDirectory";
3584
-    $contents_head[] = " * @since 1.4.2";
3585
-    $contents_head[] = " */";
3586
-    $contents_head[] = "";
3587
-    $contents_head[] = "// Language keys";
3588
-
3589
-    $contents_foot = array();
3590
-    $contents_foot[] = "";
3591
-    $contents_foot[] = "";
3592
-
3593
-    $contents = implode(PHP_EOL, $contents_head);
3594
-
3595
-    if (!empty($contents_strings)) {
3596
-        foreach ( $contents_strings as $string ) {
3597
-            if (is_scalar($string) && $string != '') {
3598
-                $string = str_replace("'", "\'", $string);
3599
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3600
-            }
3601
-        }
3602
-    }
3557
+	$language_file = geodir_plugin_path() . '/db-language.php';
3558
+
3559
+	if(is_file($language_file) && !is_writable($language_file))
3560
+		return false; // Not possible to create.
3561
+
3562
+	if(!is_file($language_file) && !is_writable(dirname($language_file)))
3563
+		return false; // Not possible to create.
3564
+
3565
+	$contents_strings = array();
3566
+
3567
+	/**
3568
+	 * Filter the language string from database to translate via po editor
3569
+	 *
3570
+	 * @since 1.4.2
3571
+	 *
3572
+	 * @param array $contents_strings Array of strings.
3573
+	 */
3574
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3575
+
3576
+	$contents_strings = array_unique($contents_strings);
3577
+
3578
+	$contents_head = array();
3579
+	$contents_head[] = "<?php";
3580
+	$contents_head[] = "/**";
3581
+	$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3582
+	$contents_head[] = " *";
3583
+	$contents_head[] = " * @package GeoDirectory";
3584
+	$contents_head[] = " * @since 1.4.2";
3585
+	$contents_head[] = " */";
3586
+	$contents_head[] = "";
3587
+	$contents_head[] = "// Language keys";
3588
+
3589
+	$contents_foot = array();
3590
+	$contents_foot[] = "";
3591
+	$contents_foot[] = "";
3592
+
3593
+	$contents = implode(PHP_EOL, $contents_head);
3594
+
3595
+	if (!empty($contents_strings)) {
3596
+		foreach ( $contents_strings as $string ) {
3597
+			if (is_scalar($string) && $string != '') {
3598
+				$string = str_replace("'", "\'", $string);
3599
+				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3600
+			}
3601
+		}
3602
+	}
3603 3603
 
3604
-    $contents .= implode(PHP_EOL, $contents_foot);
3604
+	$contents .= implode(PHP_EOL, $contents_foot);
3605 3605
 
3606
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3607
-        return false; // Failure; could not write file.
3606
+	if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3607
+		return false; // Failure; could not write file.
3608 3608
 
3609
-    return true;
3609
+	return true;
3610 3610
 }
3611 3611
 
3612 3612
 /**
@@ -3622,31 +3622,31 @@  discard block
 block discarded – undo
3622 3622
  * @return array Translation texts.
3623 3623
  */
3624 3624
 function geodir_load_custom_field_translation($translation_texts = array()) {
3625
-    global $wpdb;
3625
+	global $wpdb;
3626 3626
 
3627
-    // Custom fields table
3628
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3629
-    $rows = $wpdb->get_results($sql);
3627
+	// Custom fields table
3628
+	$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3629
+	$rows = $wpdb->get_results($sql);
3630 3630
 
3631
-    if (!empty($rows)) {
3632
-        foreach($rows as $row) {
3633
-            if (!empty($row->admin_title))
3634
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3631
+	if (!empty($rows)) {
3632
+		foreach($rows as $row) {
3633
+			if (!empty($row->admin_title))
3634
+				$translation_texts[] = stripslashes_deep($row->admin_title);
3635 3635
 			
3636
-            if (!empty($row->admin_desc))
3637
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3636
+			if (!empty($row->admin_desc))
3637
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
3638 3638
 
3639
-            if (!empty($row->site_title))
3640
-                $translation_texts[] = stripslashes_deep($row->site_title);
3639
+			if (!empty($row->site_title))
3640
+				$translation_texts[] = stripslashes_deep($row->site_title);
3641 3641
 
3642
-            if (!empty($row->clabels))
3643
-                $translation_texts[] = stripslashes_deep($row->clabels);
3642
+			if (!empty($row->clabels))
3643
+				$translation_texts[] = stripslashes_deep($row->clabels);
3644 3644
 
3645
-            if (!empty($row->required_msg))
3646
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3645
+			if (!empty($row->required_msg))
3646
+				$translation_texts[] = stripslashes_deep($row->required_msg);
3647 3647
 			
3648 3648
 			if (!empty($row->default_value))
3649
-                $translation_texts[] = stripslashes_deep($row->default_value);
3649
+				$translation_texts[] = stripslashes_deep($row->default_value);
3650 3650
 			
3651 3651
 			if (!empty($row->option_values)) {
3652 3652
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3659,25 +3659,25 @@  discard block
 block discarded – undo
3659 3659
 					}
3660 3660
 				}
3661 3661
 			}
3662
-        }
3663
-    }
3662
+		}
3663
+	}
3664 3664
 	
3665
-    // Custom sorting fields table
3666
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3667
-    $rows = $wpdb->get_results($sql);
3665
+	// Custom sorting fields table
3666
+	$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3667
+	$rows = $wpdb->get_results($sql);
3668 3668
 
3669
-    if (!empty($rows)) {
3670
-        foreach($rows as $row) {
3671
-            if (!empty($row->site_title))
3672
-                $translation_texts[] = stripslashes_deep($row->site_title);
3669
+	if (!empty($rows)) {
3670
+		foreach($rows as $row) {
3671
+			if (!empty($row->site_title))
3672
+				$translation_texts[] = stripslashes_deep($row->site_title);
3673 3673
 
3674
-            if (!empty($row->asc_title))
3675
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3674
+			if (!empty($row->asc_title))
3675
+				$translation_texts[] = stripslashes_deep($row->asc_title);
3676 3676
 
3677
-            if (!empty($row->desc_title))
3678
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3679
-        }
3680
-    }
3677
+			if (!empty($row->desc_title))
3678
+				$translation_texts[] = stripslashes_deep($row->desc_title);
3679
+		}
3680
+	}
3681 3681
 	
3682 3682
 	// Advance search filter fields table
3683 3683
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
@@ -3698,9 +3698,9 @@  discard block
 block discarded – undo
3698 3698
 		}
3699 3699
 	}
3700 3700
 
3701
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3701
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3702 3702
 
3703
-    return $translation_texts;
3703
+	return $translation_texts;
3704 3704
 }
3705 3705
 
3706 3706
 /**
@@ -3712,71 +3712,71 @@  discard block
 block discarded – undo
3712 3712
  * @return array Array of mime types.
3713 3713
  */
3714 3714
 function geodir_allowed_mime_types() {
3715
-    /**
3716
-     * Filter the list of mime types and file extensions allowed for file upload.
3717
-     *
3718
-     * @since 1.4.7
3719
-     * @package GeoDirectory
3720
-     *
3721
-     * @param array $geodir_allowed_mime_types and file extensions.
3722
-     */
3723
-    return apply_filters( 'geodir_allowed_mime_types', array(
3724
-            'Image' => array( // Image formats.
3725
-                'jpg' => 'image/jpeg',
3726
-                'jpe' => 'image/jpeg',
3727
-                'jpeg' => 'image/jpeg',
3728
-                'gif' => 'image/gif',
3729
-                'png' => 'image/png',
3730
-                'bmp' => 'image/bmp',
3731
-                'ico' => 'image/x-icon',
3732
-            ),
3733
-            'Video' => array( // Video formats.
3734
-                'asf' => 'video/x-ms-asf',
3735
-                'avi' => 'video/avi',
3736
-                'flv' => 'video/x-flv',
3737
-                'mkv' => 'video/x-matroska',
3738
-                'mp4' => 'video/mp4',
3739
-                'mpeg' => 'video/mpeg',
3740
-                'mpg' => 'video/mpeg',
3741
-                'wmv' => 'video/x-ms-wmv',
3742
-                '3gp' => 'video/3gpp',
3743
-            ),
3744
-            'Audio' => array( // Audio formats.
3745
-                'ogg' => 'audio/ogg',
3746
-                'mp3' => 'audio/mpeg',
3747
-                'wav' => 'audio/wav',
3748
-                'wma' => 'audio/x-ms-wma',
3749
-            ),
3750
-            'Text' => array( // Text formats.
3751
-                'css' => 'text/css',
3752
-                'csv' => 'text/csv',
3753
-                'htm' => 'text/html',
3754
-                'html' => 'text/html',
3755
-                'txt' => 'text/plain',
3756
-                'rtx' => 'text/richtext',
3757
-                'vtt' => 'text/vtt',
3758
-            ),
3759
-            'Application' => array( // Application formats.
3760
-                'doc' => 'application/msword',
3761
-                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3762
-                'exe' => 'application/x-msdownload',
3763
-                'js' => 'application/javascript',
3764
-                'odt' => 'application/vnd.oasis.opendocument.text',
3765
-                'pdf' => 'application/pdf',
3766
-                'pot' => 'application/vnd.ms-powerpoint',
3767
-                'ppt' => 'application/vnd.ms-powerpoint',
3768
-                'pptx' => 'application/vnd.ms-powerpoint',
3769
-                'psd' => 'application/octet-stream',
3770
-                'rar' => 'application/rar',
3771
-                'rtf' => 'application/rtf',
3772
-                'swf' => 'application/x-shockwave-flash',
3773
-                'tar' => 'application/x-tar',
3774
-                'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3775
-                'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3776
-                'zip' => 'application/zip',
3777
-            )
3778
-        )
3779
-    );
3715
+	/**
3716
+	 * Filter the list of mime types and file extensions allowed for file upload.
3717
+	 *
3718
+	 * @since 1.4.7
3719
+	 * @package GeoDirectory
3720
+	 *
3721
+	 * @param array $geodir_allowed_mime_types and file extensions.
3722
+	 */
3723
+	return apply_filters( 'geodir_allowed_mime_types', array(
3724
+			'Image' => array( // Image formats.
3725
+				'jpg' => 'image/jpeg',
3726
+				'jpe' => 'image/jpeg',
3727
+				'jpeg' => 'image/jpeg',
3728
+				'gif' => 'image/gif',
3729
+				'png' => 'image/png',
3730
+				'bmp' => 'image/bmp',
3731
+				'ico' => 'image/x-icon',
3732
+			),
3733
+			'Video' => array( // Video formats.
3734
+				'asf' => 'video/x-ms-asf',
3735
+				'avi' => 'video/avi',
3736
+				'flv' => 'video/x-flv',
3737
+				'mkv' => 'video/x-matroska',
3738
+				'mp4' => 'video/mp4',
3739
+				'mpeg' => 'video/mpeg',
3740
+				'mpg' => 'video/mpeg',
3741
+				'wmv' => 'video/x-ms-wmv',
3742
+				'3gp' => 'video/3gpp',
3743
+			),
3744
+			'Audio' => array( // Audio formats.
3745
+				'ogg' => 'audio/ogg',
3746
+				'mp3' => 'audio/mpeg',
3747
+				'wav' => 'audio/wav',
3748
+				'wma' => 'audio/x-ms-wma',
3749
+			),
3750
+			'Text' => array( // Text formats.
3751
+				'css' => 'text/css',
3752
+				'csv' => 'text/csv',
3753
+				'htm' => 'text/html',
3754
+				'html' => 'text/html',
3755
+				'txt' => 'text/plain',
3756
+				'rtx' => 'text/richtext',
3757
+				'vtt' => 'text/vtt',
3758
+			),
3759
+			'Application' => array( // Application formats.
3760
+				'doc' => 'application/msword',
3761
+				'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3762
+				'exe' => 'application/x-msdownload',
3763
+				'js' => 'application/javascript',
3764
+				'odt' => 'application/vnd.oasis.opendocument.text',
3765
+				'pdf' => 'application/pdf',
3766
+				'pot' => 'application/vnd.ms-powerpoint',
3767
+				'ppt' => 'application/vnd.ms-powerpoint',
3768
+				'pptx' => 'application/vnd.ms-powerpoint',
3769
+				'psd' => 'application/octet-stream',
3770
+				'rar' => 'application/rar',
3771
+				'rtf' => 'application/rtf',
3772
+				'swf' => 'application/x-shockwave-flash',
3773
+				'tar' => 'application/x-tar',
3774
+				'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3775
+				'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3776
+				'zip' => 'application/zip',
3777
+			)
3778
+		)
3779
+	);
3780 3780
 }
3781 3781
 
3782 3782
 /**
@@ -3788,21 +3788,21 @@  discard block
 block discarded – undo
3788 3788
  * @return string User display name.
3789 3789
  */
3790 3790
 function geodir_get_client_name($user_id) {
3791
-    $client_name = '';
3791
+	$client_name = '';
3792 3792
 
3793
-    $user_data = get_userdata($user_id);
3793
+	$user_data = get_userdata($user_id);
3794 3794
 
3795
-    if (!empty($user_data)) {
3796
-        if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3797
-            $client_name = trim($user_data->display_name);
3798
-        } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3799
-            $client_name = trim($user_data->user_nicename);
3800
-        } else {
3801
-            $client_name = trim($user_data->user_login);
3802
-        }
3803
-    }
3795
+	if (!empty($user_data)) {
3796
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3797
+			$client_name = trim($user_data->display_name);
3798
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3799
+			$client_name = trim($user_data->user_nicename);
3800
+		} else {
3801
+			$client_name = trim($user_data->user_login);
3802
+		}
3803
+	}
3804 3804
 
3805
-    return $client_name;
3805
+	return $client_name;
3806 3806
 }
3807 3807
 
3808 3808
 
@@ -3817,125 +3817,125 @@  discard block
 block discarded – undo
3817 3817
  */
3818 3818
 function geodir_wpseo_replacements($vars){
3819 3819
 
3820
-    global $wp;
3821
-    $title = '';
3822
-    // location variables
3823
-    $gd_post_type = geodir_get_current_posttype();
3824
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3825
-    /**
3826
-     * Filter the title variables location variables array
3827
-     *
3828
-     * @since 1.5.5
3829
-     * @package GeoDirectory
3830
-     * @param array $location_array The array of location variables.
3831
-     * @param array $vars The page title variables.
3832
-     */
3833
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
3834
-    $location_titles = array();
3835
-    if(get_query_var( 'gd_country_full' )){
3836
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
3837
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
3838
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
3839
-    }
3840
-    $location_single = '';
3841
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
3842
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
3843
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
3844
-
3845
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
3846
-
3847
-    if (function_exists('get_actual_location_name')) {
3848
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
3849
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
3850
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
3851
-    }
3852
-
3853
-    if ($gd_city != '') {
3854
-        if ($gd_city_actual != '') {
3855
-            $gd_city = $gd_city_actual;
3856
-        } else {
3857
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
3858
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
3859
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
3860
-        }
3861
-        $location_single = $gd_city;
3862
-
3863
-    } else if ($gd_region != '') {
3864
-        if ($gd_region_actual != '') {
3865
-            $gd_region = $gd_region_actual;
3866
-        } else {
3867
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
3868
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
3869
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
3870
-        }
3820
+	global $wp;
3821
+	$title = '';
3822
+	// location variables
3823
+	$gd_post_type = geodir_get_current_posttype();
3824
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3825
+	/**
3826
+	 * Filter the title variables location variables array
3827
+	 *
3828
+	 * @since 1.5.5
3829
+	 * @package GeoDirectory
3830
+	 * @param array $location_array The array of location variables.
3831
+	 * @param array $vars The page title variables.
3832
+	 */
3833
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
3834
+	$location_titles = array();
3835
+	if(get_query_var( 'gd_country_full' )){
3836
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
3837
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
3838
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
3839
+	}
3840
+	$location_single = '';
3841
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
3842
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
3843
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
3871 3844
 
3872
-        $location_single = $gd_region;
3873
-    } else if ($gd_country != '') {
3874
-        if ($gd_country_actual != '') {
3875
-            $gd_country = $gd_country_actual;
3876
-        } else {
3877
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
3878
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
3879
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
3880
-        }
3845
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
3846
+
3847
+	if (function_exists('get_actual_location_name')) {
3848
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
3849
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
3850
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
3851
+	}
3881 3852
 
3882
-        $location_single = $gd_country;
3883
-    }
3853
+	if ($gd_city != '') {
3854
+		if ($gd_city_actual != '') {
3855
+			$gd_city = $gd_city_actual;
3856
+		} else {
3857
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
3858
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
3859
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
3860
+		}
3861
+		$location_single = $gd_city;
3862
+
3863
+	} else if ($gd_region != '') {
3864
+		if ($gd_region_actual != '') {
3865
+			$gd_region = $gd_region_actual;
3866
+		} else {
3867
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
3868
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
3869
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
3870
+		}
3871
+
3872
+		$location_single = $gd_region;
3873
+	} else if ($gd_country != '') {
3874
+		if ($gd_country_actual != '') {
3875
+			$gd_country = $gd_country_actual;
3876
+		} else {
3877
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
3878
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
3879
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
3880
+		}
3884 3881
 
3885
-    if (!empty($location_array)) {
3882
+		$location_single = $gd_country;
3883
+	}
3886 3884
 
3887
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
3888
-        $location_array = array_reverse($location_array);
3885
+	if (!empty($location_array)) {
3889 3886
 
3890
-        foreach ($location_array as $location_type => $location) {
3891
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
3892
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
3887
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
3888
+		$location_array = array_reverse($location_array);
3893 3889
 
3894
-            $location_name = geodir_ucwords($gd_location_link_text);
3895
-            $location_name = __($location_name, 'geodirectory');
3890
+		foreach ($location_array as $location_type => $location) {
3891
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
3892
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
3896 3893
 
3897
-            if ($actual_location_name) {
3898
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
3899
-                $location_name = get_actual_location_name($location_type, $location, true);
3900
-            }
3894
+			$location_name = geodir_ucwords($gd_location_link_text);
3895
+			$location_name = __($location_name, 'geodirectory');
3901 3896
 
3902
-            $location_titles[] = $location_name;
3903
-        }
3904
-        if (!empty($location_titles)) {
3905
-            $location_titles = array_unique($location_titles);
3906
-        }
3907
-    }
3897
+			if ($actual_location_name) {
3898
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
3899
+				$location_name = get_actual_location_name($location_type, $location, true);
3900
+			}
3908 3901
 
3902
+			$location_titles[] = $location_name;
3903
+		}
3904
+		if (!empty($location_titles)) {
3905
+			$location_titles = array_unique($location_titles);
3906
+		}
3907
+	}
3909 3908
 
3910
-    if(!empty($location_titles)) {
3911
-        $vars['%%location%%'] = implode(", ", $location_titles);
3912
-    }
3913 3909
 
3910
+	if(!empty($location_titles)) {
3911
+		$vars['%%location%%'] = implode(", ", $location_titles);
3912
+	}
3914 3913
 
3915
-    if(!empty($location_titles)) {
3916
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
3917
-    }
3918 3914
 
3915
+	if(!empty($location_titles)) {
3916
+		$vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
3917
+	}
3919 3918
 
3920 3919
 
3921
-    if($location_single) {
3922
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
3923
-    }
3924 3920
 
3921
+	if($location_single) {
3922
+		$vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
3923
+	}
3925 3924
 
3926
-    if($location_single) {
3927
-        $vars['%%location_single%%'] = $location_single;
3928
-    }
3929 3925
 
3930
-    /**
3931
-     * Filter the title variables after standard ones have been filtered for wpseo.
3932
-     *
3933
-     * @since 1.5.7
3934
-     * @package GeoDirectory
3935
-     * @param string $vars The title with variables.
3936
-     * @param array $location_array The array of location variables.
3937
-     */
3938
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3926
+	if($location_single) {
3927
+		$vars['%%location_single%%'] = $location_single;
3928
+	}
3929
+
3930
+	/**
3931
+	 * Filter the title variables after standard ones have been filtered for wpseo.
3932
+	 *
3933
+	 * @since 1.5.7
3934
+	 * @package GeoDirectory
3935
+	 * @param string $vars The title with variables.
3936
+	 * @param array $location_array The array of location variables.
3937
+	 */
3938
+	return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3939 3939
 }
3940 3940
 
3941 3941
 
@@ -3945,10 +3945,10 @@  discard block
 block discarded – undo
3945 3945
 function geodir_filter_title_variables($title, $gd_page, $sep=''){
3946 3946
 
3947 3947
 
3948
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
3949
-    global $post;
3950
-    //print_r($post);
3951
-    /*
3948
+	if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
3949
+	global $post;
3950
+	//print_r($post);
3951
+	/*
3952 3952
     %%date%%	                Replaced with the date of the post/page
3953 3953
     %%title%%	                Replaced with the title of the post/page
3954 3954
     %%sitename%%	            The site's name
@@ -3975,134 +3975,134 @@  discard block
 block discarded – undo
3975 3975
     %%pagenumber%%	            Replaced with the current page number
3976 3976
      */
3977 3977
 
3978
-    if ($sep == '') {
3979
-        /**
3980
-         * Filter the page title separator.
3981
-         *
3982
-         * @since 1.0.0
3983
-         * @package GeoDirectory
3984
-         * @param string $sep The separator, default: `|`.
3985
-         */
3986
-        $sep = apply_filters('geodir_page_title_separator', '|');
3987
-    }
3988
-
3989
-
3990
-    if(strpos($title,'%%title%%') !== false){
3991
-        $title = str_replace("%%title%%",$post->post_title,$title);
3992
-    }
3993
-
3994
-    if(strpos($title,'%%sitename%%') !== false){
3995
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
3996
-    }
3997
-
3998
-    if(strpos($title,'%%sitedesc%%') !== false){
3999
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4000
-    }
4001
-
4002
-    if(strpos($title,'%%excerpt%%') !== false){
4003
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4004
-    }
4005
-
4006
-    if(strpos($title,'%%pt_single%%') !== false){
4007
-        $single_name = '';
4008
-        if($gd_page=='search' || $gd_page=='author'){
4009
-            $geodir_post_types = get_option('geodir_post_types');
4010
-            $spt = esc_attr($_REQUEST['stype']);
4011
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4012
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4013
-            }
4014
-        }elseif($gd_page=='add-listing'){
4015
-            $geodir_post_types = get_option('geodir_post_types');
4016
-            $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4017
-            if(!$spt && isset($_REQUEST['pid'])){
4018
-                $spt = get_post_type( $_REQUEST['pid'] );
4019
-            }
4020
-            if(!$spt){$spt='gd_place';}
4021
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4022
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4023
-            }
4024
-        }
4025
-        elseif($post->post_type){
4026
-            $geodir_post_types = get_option('geodir_post_types');
4027
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4028
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4029
-            }
3978
+	if ($sep == '') {
3979
+		/**
3980
+		 * Filter the page title separator.
3981
+		 *
3982
+		 * @since 1.0.0
3983
+		 * @package GeoDirectory
3984
+		 * @param string $sep The separator, default: `|`.
3985
+		 */
3986
+		$sep = apply_filters('geodir_page_title_separator', '|');
3987
+	}
4030 3988
 
4031 3989
 
4032
-        }
4033
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4034
-    }
4035
-
4036
-    if(strpos($title,'%%pt_plural%%') !== false){
4037
-        $plural_name = '';
4038
-        if($gd_page=='search' || $gd_page=='author'){
4039
-            $geodir_post_types = get_option('geodir_post_types');
4040
-            $spt = esc_attr($_REQUEST['stype']);
4041
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4042
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4043
-            }
4044
-        }elseif($gd_page=='add-listing'){
4045
-            $geodir_post_types = get_option('geodir_post_types');
4046
-            $spt = sanitize_text_field($_REQUEST['listing_type']);
4047
-            if(!$spt){$spt='gd_place';}
4048
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4049
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4050
-            }
4051
-        }
4052
-        elseif(isset($post->post_type) && $post->post_type){
4053
-            $geodir_post_types = get_option('geodir_post_types');
4054
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4055
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4056
-            }
3990
+	if(strpos($title,'%%title%%') !== false){
3991
+		$title = str_replace("%%title%%",$post->post_title,$title);
3992
+	}
4057 3993
 
4058
-        }
4059
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4060
-    }
3994
+	if(strpos($title,'%%sitename%%') !== false){
3995
+		$title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
3996
+	}
4061 3997
 
3998
+	if(strpos($title,'%%sitedesc%%') !== false){
3999
+		$title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4000
+	}
4062 4001
 
4002
+	if(strpos($title,'%%excerpt%%') !== false){
4003
+		$title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4004
+	}
4063 4005
 
4064
-    if(strpos($title,'%%category%%') !== false){
4065
-        $cat_name = '';
4006
+	if(strpos($title,'%%pt_single%%') !== false){
4007
+		$single_name = '';
4008
+		if($gd_page=='search' || $gd_page=='author'){
4009
+			$geodir_post_types = get_option('geodir_post_types');
4010
+			$spt = esc_attr($_REQUEST['stype']);
4011
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4012
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4013
+			}
4014
+		}elseif($gd_page=='add-listing'){
4015
+			$geodir_post_types = get_option('geodir_post_types');
4016
+			$spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4017
+			if(!$spt && isset($_REQUEST['pid'])){
4018
+				$spt = get_post_type( $_REQUEST['pid'] );
4019
+			}
4020
+			if(!$spt){$spt='gd_place';}
4021
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4022
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4023
+			}
4024
+		}
4025
+		elseif($post->post_type){
4026
+			$geodir_post_types = get_option('geodir_post_types');
4027
+			if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4028
+				$single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4029
+			}
4066 4030
 
4067
-        if($gd_page=='detail') {
4068
-            if ($post->default_category) {
4069
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4070
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4071
-            }
4072
-        }elseif($gd_page=='listing'){
4073
-            $queried_object = get_queried_object();
4074
-            if(isset($queried_object->name)){
4075
-                $cat_name = $queried_object->name;
4076
-            }
4077
-        }
4078
-        $title = str_replace("%%category%%",$cat_name,$title);
4079
-    }
4080
-
4081
-    if(strpos($title,'%%tag%%') !== false){
4082
-        $cat_name = '';
4083
-
4084
-        if($gd_page=='detail') {
4085
-            if ($post->default_category) {
4086
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4087
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4088
-            }
4089
-        }elseif($gd_page=='listing'){
4090
-            $queried_object = get_queried_object();
4091
-            if(isset($queried_object->name)){
4092
-                $cat_name = $queried_object->name;
4093
-            }
4094
-        }
4095
-        $title = str_replace("%%tag%%",$cat_name,$title);
4096
-    }
4031
+
4032
+		}
4033
+		$title = str_replace("%%pt_single%%",$single_name,$title);
4034
+	}
4035
+
4036
+	if(strpos($title,'%%pt_plural%%') !== false){
4037
+		$plural_name = '';
4038
+		if($gd_page=='search' || $gd_page=='author'){
4039
+			$geodir_post_types = get_option('geodir_post_types');
4040
+			$spt = esc_attr($_REQUEST['stype']);
4041
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4042
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4043
+			}
4044
+		}elseif($gd_page=='add-listing'){
4045
+			$geodir_post_types = get_option('geodir_post_types');
4046
+			$spt = sanitize_text_field($_REQUEST['listing_type']);
4047
+			if(!$spt){$spt='gd_place';}
4048
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4049
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4050
+			}
4051
+		}
4052
+		elseif(isset($post->post_type) && $post->post_type){
4053
+			$geodir_post_types = get_option('geodir_post_types');
4054
+			if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4055
+				$plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4056
+			}
4057
+
4058
+		}
4059
+		$title = str_replace("%%pt_plural%%",$plural_name,$title);
4060
+	}
4061
+
4062
+
4063
+
4064
+	if(strpos($title,'%%category%%') !== false){
4065
+		$cat_name = '';
4066
+
4067
+		if($gd_page=='detail') {
4068
+			if ($post->default_category) {
4069
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4070
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4071
+			}
4072
+		}elseif($gd_page=='listing'){
4073
+			$queried_object = get_queried_object();
4074
+			if(isset($queried_object->name)){
4075
+				$cat_name = $queried_object->name;
4076
+			}
4077
+		}
4078
+		$title = str_replace("%%category%%",$cat_name,$title);
4079
+	}
4080
+
4081
+	if(strpos($title,'%%tag%%') !== false){
4082
+		$cat_name = '';
4083
+
4084
+		if($gd_page=='detail') {
4085
+			if ($post->default_category) {
4086
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4087
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4088
+			}
4089
+		}elseif($gd_page=='listing'){
4090
+			$queried_object = get_queried_object();
4091
+			if(isset($queried_object->name)){
4092
+				$cat_name = $queried_object->name;
4093
+			}
4094
+		}
4095
+		$title = str_replace("%%tag%%",$cat_name,$title);
4096
+	}
4097 4097
 
4098 4098
 
4099 4099
 
4100
-    if(strpos($title,'%%id%%') !== false){
4101
-        $ID = (isset($post->ID)) ? $post->ID : '';
4102
-        $title = str_replace("%%id%%",$ID,$title);
4103
-    }
4100
+	if(strpos($title,'%%id%%') !== false){
4101
+		$ID = (isset($post->ID)) ? $post->ID : '';
4102
+		$title = str_replace("%%id%%",$ID,$title);
4103
+	}
4104 4104
 
4105
-    /*
4105
+	/*
4106 4106
         if(strpos($title,'') !== false){
4107 4107
             $title = str_replace("",,$title);
4108 4108
         }
@@ -4112,174 +4112,174 @@  discard block
 block discarded – undo
4112 4112
         }
4113 4113
     */
4114 4114
 
4115
-    if(strpos($title,'%%sep%%') !== false){
4116
-        $title = str_replace("%%sep%%",$sep,$title);
4117
-    }
4118
-
4119
-
4120
-    global $wp;
4121
-    // location variables
4122
-    $gd_post_type = geodir_get_current_posttype();
4123
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4124
-    /**
4125
-     * Filter the title variables location variables array
4126
-     *
4127
-     * @since 1.5.5
4128
-     * @package GeoDirectory
4129
-     * @param array $location_array The array of location variables.
4130
-     * @param string $title The title with variables..
4131
-     * @param string $gd_page The page being filtered.
4132
-     * @param string $sep The separator, default: `|`.
4133
-     */
4134
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4135
-    $location_titles = array();
4136
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4137
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4138
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4139
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4140
-    }
4141
-    $location_single = '';
4142
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4143
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4144
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4145
-
4146
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4147
-
4148
-    if (function_exists('get_actual_location_name')) {
4149
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4150
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4151
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4152
-    }
4153
-
4154
-    if ($gd_city != '') {
4155
-        if ($gd_city_actual != '') {
4156
-            $gd_city = $gd_city_actual;
4157
-        } else {
4158
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4159
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4160
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4161
-        }
4162
-        $location_single = $gd_city;
4163
-
4164
-    } else if ($gd_region != '') {
4165
-        if ($gd_region_actual != '') {
4166
-            $gd_region = $gd_region_actual;
4167
-        } else {
4168
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4169
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4170
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4171
-        }
4115
+	if(strpos($title,'%%sep%%') !== false){
4116
+		$title = str_replace("%%sep%%",$sep,$title);
4117
+	}
4172 4118
 
4173
-        $location_single = $gd_region;
4174
-    } else if ($gd_country != '') {
4175
-        if ($gd_country_actual != '') {
4176
-            $gd_country = $gd_country_actual;
4177
-        } else {
4178
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4179
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4180
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4181
-        }
4182 4119
 
4183
-        $location_single = $gd_country;
4184
-    }
4120
+	global $wp;
4121
+	// location variables
4122
+	$gd_post_type = geodir_get_current_posttype();
4123
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4124
+	/**
4125
+	 * Filter the title variables location variables array
4126
+	 *
4127
+	 * @since 1.5.5
4128
+	 * @package GeoDirectory
4129
+	 * @param array $location_array The array of location variables.
4130
+	 * @param string $title The title with variables..
4131
+	 * @param string $gd_page The page being filtered.
4132
+	 * @param string $sep The separator, default: `|`.
4133
+	 */
4134
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4135
+	$location_titles = array();
4136
+	if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4137
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4138
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4139
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4140
+	}
4141
+	$location_single = '';
4142
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4143
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4144
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4185 4145
 
4186
-    if (!empty($location_array)) {
4146
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4187 4147
 
4188
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4189
-        $location_array = array_reverse($location_array);
4148
+	if (function_exists('get_actual_location_name')) {
4149
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4150
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4151
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4152
+	}
4190 4153
 
4191
-        foreach ($location_array as $location_type => $location) {
4192
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4193
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4154
+	if ($gd_city != '') {
4155
+		if ($gd_city_actual != '') {
4156
+			$gd_city = $gd_city_actual;
4157
+		} else {
4158
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4159
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4160
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4161
+		}
4162
+		$location_single = $gd_city;
4163
+
4164
+	} else if ($gd_region != '') {
4165
+		if ($gd_region_actual != '') {
4166
+			$gd_region = $gd_region_actual;
4167
+		} else {
4168
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4169
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4170
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4171
+		}
4194 4172
 
4195
-            $location_name = geodir_ucwords($gd_location_link_text);
4196
-            $location_name = __($location_name, 'geodirectory');
4173
+		$location_single = $gd_region;
4174
+	} else if ($gd_country != '') {
4175
+		if ($gd_country_actual != '') {
4176
+			$gd_country = $gd_country_actual;
4177
+		} else {
4178
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4179
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4180
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4181
+		}
4197 4182
 
4198
-            if ($actual_location_name) {
4199
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4200
-                $location_name = get_actual_location_name($location_type, $location, true);
4201
-            }
4183
+		$location_single = $gd_country;
4184
+	}
4202 4185
 
4203
-            $location_titles[] = $location_name;
4204
-        }
4205
-        if (!empty($location_titles)) {
4206
-            $location_titles = array_unique($location_titles);
4207
-        }
4208
-    }
4186
+	if (!empty($location_array)) {
4209 4187
 
4188
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4189
+		$location_array = array_reverse($location_array);
4210 4190
 
4211
-    if(strpos($title,'%%location%%') !== false){
4212
-        $location = '';
4213
-        if($location_titles) {
4214
-            $location = implode(", ", $location_titles);
4215
-        }
4216
-        $title = str_replace("%%location%%",$location,$title);
4217
-    }
4191
+		foreach ($location_array as $location_type => $location) {
4192
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4193
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4218 4194
 
4219
-    if(strpos($title,'%%in_location%%') !== false){
4220
-        $location = '';
4221
-        if($location_titles) {
4222
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4223
-        }
4224
-        $title = str_replace("%%in_location%%",$location,$title);
4225
-    }
4195
+			$location_name = geodir_ucwords($gd_location_link_text);
4196
+			$location_name = __($location_name, 'geodirectory');
4226 4197
 
4227
-    if(strpos($title,'%%in_location_single%%') !== false){
4228
-        if($location_single) {
4229
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4230
-        }
4231
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4232
-    }
4198
+			if ($actual_location_name) {
4199
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4200
+				$location_name = get_actual_location_name($location_type, $location, true);
4201
+			}
4233 4202
 
4234
-    if(strpos($title,'%%location_single%%') !== false){
4235
-        $title = str_replace("%%location_single%%",$location_single,$title);
4236
-    }
4203
+			$location_titles[] = $location_name;
4204
+		}
4205
+		if (!empty($location_titles)) {
4206
+			$location_titles = array_unique($location_titles);
4207
+		}
4208
+	}
4237 4209
 
4238 4210
 
4239
-    if(strpos($title,'%%search_term%%') !== false){
4240
-        $search_term = '';
4241
-        if(isset($_REQUEST['s'])){
4242
-            $search_term = esc_attr($_REQUEST['s']);
4243
-        }
4244
-        $title = str_replace("%%search_term%%",$search_term,$title);
4245
-    }
4211
+	if(strpos($title,'%%location%%') !== false){
4212
+		$location = '';
4213
+		if($location_titles) {
4214
+			$location = implode(", ", $location_titles);
4215
+		}
4216
+		$title = str_replace("%%location%%",$location,$title);
4217
+	}
4246 4218
 
4247
-    if(strpos($title,'%%search_near%%') !== false){
4248
-        $search_term = '';
4249
-        if(isset($_REQUEST['snear'])){
4250
-            $search_term = esc_attr($_REQUEST['snear']);
4251
-        }
4252
-        $title = str_replace("%%search_near%%",$search_term,$title);
4253
-    }
4254
-
4255
-    if(strpos($title,'%%name%%') !== false){
4256
-        $author_name = '';
4257
-        if($author_name = get_the_author()){}
4258
-        else{
4259
-            $queried_object = get_queried_object();
4260
-            if(isset($queried_object->data->user_nicename)){
4261
-                $author_name = $queried_object->data->user_nicename;
4262
-            }
4263
-        }
4264
-        $title = str_replace("%%name%%",$author_name,$title);
4265
-    }
4266
-
4267
-    $title = wptexturize( $title );
4268
-    $title = convert_chars( $title );
4269
-    $title = esc_html( $title );
4270
-
4271
-    /**
4272
-     * Filter the title variables after standard ones have been filtered.
4273
-     *
4274
-     * @since 1.5.7
4275
-     * @package GeoDirectory
4276
-     * @param string $title The title with variables.
4277
-     * @param array $location_array The array of location variables.
4278
-     * @param string $gd_page The page being filtered.
4279
-     * @param string $sep The separator, default: `|`.
4280
-     */
4219
+	if(strpos($title,'%%in_location%%') !== false){
4220
+		$location = '';
4221
+		if($location_titles) {
4222
+			$location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4223
+		}
4224
+		$title = str_replace("%%in_location%%",$location,$title);
4225
+	}
4226
+
4227
+	if(strpos($title,'%%in_location_single%%') !== false){
4228
+		if($location_single) {
4229
+			$location_single = __('in', 'geodirectory') . ' ' .$location_single;
4230
+		}
4231
+		$title = str_replace("%%in_location_single%%",$location_single,$title);
4232
+	}
4233
+
4234
+	if(strpos($title,'%%location_single%%') !== false){
4235
+		$title = str_replace("%%location_single%%",$location_single,$title);
4236
+	}
4237
+
4238
+
4239
+	if(strpos($title,'%%search_term%%') !== false){
4240
+		$search_term = '';
4241
+		if(isset($_REQUEST['s'])){
4242
+			$search_term = esc_attr($_REQUEST['s']);
4243
+		}
4244
+		$title = str_replace("%%search_term%%",$search_term,$title);
4245
+	}
4281 4246
 
4282
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4247
+	if(strpos($title,'%%search_near%%') !== false){
4248
+		$search_term = '';
4249
+		if(isset($_REQUEST['snear'])){
4250
+			$search_term = esc_attr($_REQUEST['snear']);
4251
+		}
4252
+		$title = str_replace("%%search_near%%",$search_term,$title);
4253
+	}
4254
+
4255
+	if(strpos($title,'%%name%%') !== false){
4256
+		$author_name = '';
4257
+		if($author_name = get_the_author()){}
4258
+		else{
4259
+			$queried_object = get_queried_object();
4260
+			if(isset($queried_object->data->user_nicename)){
4261
+				$author_name = $queried_object->data->user_nicename;
4262
+			}
4263
+		}
4264
+		$title = str_replace("%%name%%",$author_name,$title);
4265
+	}
4266
+
4267
+	$title = wptexturize( $title );
4268
+	$title = convert_chars( $title );
4269
+	$title = esc_html( $title );
4270
+
4271
+	/**
4272
+	 * Filter the title variables after standard ones have been filtered.
4273
+	 *
4274
+	 * @since 1.5.7
4275
+	 * @package GeoDirectory
4276
+	 * @param string $title The title with variables.
4277
+	 * @param array $location_array The array of location variables.
4278
+	 * @param string $gd_page The page being filtered.
4279
+	 * @param string $sep The separator, default: `|`.
4280
+	 */
4281
+
4282
+	return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4283 4283
 }
4284 4284
 
4285 4285
 /**
@@ -4292,65 +4292,65 @@  discard block
 block discarded – undo
4292 4292
  * @return array Translation texts.
4293 4293
  */
4294 4294
 function geodir_load_cpt_text_translation($translation_texts = array()) {
4295
-    $gd_post_types = geodir_get_posttypes('array');
4296
-
4297
-    if (!empty($gd_post_types)) {
4298
-        foreach ($gd_post_types as $post_type => $cpt_info) {
4299
-            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4300
-            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4301
-            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4302
-
4303
-            if (!empty($labels)) {
4304
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4305
-                    $translation_texts[] = $labels['name'];
4306
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4307
-                    $translation_texts[] = $labels['singular_name'];
4308
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4309
-                    $translation_texts[] = $labels['add_new'];
4310
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4311
-                    $translation_texts[] = $labels['add_new_item'];
4312
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4313
-                    $translation_texts[] = $labels['edit_item'];
4314
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4315
-                    $translation_texts[] = $labels['new_item'];
4316
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4317
-                    $translation_texts[] = $labels['view_item'];
4318
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4319
-                    $translation_texts[] = $labels['search_items'];
4320
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4321
-                    $translation_texts[] = $labels['not_found'];
4322
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4323
-                    $translation_texts[] = $labels['not_found_in_trash'];
4324
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4325
-                    $translation_texts[] = $labels['label_post_profile'];
4326
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4327
-                    $translation_texts[] = $labels['label_post_info'];
4328
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4329
-                    $translation_texts[] = $labels['label_post_images'];
4330
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4331
-                    $translation_texts[] = $labels['label_post_map'];
4332
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4333
-                    $translation_texts[] = $labels['label_reviews'];
4334
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4335
-                    $translation_texts[] = $labels['label_related_listing'];
4336
-            }
4337
-
4338
-            if ($description != '' && !in_array($description, $translation_texts)) {
4339
-                $translation_texts[] = normalize_whitespace($description);
4340
-            }
4341
-
4342
-            if (!empty($seo)) {
4343
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4344
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4345
-
4346
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4347
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4348
-            }
4349
-        }
4350
-    }
4351
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4295
+	$gd_post_types = geodir_get_posttypes('array');
4296
+
4297
+	if (!empty($gd_post_types)) {
4298
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4299
+			$labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4300
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4301
+			$seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4302
+
4303
+			if (!empty($labels)) {
4304
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4305
+					$translation_texts[] = $labels['name'];
4306
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4307
+					$translation_texts[] = $labels['singular_name'];
4308
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4309
+					$translation_texts[] = $labels['add_new'];
4310
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4311
+					$translation_texts[] = $labels['add_new_item'];
4312
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4313
+					$translation_texts[] = $labels['edit_item'];
4314
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4315
+					$translation_texts[] = $labels['new_item'];
4316
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4317
+					$translation_texts[] = $labels['view_item'];
4318
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4319
+					$translation_texts[] = $labels['search_items'];
4320
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4321
+					$translation_texts[] = $labels['not_found'];
4322
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4323
+					$translation_texts[] = $labels['not_found_in_trash'];
4324
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4325
+					$translation_texts[] = $labels['label_post_profile'];
4326
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4327
+					$translation_texts[] = $labels['label_post_info'];
4328
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4329
+					$translation_texts[] = $labels['label_post_images'];
4330
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4331
+					$translation_texts[] = $labels['label_post_map'];
4332
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4333
+					$translation_texts[] = $labels['label_reviews'];
4334
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4335
+					$translation_texts[] = $labels['label_related_listing'];
4336
+			}
4337
+
4338
+			if ($description != '' && !in_array($description, $translation_texts)) {
4339
+				$translation_texts[] = normalize_whitespace($description);
4340
+			}
4341
+
4342
+			if (!empty($seo)) {
4343
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4344
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4345
+
4346
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4347
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4348
+			}
4349
+		}
4350
+	}
4351
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4352 4352
 
4353
-    return $translation_texts;
4353
+	return $translation_texts;
4354 4354
 }
4355 4355
 
4356 4356
 /**
@@ -4363,27 +4363,27 @@  discard block
 block discarded – undo
4363 4363
  * @return array Location terms.
4364 4364
  */
4365 4365
 function geodir_remove_location_terms($location_terms = array()) {
4366
-    $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4367
-
4368
-    if (!empty($location_terms) && $location_manager) {
4369
-        $hide_country_part = get_option('geodir_location_hide_country_part');
4370
-        $hide_region_part = get_option('geodir_location_hide_region_part');
4371
-
4372
-        if ($hide_region_part && $hide_country_part) {
4373
-            if (isset($location_terms['gd_country']))
4374
-                unset($location_terms['gd_country']);
4375
-            if (isset($location_terms['gd_region']))
4376
-                unset($location_terms['gd_region']);
4377
-        } else if ($hide_region_part && !$hide_country_part) {
4378
-            if (isset($location_terms['gd_region']))
4379
-                unset($location_terms['gd_region']);
4380
-        } else if (!$hide_region_part && $hide_country_part) {
4381
-            if (isset($location_terms['gd_country']))
4382
-                unset($location_terms['gd_country']);
4383
-        }
4384
-    }
4366
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4367
+
4368
+	if (!empty($location_terms) && $location_manager) {
4369
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4370
+		$hide_region_part = get_option('geodir_location_hide_region_part');
4371
+
4372
+		if ($hide_region_part && $hide_country_part) {
4373
+			if (isset($location_terms['gd_country']))
4374
+				unset($location_terms['gd_country']);
4375
+			if (isset($location_terms['gd_region']))
4376
+				unset($location_terms['gd_region']);
4377
+		} else if ($hide_region_part && !$hide_country_part) {
4378
+			if (isset($location_terms['gd_region']))
4379
+				unset($location_terms['gd_region']);
4380
+		} else if (!$hide_region_part && $hide_country_part) {
4381
+			if (isset($location_terms['gd_country']))
4382
+				unset($location_terms['gd_country']);
4383
+		}
4384
+	}
4385 4385
 
4386
-    return $location_terms;
4386
+	return $location_terms;
4387 4387
 }
4388 4388
 
4389 4389
 /**
@@ -4397,30 +4397,30 @@  discard block
 block discarded – undo
4397 4397
  * @param bool $update Whether this is an existing listing being updated or not.
4398 4398
  */
4399 4399
 function geodir_on_wp_insert_post($post_ID, $post, $update) {
4400
-    if (!$update) {
4401
-        return;
4402
-    }
4400
+	if (!$update) {
4401
+		return;
4402
+	}
4403 4403
     
4404
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4405
-    $inline_save = isset($_POST['action']) && $_POST['action'] == 'inline-save' ? true : false;
4404
+	$is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4405
+	$inline_save = isset($_POST['action']) && $_POST['action'] == 'inline-save' ? true : false;
4406 4406
 
4407
-    if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4408
-        return;
4409
-    }
4407
+	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4408
+		return;
4409
+	}
4410 4410
 
4411
-    $user_id = (int)get_current_user_id();
4411
+	$user_id = (int)get_current_user_id();
4412 4412
         
4413
-    if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4414
-        $author_id = !empty($post->post_author) ? $post->post_author : 0;
4413
+	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4414
+		$author_id = !empty($post->post_author) ? $post->post_author : 0;
4415 4415
         
4416
-        if ($user_id == $author_id) {
4417
-            $from_email = get_option('site_email');
4418
-            $from_name = get_site_emailName();
4419
-            $to_email = get_option('admin_email');
4420
-            $to_name = get_option('name');
4421
-            $message_type = 'listing_edited';
4416
+		if ($user_id == $author_id) {
4417
+			$from_email = get_option('site_email');
4418
+			$from_name = get_site_emailName();
4419
+			$to_email = get_option('admin_email');
4420
+			$to_name = get_option('name');
4421
+			$message_type = 'listing_edited';
4422 4422
             
4423
-            geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4424
-        }
4425
-    }
4423
+			geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4424
+		}
4425
+	}
4426 4426
 }
4427 4427
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/geodir-class-session.php 3 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -151,8 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @since 1.5.7
152 152
 	 *
153 153
 	 * @param string|array $key Session key.
154
-	 * @param integer $value Session variable.
155
-	 * @return string Session variable.
154
+	 * @return boolean Session variable.
156 155
 	 */
157 156
 	public function un_set( $key ) {
158 157
 		if ( empty( $key ) ) {
@@ -188,8 +187,7 @@  discard block
 block discarded – undo
188 187
 	 * @since 1.5.7
189 188
 	 *
190 189
 	 * @param string $key Session key.
191
-	 * @param integer $value Session variable.
192
-	 * @return string Session variable.
190
+	 * @return boolean Session variable.
193 191
 	 */
194 192
 	public function is_set( $key ) {
195 193
 		$key = sanitize_key( $key );
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 /**
6 6
  * Geodir_Session Class.
@@ -46,36 +46,36 @@  discard block
 block discarded – undo
46 46
 	public function __construct() {
47 47
 		$this->use_php_sessions = $this->use_php_sessions();
48 48
 
49
-		if ( $this->use_php_sessions ) {
50
-			if ( is_multisite() ) {
49
+		if ($this->use_php_sessions) {
50
+			if (is_multisite()) {
51 51
 				$this->prefix = '_' . get_current_blog_id();
52 52
 			}
53 53
 
54 54
 			// Use PHP SESSION (must be enabled via the GEODIR_USE_PHP_SESSIONS constant)
55
-			add_action( 'init', array( $this, 'maybe_start_session' ), -2 );
55
+			add_action('init', array($this, 'maybe_start_session'), -2);
56 56
 		} else {
57 57
 			// Use WP_Session (default)
58
-			if ( !defined( 'WP_SESSION_COOKIE' ) ) {
59
-				define( 'WP_SESSION_COOKIE', 'geodir_wp_session' );
58
+			if (!defined('WP_SESSION_COOKIE')) {
59
+				define('WP_SESSION_COOKIE', 'geodir_wp_session');
60 60
 			}
61 61
 
62
-			if ( !class_exists( 'Recursive_ArrayAccess' ) ) {
62
+			if (!class_exists('Recursive_ArrayAccess')) {
63 63
 				require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-recursive-arrayaccess.php';
64 64
 			}
65 65
 
66
-			if ( !class_exists( 'WP_Session' ) ) {
66
+			if (!class_exists('WP_Session')) {
67 67
 				require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-wp-session.php';
68 68
 				require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/wp-session.php';
69 69
 			}
70 70
 
71
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
72
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
71
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
72
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
73 73
 		}
74 74
 
75
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
76
-			add_action( 'plugins_loaded', array( $this, 'init' ), -1 );
75
+		if (empty($this->session) && !$this->use_php_sessions) {
76
+			add_action('plugins_loaded', array($this, 'init'), -1);
77 77
 		} else {
78
-			add_action( 'init', array( $this, 'init' ), -1 );
78
+			add_action('init', array($this, 'init'), -1);
79 79
 		}
80 80
 	}
81 81
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @return void
88 88
 	 */
89 89
 	public function init() {
90
-		if ( $this->use_php_sessions ) {
91
-			$this->session = isset( $_SESSION['gd' . $this->prefix ] ) && is_array( $_SESSION['gd' . $this->prefix ] ) ? $_SESSION['gd' . $this->prefix ] : array();
90
+		if ($this->use_php_sessions) {
91
+			$this->session = isset($_SESSION['gd' . $this->prefix]) && is_array($_SESSION['gd' . $this->prefix]) ? $_SESSION['gd' . $this->prefix] : array();
92 92
 		} else {
93 93
 			$this->session = WP_Session::get_instance();
94 94
 		}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	 * @param string $key Session key
116 116
 	 * @return string Session variable
117 117
 	 */
118
-	public function get( $key ) {
119
-		$key = sanitize_key( $key );
120
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
118
+	public function get($key) {
119
+		$key = sanitize_key($key);
120
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false;
121 121
 	}
122 122
 
123 123
 	/**
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 * @param integer $value Session variable
130 130
 	 * @return string Session variable
131 131
 	 */
132
-	public function set( $key, $value ) {
133
-		$key = sanitize_key( $key );
132
+	public function set($key, $value) {
133
+		$key = sanitize_key($key);
134 134
 
135
-		if ( is_array( $value ) ) {
136
-			$this->session[ $key ] = maybe_serialize( $value );
135
+		if (is_array($value)) {
136
+			$this->session[$key] = maybe_serialize($value);
137 137
 		} else {
138
-			$this->session[ $key ] = $value;
138
+			$this->session[$key] = $value;
139 139
 		}
140 140
 
141
-		if ( $this->use_php_sessions ) {
142
-			$_SESSION['gd' . $this->prefix ] = $this->session;
141
+		if ($this->use_php_sessions) {
142
+			$_SESSION['gd' . $this->prefix] = $this->session;
143 143
 		}
144 144
 
145
-		return $this->session[ $key ];
145
+		return $this->session[$key];
146 146
 	}
147 147
 	
148 148
 	/**
@@ -154,29 +154,29 @@  discard block
 block discarded – undo
154 154
 	 * @param integer $value Session variable.
155 155
 	 * @return string Session variable.
156 156
 	 */
157
-	public function un_set( $key ) {
158
-		if ( empty( $key ) ) {
157
+	public function un_set($key) {
158
+		if (empty($key)) {
159 159
 			return false;
160 160
 		}
161 161
 		
162
-		if ( is_array( $key ) ) {
162
+		if (is_array($key)) {
163 163
 			foreach ($key as $index) {
164
-				$index = sanitize_key( $index );
164
+				$index = sanitize_key($index);
165 165
 			
166
-				if ( $index && isset( $this->session[ $index ] ) ) {
167
-					unset( $this->session[ $index ] );
166
+				if ($index && isset($this->session[$index])) {
167
+					unset($this->session[$index]);
168 168
 				}
169 169
 			}
170 170
 		} else {
171
-			$key = sanitize_key( $key );
171
+			$key = sanitize_key($key);
172 172
 			
173
-			if ( isset( $this->session[ $key ] ) ) {
174
-				unset( $this->session[ $key ] );
173
+			if (isset($this->session[$key])) {
174
+				unset($this->session[$key]);
175 175
 			}
176 176
 		}
177 177
 
178
-		if ( $this->use_php_sessions ) {
179
-			$_SESSION['gd' . $this->prefix ] = $this->session;
178
+		if ($this->use_php_sessions) {
179
+			$_SESSION['gd' . $this->prefix] = $this->session;
180 180
 		}
181 181
 
182 182
 		return true;
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 	 * @param integer $value Session variable.
192 192
 	 * @return string Session variable.
193 193
 	 */
194
-	public function is_set( $key ) {
195
-		$key = sanitize_key( $key );
194
+	public function is_set($key) {
195
+		$key = sanitize_key($key);
196 196
 		
197
-		if ( empty( $key ) ) {
197
+		if (empty($key)) {
198 198
 			return false;
199 199
 		}
200 200
 
201
-		if ( isset( $this->session[ $key ] ) ) {
201
+		if (isset($this->session[$key])) {
202 202
 			return true;
203 203
 		}
204 204
 
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @param int $exp Default expiration (1 hour)
214 214
 	 * @return int
215 215
 	 */
216
-	public function set_expiration_variant_time( $exp ) {
217
-		return ( 30 * 60 * 23 );
216
+	public function set_expiration_variant_time($exp) {
217
+		return (30 * 60 * 23);
218 218
 	}
219 219
 
220 220
 	/**
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param int $exp Default expiration (1 hour)
226 226
 	 * @return int
227 227
 	 */
228
-	public function set_expiration_time( $exp ) {
229
-		return ( 30 * 60 * 24 );
228
+	public function set_expiration_time($exp) {
229
+		return (30 * 60 * 24);
230 230
 	}
231 231
 
232 232
 	/**
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
 		$ret = false;
245 245
 
246 246
 		// If the database variable is already set, no need to run autodetection
247
-		$geodir_use_php_sessions = (bool)get_option( 'geodir_use_php_sessions' );
247
+		$geodir_use_php_sessions = (bool) get_option('geodir_use_php_sessions');
248 248
 
249
-		if (!$geodir_use_php_sessions ) {
249
+		if (!$geodir_use_php_sessions) {
250 250
 			// Attempt to detect if the server supports PHP sessions
251
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
252
-				$this->set( 'geodir_use_php_sessions', 1 );
251
+			if (function_exists('session_start') && !ini_get('safe_mode')) {
252
+				$this->set('geodir_use_php_sessions', 1);
253 253
 				
254
-				if ( $this->get( 'geodir_use_php_sessions' ) ) {
254
+				if ($this->get('geodir_use_php_sessions')) {
255 255
 					$ret = true;
256 256
 
257 257
 					// Set the database option
258
-					update_option( 'geodir_use_php_sessions', true );
258
+					update_option('geodir_use_php_sessions', true);
259 259
 				}
260 260
 			}
261 261
 		} else {
@@ -263,20 +263,20 @@  discard block
 block discarded – undo
263 263
 		}
264 264
 
265 265
 		// Enable or disable PHP Sessions based on the GEODIR_USE_PHP_SESSIONS constant
266
-		if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && GEODIR_USE_PHP_SESSIONS ) {
266
+		if (defined('GEODIR_USE_PHP_SESSIONS') && GEODIR_USE_PHP_SESSIONS) {
267 267
 			$ret = true;
268
-		} else if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && ! GEODIR_USE_PHP_SESSIONS ) {
268
+		} else if (defined('GEODIR_USE_PHP_SESSIONS') && !GEODIR_USE_PHP_SESSIONS) {
269 269
 			$ret = false;
270 270
 		}
271 271
 
272
-		return (bool) apply_filters( 'geodir_use_php_sessions', $ret );
272
+		return (bool) apply_filters('geodir_use_php_sessions', $ret);
273 273
 	}
274 274
 
275 275
 	/**
276 276
 	 * Starts a new session if one hasn't started yet.
277 277
 	 */
278 278
 	public function maybe_start_session() {
279
-		if ( !session_id() && !headers_sent() ) {
279
+		if (!session_id() && !headers_sent()) {
280 280
 			session_start();
281 281
 		}
282 282
 	}
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	public function use_cart_cookie() {
291 291
 		$ret = true;
292 292
 
293
-		if ( defined( 'GEODIR_USE_CART_COOKIE' ) && ! GEODIR_USE_CART_COOKIE ) {
293
+		if (defined('GEODIR_USE_CART_COOKIE') && !GEODIR_USE_CART_COOKIE) {
294 294
 			$ret = false;
295 295
 		}
296 296
 
297
-		return (bool) apply_filters( 'geodir_use_cart_cookie', $ret );
297
+		return (bool) apply_filters('geodir_use_cart_cookie', $ret);
298 298
 	}
299 299
 }
300 300
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined( 'ABSPATH' ) ) {
4
+	exit;
5
+}
4 6
 
5 7
 /**
6 8
  * Geodir_Session Class.
Please login to merge, or discard this patch.