Completed
Pull Request — master (#209)
by Kiran
05:19
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   +642 added lines, -642 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);
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                     else
669 669
                         $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
670 670
                     $catname = str_replace(' ', '_', $catname);
671
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
671
+                    $uploaded = (array) fetch_remote_file("$dummy_image_url/" . $catname . ".png");
672 672
 
673 673
                     if (empty($uploaded['error'])) {
674 674
                         $new_path = $uploaded['file'];
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
                 else
710 710
                     $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
711 711
                 $catname = str_replace(' ', '_', $catname);
712
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
712
+                $uploaded = (array) fetch_remote_file("$dummy_image_url/" . $catname . ".png");
713 713
 
714 714
                 if (empty($uploaded['error'])) {
715 715
                     $new_path = $uploaded['file'];
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
  */
1022 1022
 function geodir_extend_geodirectory_setting_tab($tabs)
1023 1023
 {
1024
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1024
+    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory') . ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1025 1025
     return $tabs;
1026 1026
 }
1027 1027
 
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 function geodir_post_information_save($post_id, $post) {
1175 1175
     global $wpdb, $current_user;
1176 1176
 
1177
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1177
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
1178 1178
         return;
1179 1179
     }
1180 1180
 
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 
1257 1257
         if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] == 'csv_upload_settings') {
1258 1258
             if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'success') {
1259
-                $rowcount = (int)$_REQUEST['rowcount'];
1259
+                $rowcount = (int) $_REQUEST['rowcount'];
1260 1260
                 $uploads = wp_upload_dir();
1261 1261
                 ?>
1262 1262
                 <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204); margin-left:0px; margin-top:0px; margin-bottom:10px;">
@@ -1270,25 +1270,25 @@  discard block
 block discarded – undo
1270 1270
 
1271 1271
                     if (isset($_REQUEST['invalidcount']) && $_REQUEST['invalidcount'] > 0) {
1272 1272
                         echo '<p>';
1273
-                        printf(CSV_INVALID_DEFUALT_ADDRESS, (int)$_REQUEST['invalidcount'], (int)$_REQUEST['total_records']);
1273
+                        printf(CSV_INVALID_DEFUALT_ADDRESS, (int) $_REQUEST['invalidcount'], (int) $_REQUEST['total_records']);
1274 1274
                         echo '</p>';
1275 1275
                     }
1276 1276
 
1277 1277
                     if (isset($_REQUEST['blank_address']) && $_REQUEST['blank_address'] > 0) {
1278 1278
                         echo '<p>';
1279
-                        printf(CSV_INVALID_TOTAL_RECORD, (int)$_REQUEST['blank_address'], (int)$_REQUEST['total_records']);
1279
+                        printf(CSV_INVALID_TOTAL_RECORD, (int) $_REQUEST['blank_address'], (int) $_REQUEST['total_records']);
1280 1280
                         echo '</p>';
1281 1281
                     }
1282 1282
 
1283 1283
                     if (isset($_REQUEST['invalid_post_type']) && $_REQUEST['invalid_post_type'] > 0) {
1284 1284
                         echo '<p>';
1285
-                        printf(CSV_INVALID_POST_TYPE, (int)$_REQUEST['invalid_post_type'], (int)$_REQUEST['total_records']);
1285
+                        printf(CSV_INVALID_POST_TYPE, (int) $_REQUEST['invalid_post_type'], (int) $_REQUEST['total_records']);
1286 1286
                         echo '</p>';
1287 1287
                     }
1288 1288
 
1289 1289
                     if (isset($_REQUEST['invalid_title']) && $_REQUEST['invalid_title'] > 0) {
1290 1290
                         echo '<p>';
1291
-                        printf(CSV_BLANK_POST_TITLE, (int)$_REQUEST['invalid_title'], (int)$_REQUEST['total_records']);
1291
+                        printf(CSV_BLANK_POST_TITLE, (int) $_REQUEST['invalid_title'], (int) $_REQUEST['total_records']);
1292 1292
                         echo '</p>';
1293 1293
                     }
1294 1294
 
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
                     jQuery('#gd-import-perc').text('0%');
1491 1491
 
1492 1492
                     jQuery('.gd-csv-form-table .filelist .file').remove();
1493
-                    jQuery('#gd-import-msg').find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
1493
+                    jQuery('#gd-import-msg').find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
1494 1494
                     jQuery('#gd-import-msg').show();
1495 1495
 
1496 1496
                     return false;
@@ -1658,38 +1658,38 @@  discard block
 block discarded – undo
1658 1658
 
1659 1659
                 var gdMsg = '<p></p>';
1660 1660
                 if (gd_invalidcount == 0 && gd_blank_address == 0 && gd_invalid_post_type == 0 && gd_invalid_title == 0) {
1661
-                    gdMsg += "<p><?php echo esc_attr( CSV_INSERT_DATA );?></p>";
1661
+                    gdMsg += "<p><?php echo esc_attr(CSV_INSERT_DATA); ?></p>";
1662 1662
                 }
1663 1663
 
1664
-                var msgParse = '<p><?php echo addslashes( CSV_TOTAL_RECORD );?></p>';
1664
+                var msgParse = '<p><?php echo addslashes(CSV_TOTAL_RECORD); ?></p>';
1665 1665
                 gdMsg += msgParse.replace("%s", gd_rowcount);
1666 1666
 
1667 1667
                 if (gd_invalidcount > 0) {
1668
-                    msgParse = msgParse = '<p><?php echo sprintf( CSV_INVALID_DEFUALT_ADDRESS, '%s', '%d' );?></p>';
1668
+                    msgParse = msgParse = '<p><?php echo sprintf(CSV_INVALID_DEFUALT_ADDRESS, '%s', '%d'); ?></p>';
1669 1669
                     msgParse = msgParse.replace("%s", gd_invalidcount);
1670 1670
                     msgParse = msgParse.replace("%d", gd_total_records);
1671 1671
                     gdMsg += msgParse;
1672 1672
                 }
1673 1673
                 if (gd_blank_address > 0) {
1674
-                    msgParse = '<p><?php echo addslashes( sprintf( CSV_INVALID_TOTAL_RECORD, '%s', '%d' ) );?></p>';
1674
+                    msgParse = '<p><?php echo addslashes(sprintf(CSV_INVALID_TOTAL_RECORD, '%s', '%d')); ?></p>';
1675 1675
                     msgParse = msgParse.replace("%s", gd_blank_address);
1676 1676
                     msgParse = msgParse.replace("%d", gd_total_records);
1677 1677
                     gdMsg += msgParse;
1678 1678
                 }
1679 1679
                 if (gd_invalid_post_type > 0) {
1680
-                    msgParse = '<p><?php echo addslashes( sprintf( CSV_INVALID_POST_TYPE, '%s', '%d' ) );?></p>';
1680
+                    msgParse = '<p><?php echo addslashes(sprintf(CSV_INVALID_POST_TYPE, '%s', '%d')); ?></p>';
1681 1681
                     msgParse = msgParse.replace("%s", gd_invalid_post_type);
1682 1682
                     msgParse = msgParse.replace("%d", gd_total_records);
1683 1683
                     gdMsg += msgParse;
1684 1684
                 }
1685 1685
                 if (gd_invalid_title > 0) {
1686
-                    msgParse = '<p><?php echo addslashes( sprintf( CSV_BLANK_POST_TITLE, '%s', '%d' ) );?></p>';
1686
+                    msgParse = '<p><?php echo addslashes(sprintf(CSV_BLANK_POST_TITLE, '%s', '%d')); ?></p>';
1687 1687
                     msgParse = msgParse.replace("%s", gd_invalid_title);
1688 1688
                     msgParse = msgParse.replace("%d", gd_total_records);
1689 1689
                     gdMsg += msgParse;
1690 1690
                 }
1691 1691
                 if (gd_upload_files > 0) {
1692
-                    gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>';
1692
+                    gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>';
1693 1693
                 }
1694 1694
                 gdMsg += '<p></p>';
1695 1695
                 jQuery('#gd-import-msg').find('#message').removeClass('error').addClass('updated').html(gdMsg);
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
         <table class="form-table gd-csv-form-table">
1700 1700
             <tbody>
1701 1701
             <tr valign="top" class="single_select_page">
1702
-                <th class="titledesc" scope="row"><?php echo SELECT_CSV_FILE;?></th>
1702
+                <th class="titledesc" scope="row"><?php echo SELECT_CSV_FILE; ?></th>
1703 1703
                 <td class="forminp">
1704 1704
                     <div class="gtd-formfeild">
1705 1705
                         <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox">
@@ -1734,12 +1734,12 @@  discard block
 block discarded – undo
1734 1734
                                id="gd_import_data" class="button-primary" name="save">
1735 1735
                         <input onclick="gdContinueImport()" type="button" value="Continue Import Data"
1736 1736
                                id="gd_continue_data" class="button-primary" style="display:none"/>
1737
-                        <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>"
1737
+                        <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>"
1738 1738
                                id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none"
1739 1739
                                onclick="gdTerminateImport()"/>
1740 1740
 
1741 1741
                         <div id="gd_process_data" style="display:none"><span class="spinner"
1742
-                                                                             style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
1742
+                                                                             style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
1743 1743
                         </div>
1744 1744
                     </div>
1745 1745
                     <div id="gd_importer" style="display:none">
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
                         <input type="hidden" id="gd_total_records" value="0"/>
1758 1758
                     </div>
1759 1759
                     <div class="gd-import-progress" id="gd-import-progress" style="display:none">
1760
-                        <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
1760
+                        <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
1761 1761
                                 id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
1762 1762
                                 id="gd-import-perc">0%</font> )
1763 1763
                             <div class="gd-fileprogress"></div>
@@ -2016,7 +2016,7 @@  discard block
 block discarded – undo
2016 2016
                             $payment_info = array();
2017 2017
                             $package_info = array();
2018 2018
 
2019
-                            $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2019
+                            $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]);
2020 2020
                             $package_id = '';
2021 2021
                             if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2022 2022
                                 $package_id = $gd_post_info['package_id'];
@@ -2250,7 +2250,7 @@  discard block
 block discarded – undo
2250 2250
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
2251 2251
                                            id="<?php echo esc_attr($value['id']); ?>"
2252 2252
                                            type="<?php echo esc_attr($value['type']); ?>"
2253
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2253
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2254 2254
                                            style=" <?php echo esc_attr($value['css']); ?>"
2255 2255
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
2256 2256
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
2268 2268
                                            id="<?php echo esc_attr($value['id']); ?>"
2269 2269
                                            type="<?php echo esc_attr($value['type']); ?>"
2270
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2270
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2271 2271
                                            style="<?php echo esc_attr($value['css']); ?>"
2272 2272
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
2273 2273
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -2368,7 +2368,7 @@  discard block
 block discarded – undo
2368 2368
                                             id="<?php echo esc_attr($value['id']); ?>"
2369 2369
                                             style="<?php echo esc_attr($value['css']); ?>"
2370 2370
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
2371
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
2371
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>"
2372 2372
                                             option-ajaxchosen="false">
2373 2373
                         <?php
2374 2374
                         foreach ($value['options'] as $key => $val) {
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
                 ?>
2417 2417
 
2418 2418
                 <tr valign="top">
2419
-                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
2419
+                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
2420 2420
                     <td width="60%">
2421 2421
                         <select name="geodir_default_map_language" style="width:60%">
2422 2422
                             <?php
@@ -2498,7 +2498,7 @@  discard block
 block discarded – undo
2498 2498
 
2499 2499
                 <tr valign="top">
2500 2500
                     <th class="titledesc"
2501
-                        width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
2501
+                        width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
2502 2502
                     <td width="60%">
2503 2503
                         <select name="geodir_default_map_search_pt" style="width:60%">
2504 2504
                             <?php
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
                         $cat_display = 'checkbox';
2540 2540
                         $gd_post_types = get_option('geodir_exclude_post_type_on_map');
2541 2541
                         $gd_cats = get_option('geodir_exclude_cat_on_map');
2542
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
2542
+                        $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
2543 2543
                         $count = 1;
2544 2544
                         ?>
2545 2545
                         <table width="70%" class="widefat">
@@ -2568,7 +2568,7 @@  discard block
 block discarded – undo
2568 2568
                                                                                            name="home_map_post_types[]"
2569 2569
                                                                                            id="<?php echo esc_attr($value['id']); ?>"
2570 2570
                                                                                            value="<?php echo $key; ?>"
2571
-                                                                                           class="map_post_type" <?php echo $checked;?> />
2571
+                                                                                           class="map_post_type" <?php echo $checked; ?> />
2572 2572
                                         <?php echo $post_types_obj->labels->singular_name; ?></td>
2573 2573
                                     <td width="40%">
2574 2574
                                         <div class="home_map_category" style="overflow:auto;width:200px;height:100px;"
@@ -2626,12 +2626,12 @@  discard block
 block discarded – undo
2626 2626
                 ?>
2627 2627
                 <fieldset>
2628 2628
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
2629
-                    <label for="<?php echo $value['id'];?>">
2629
+                    <label for="<?php echo $value['id']; ?>">
2630 2630
                         <input name="<?php echo esc_attr($value['id']); ?>"
2631 2631
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
2632 2632
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
2633 2633
                             echo 'checked="checked"';
2634
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
2634
+                        }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
2635 2635
                         <?php echo $value['desc']; ?></label><br>
2636 2636
                 </fieldset>
2637 2637
                 <?php
@@ -2653,7 +2653,7 @@  discard block
 block discarded – undo
2653 2653
                     <textarea
2654 2654
                         <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
2655 2655
                         id="<?php echo esc_attr($value['id']); ?>"
2656
-                        <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2656
+                        <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2657 2657
                         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
2658 2658
                         class="description"><?php echo $value['desc'] ?></span>
2659 2659
 
@@ -2700,7 +2700,7 @@  discard block
 block discarded – undo
2700 2700
 					}
2701 2701
 				}
2702 2702
 				//
2703
-				$page_setting = (int)get_option($value['id']);
2703
+				$page_setting = (int) get_option($value['id']);
2704 2704
 
2705 2705
                 $args = array('name' => $value['id'],
2706 2706
                     'id' => $value['id'],
@@ -2727,7 +2727,7 @@  discard block
 block discarded – undo
2727 2727
                 break;
2728 2728
             case 'single_select_country' :
2729 2729
                 $countries = $geodirectory->countries->countries;
2730
-                $country_setting = (string)get_option($value['id']);
2730
+                $country_setting = (string) get_option($value['id']);
2731 2731
                 if (strstr($country_setting, ':')) :
2732 2732
                     $country = current(explode(':', $country_setting));
2733 2733
                     $state = end(explode(':', $country_setting));
@@ -2750,7 +2750,7 @@  discard block
 block discarded – undo
2750 2750
             case 'multi_select_countries' :
2751 2751
                 $countries = $geodirectory->countries->countries;
2752 2752
                 asort($countries);
2753
-                $selections = (array)get_option($value['id']);
2753
+                $selections = (array) get_option($value['id']);
2754 2754
                 ?>
2755 2755
                 <tr valign="top">
2756 2756
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -2772,8 +2772,8 @@  discard block
 block discarded – undo
2772 2772
                 break;
2773 2773
 
2774 2774
             case 'google_analytics' :
2775
-                $selections = (array)get_option($value['id']);
2776
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
2775
+                $selections = (array) get_option($value['id']);
2776
+                if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
2777 2777
                     ?>
2778 2778
                     <tr valign="top">
2779 2779
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -2784,10 +2784,10 @@  discard block
 block discarded – undo
2784 2784
 
2785 2785
                             $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
2786 2786
                             $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
2787
-                            $state = "&state=123";//any string
2787
+                            $state = "&state=123"; //any string
2788 2788
                             $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2789 2789
                             $response_type = "&response_type=code";
2790
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
2790
+                            $client_id = "&client_id=" . get_option('geodir_ga_client_id');
2791 2791
                             $access_type = "&access_type=offline";
2792 2792
                             $approval_prompt = "&approval_prompt=force";
2793 2793
 
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
                             ?>
2798 2798
                             <script>
2799 2799
                                 function gd_ga_popup() {
2800
-                                    var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
2800
+                                    var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
2801 2801
                                     var pollTimer = window.setInterval(function () {
2802 2802
                                         if (win.closed !== false) { // !== is required for compatibility with Opera
2803 2803
                                             window.clearInterval(pollTimer);
@@ -2819,7 +2819,7 @@  discard block
 block discarded – undo
2819 2819
                             } else {
2820 2820
                                 ?>
2821 2821
                                 <span class="button-primary"
2822
-                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
2822
+                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
2823 2823
                             <?php
2824 2824
                             }
2825 2825
                             ?>
@@ -2890,9 +2890,9 @@  discard block
 block discarded – undo
2890 2890
 
2891 2891
             <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
2892 2892
             jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
2893
-            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
2893
+            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
2894 2894
             jQuery('.gd-content-heading').hide();
2895
-            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
2895
+            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
2896 2896
             <?php } ?>
2897 2897
         });
2898 2898
     </script>
@@ -3034,7 +3034,7 @@  discard block
 block discarded – undo
3034 3034
         <div
3035 3035
             class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
3036 3036
             id="<?php echo $id; ?>plupload-upload-ui">
3037
-            <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
3037
+            <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
3038 3038
             <input id="<?php echo $id; ?>plupload-browse-button" type="button"
3039 3039
                    value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
3040 3040
             <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span>
@@ -3049,7 +3049,7 @@  discard block
 block discarded – undo
3049 3049
              id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
3050 3050
         </div>
3051 3051
         <span
3052
-            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory');?></span>
3052
+            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory'); ?></span>
3053 3053
         <span id="<?php echo $id; ?>upload-error" style="display:none"></span>
3054 3054
     </div>
3055 3055
 
@@ -3427,11 +3427,11 @@  discard block
 block discarded – undo
3427 3427
 function geodir_hide_admin_preview_button() {
3428 3428
     global $post_type;
3429 3429
     $post_types = geodir_get_posttypes();
3430
-    if(in_array($post_type, $post_types))
3430
+    if (in_array($post_type, $post_types))
3431 3431
         echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
3432 3432
 }
3433
-add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
3434
-add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
3433
+add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
3434
+add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
3435 3435
 
3436 3436
 /**
3437 3437
  * Add the tab in left sidebar menu fro import & export page.
@@ -3441,8 +3441,8 @@  discard block
 block discarded – undo
3441 3441
  *
3442 3442
  * @return array Array of tab data.
3443 3443
  */
3444
-function geodir_import_export_tab( $tabs ) {
3445
-	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
3444
+function geodir_import_export_tab($tabs) {
3445
+	$tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
3446 3446
     return $tabs;
3447 3447
 }
3448 3448
 
@@ -3456,7 +3456,7 @@  discard block
 block discarded – undo
3456 3456
  * @return string Html content.
3457 3457
  */
3458 3458
 function geodir_import_export_page() {
3459
-	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
3459
+	$nonce = wp_create_nonce('geodir_import_export_nonce');
3460 3460
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
3461 3461
     /**
3462 3462
      * Filter sample category data csv file url.
@@ -3466,7 +3466,7 @@  discard block
 block discarded – undo
3466 3466
      *
3467 3467
      * @param string $gd_cats_sample_csv Sample category data csv file url.
3468 3468
      */
3469
-	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
3469
+	$gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
3470 3470
 	
3471 3471
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
3472 3472
     /**
@@ -3477,15 +3477,15 @@  discard block
 block discarded – undo
3477 3477
      *
3478 3478
      * @param string $gd_posts_sample_csv Sample post data csv file url.
3479 3479
      */
3480
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
3480
+    $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
3481 3481
 	
3482
-	$gd_posttypes = geodir_get_posttypes( 'array' );
3482
+	$gd_posttypes = geodir_get_posttypes('array');
3483 3483
 	
3484 3484
 	$gd_posttypes_option = '';
3485
-	foreach ( $gd_posttypes as $gd_posttype => $row ) {
3486
-		$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>';
3485
+	foreach ($gd_posttypes as $gd_posttype => $row) {
3486
+		$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>';
3487 3487
 	}
3488
-	wp_enqueue_script( 'jquery-ui-progressbar' );
3488
+	wp_enqueue_script('jquery-ui-progressbar');
3489 3489
 	
3490 3490
 	$gd_chunksize_options = array();
3491 3491
 	$gd_chunksize_options[100] = 100;
@@ -3507,7 +3507,7 @@  discard block
 block discarded – undo
3507 3507
      *
3508 3508
      * @param string $gd_chunksize_options Entries options.
3509 3509
      */
3510
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
3510
+    $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
3511 3511
 	
3512 3512
 	$gd_chunksize_option = '';
3513 3513
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -3518,38 +3518,38 @@  discard block
 block discarded – undo
3518 3518
 ?>
3519 3519
 </form>
3520 3520
 <div class="inner_content_tab_main gd-import-export">
3521
-  <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3>
3522
-  <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span>
3521
+  <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
3522
+  <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
3523 3523
   <div class="gd-content-heading">
3524 3524
 
3525 3525
   <?php
3526 3526
     ini_set('max_execution_time', 999999);
3527
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
3527
+    $ini_max_execution_time_check = @ini_get('max_execution_time');
3528 3528
     ini_restore('max_execution_time');
3529 3529
 
3530
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
3530
+    if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
3531 3531
         ?>
3532 3532
 	<div id="gd_ie_reqs" class="metabox-holder">
3533 3533
       <div class="meta-box-sortables ui-sortable">
3534 3534
         <div class="postbox">
3535
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3>
3535
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
3536 3536
           <div class="inside">
3537
-            <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>
3537
+            <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>
3538 3538
 			<table class="form-table">
3539 3539
 				<thead>
3540 3540
 				  <tr>
3541
-				  	<th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th>
3541
+				  	<th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
3542 3542
 				  </tr>
3543 3543
 				</thead>
3544 3544
 				<tbody>
3545 3545
 				  <tr>
3546
-				  	<td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td>
3546
+				  	<td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
3547 3547
 				  </tr>
3548 3548
 				  <tr>
3549
-				  	<td>max_execution_time</td><td><?php  echo @ini_get( 'max_execution_time' );?></td><td>3000</td>
3549
+				  	<td>max_execution_time</td><td><?php  echo @ini_get('max_execution_time'); ?></td><td>3000</td>
3550 3550
 				  </tr>
3551 3551
 				  <tr>
3552
-				  	<td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td>
3552
+				  	<td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
3553 3553
 				  </tr>
3554 3554
 				</tbody>
3555 3555
 		    </table>
@@ -3561,20 +3561,20 @@  discard block
 block discarded – undo
3561 3561
 	<div id="gd_ie_imposts" class="metabox-holder">
3562 3562
       <div class="meta-box-sortables ui-sortable">
3563 3563
         <div id="gd_ie_im_posts" class="postbox">
3564
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3>
3564
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
3565 3565
           <div class="inside">
3566 3566
             <table class="form-table">
3567 3567
 				<tbody>
3568 3568
 				  <tr>
3569 3569
 					<td class="gd-imex-box">
3570 3570
 						<div class="gd-im-choices">
3571
-						<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>
3572
-						<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>
3571
+						<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>
3572
+						<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>
3573 3573
 						</div>
3574 3574
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui">
3575 3575
 							<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');" />
3576
-							<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">
3577
-						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" />
3576
+							<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">
3577
+						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" />
3578 3578
 							<?php
3579 3579
 							/**
3580 3580
 							 * Called just after the sample CSV download link.
@@ -3583,7 +3583,7 @@  discard block
 block discarded – undo
3583 3583
 							 */
3584 3584
 							do_action('geodir_sample_csv_download_link');
3585 3585
 							?>
3586
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span>
3586
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
3587 3587
 							<div class="filelist"></div>
3588 3588
 						</div>
3589 3589
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -3601,7 +3601,7 @@  discard block
 block discarded – undo
3601 3601
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
3602 3602
 						</div>
3603 3603
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
3604
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
3604
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
3605 3605
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
3606 3606
 									id="gd-import-perc">0%</font> )
3607 3607
 								<div class="gd-fileprogress"></div>
@@ -3613,10 +3613,10 @@  discard block
 block discarded – undo
3613 3613
                     	<div class="gd-imex-btns" style="display:none;">
3614 3614
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
3615 3615
                         	<input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
3616
-                        	<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"/>
3617
-                        	<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')"/>
3616
+                        	<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"/>
3617
+                        	<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')"/>
3618 3618
 							<div id="gd_process_data" style="display:none">
3619
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
3619
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
3620 3620
 							</div>
3621 3621
 						</div>
3622 3622
 					</td>
@@ -3630,25 +3630,25 @@  discard block
 block discarded – undo
3630 3630
 	<div id="gd_ie_excategs" class="metabox-holder">
3631 3631
 	  <div class="meta-box-sortables ui-sortable">
3632 3632
 		<div id="gd_ie_ex_posts" class="postbox">
3633
-		  <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3>
3633
+		  <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
3634 3634
 		  <div class="inside">
3635 3635
 			<table class="form-table">
3636 3636
 			  <tbody>
3637 3637
 				<tr>
3638 3638
 				  <td class="fld"><label for="gd_post_type">
3639
-					<?php _e( 'Post Type:', 'geodirectory' );?>
3639
+					<?php _e('Post Type:', 'geodirectory'); ?>
3640 3640
 					</label></td>
3641 3641
 				  <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px">
3642
-					  <?php echo $gd_posttypes_option;?>
3642
+					  <?php echo $gd_posttypes_option; ?>
3643 3643
 					</select></td>
3644 3644
 				</tr>
3645 3645
 				<tr>
3646
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
3647
-					<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>
3646
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
3647
+					<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>
3648 3648
 				  </tr>
3649 3649
 				<tr>
3650 3650
 				  <td class="fld" style="vertical-align:top"><label>
3651
-					<?php _e( 'Progress:', 'geodirectory' );?>
3651
+					<?php _e('Progress:', 'geodirectory'); ?>
3652 3652
 					</label></td>
3653 3653
 				  <td><div id='gd_progressbar_box'>
3654 3654
 					  <div id="gd_progressbar" class="gd_progressbar">
@@ -3656,13 +3656,13 @@  discard block
 block discarded – undo
3656 3656
 					  </div>
3657 3657
 					</div>
3658 3658
 					<p style="display:inline-block">
3659
-					  <?php _e( 'Elapsed Time:', 'geodirectory' );?>
3659
+					  <?php _e('Elapsed Time:', 'geodirectory'); ?>
3660 3660
 					</p>
3661 3661
 					  
3662 3662
 					<p id="gd_timer" class="gd_timer">00:00:00</p></td>
3663 3663
 				</tr>
3664 3664
 				<tr class="gd-ie-actions">
3665
-				  <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">
3665
+				  <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">
3666 3666
 				  </td>
3667 3667
 				  <td id="gd_ie_ex_files" class="gd-ie-files"></td>
3668 3668
 				</tr>
@@ -3675,20 +3675,20 @@  discard block
 block discarded – undo
3675 3675
 	<div id="gd_ie_imcategs" class="metabox-holder">
3676 3676
       <div class="meta-box-sortables ui-sortable">
3677 3677
         <div id="gd_ie_imcats" class="postbox">
3678
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3>
3678
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
3679 3679
           <div class="inside">
3680 3680
             <table class="form-table">
3681 3681
 				<tbody>
3682 3682
 				  <tr>
3683 3683
 					<td class="gd-imex-box">
3684 3684
 						<div class="gd-im-choices">
3685
-						<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>
3686
-						<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>
3685
+						<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>
3686
+						<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>
3687 3687
 						</div>
3688 3688
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui">
3689 3689
 							<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');" />
3690
-							<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">
3691
-						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" />
3690
+							<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">
3691
+						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" />
3692 3692
 						<?php
3693 3693
 						/**
3694 3694
 						 * Called just after the sample CSV download link.
@@ -3698,7 +3698,7 @@  discard block
 block discarded – undo
3698 3698
 						 */
3699 3699
 						do_action('geodir_sample_cats_csv_download_link');
3700 3700
 						?>
3701
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span>
3701
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
3702 3702
 							<div class="filelist"></div>
3703 3703
 						</div>
3704 3704
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -3715,7 +3715,7 @@  discard block
 block discarded – undo
3715 3715
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
3716 3716
 						</div>
3717 3717
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
3718
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
3718
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
3719 3719
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
3720 3720
 									id="gd-import-perc">0%</font> )
3721 3721
 								<div class="gd-fileprogress"></div>
@@ -3727,10 +3727,10 @@  discard block
 block discarded – undo
3727 3727
                     	<div class="gd-imex-btns" style="display:none;">
3728 3728
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
3729 3729
                         	<input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
3730
-                        	<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"/>
3731
-                        	<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')"/>
3730
+                        	<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"/>
3731
+                        	<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')"/>
3732 3732
 							<div id="gd_process_data" style="display:none">
3733
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
3733
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
3734 3734
 							</div>
3735 3735
 						</div>
3736 3736
 					</td>
@@ -3744,25 +3744,25 @@  discard block
 block discarded – undo
3744 3744
 	<div id="gd_ie_excategs" class="metabox-holder">
3745 3745
       <div class="meta-box-sortables ui-sortable">
3746 3746
         <div id="gd_ie_ex_cats" class="postbox">
3747
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3>
3747
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
3748 3748
           <div class="inside">
3749 3749
             <table class="form-table">
3750 3750
 				<tbody>
3751 3751
 				  <tr>
3752
-					<td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td>
3753
-					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td>
3752
+					<td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
3753
+					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td>
3754 3754
 				  </tr>
3755 3755
 				   <tr>
3756
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
3757
-					<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>
3756
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
3757
+					<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>
3758 3758
 				  </tr>
3759 3759
 				  <tr>
3760
-					<td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td>
3761
-					<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>
3760
+					<td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
3761
+					<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>
3762 3762
 				  </tr>
3763 3763
 				  <tr class="gd-ie-actions">
3764 3764
 					<td style="vertical-align:top">
3765
-						<input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
3765
+						<input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
3766 3766
 					</td>
3767 3767
 					<td id="gd_ie_ex_files" class="gd-ie-files"></td>
3768 3768
 				  </tr>
@@ -3784,7 +3784,7 @@  discard block
 block discarded – undo
3784 3784
      * @param array $gd_chunksize_options File chunk size options.
3785 3785
      * @param string $nonce Wordpress security token for GD import & export.
3786 3786
 	 */
3787
-	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
3787
+	do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
3788 3788
 	?>
3789 3789
   </div>
3790 3790
 </div>
@@ -3803,7 +3803,7 @@  discard block
 block discarded – undo
3803 3803
 		jQuery.ajax({
3804 3804
 			url: ajaxurl,
3805 3805
 			type: "POST",
3806
-			data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>',
3806
+			data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>',
3807 3807
 			dataType: 'json',
3808 3808
 			cache: false,
3809 3809
 			success: function(data) {
@@ -3855,7 +3855,7 @@  discard block
 block discarded – undo
3855 3855
 
3856 3856
 		jQuery(cont).find('.filelist .file').remove();
3857 3857
 		
3858
-		jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
3858
+		jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
3859 3859
 		jQuery('#gd-import-msg', cont).show();
3860 3860
 		
3861 3861
 		return false;
@@ -3914,7 +3914,7 @@  discard block
 block discarded – undo
3914 3914
 	jQuery.ajax({
3915 3915
 		url: ajaxurl,
3916 3916
 		type: "POST",
3917
-		data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>',
3917
+		data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>',
3918 3918
 		dataType : 'json',
3919 3919
 		cache: false,
3920 3920
 		success: function (data) {
@@ -4090,27 +4090,27 @@  discard block
 block discarded – undo
4090 4090
 	
4091 4091
 	var gdMsg = '<p></p>';
4092 4092
 	if ( processed > 0 ) {
4093
-		var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>';
4093
+		var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
4094 4094
 		msgParse = msgParse.replace("%s", processed);
4095 4095
 		gdMsg += msgParse;
4096 4096
 	}
4097 4097
 	
4098 4098
 	if ( updated > 0 ) {
4099
-		var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>';
4099
+		var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
4100 4100
 		msgParse = msgParse.replace("%s", updated);
4101 4101
 		msgParse = msgParse.replace("%d", processed);
4102 4102
 		gdMsg += msgParse;
4103 4103
 	}
4104 4104
 	
4105 4105
 	if ( created > 0 ) {
4106
-		var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>';
4106
+		var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
4107 4107
 		msgParse = msgParse.replace("%s", created);
4108 4108
 		msgParse = msgParse.replace("%d", processed);
4109 4109
 		gdMsg += msgParse;
4110 4110
 	}
4111 4111
 	
4112 4112
 	if ( skipped > 0 ) {
4113
-		var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>';
4113
+		var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
4114 4114
 		msgParse = msgParse.replace("%s", skipped);
4115 4115
 		msgParse = msgParse.replace("%d", processed);
4116 4116
 		gdMsg += msgParse;
@@ -4120,21 +4120,21 @@  discard block
 block discarded – undo
4120 4120
 		if (type=='loc') {
4121 4121
 			invalid_addr = invalid;
4122 4122
 		}
4123
-		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>';
4123
+		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>';
4124 4124
 		msgParse = msgParse.replace("%s", invalid_addr);
4125 4125
 		msgParse = msgParse.replace("%d", total);
4126 4126
 		gdMsg += msgParse;
4127 4127
 	}
4128 4128
 	
4129 4129
 	if (invalid > 0 && type!='loc') {
4130
-		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>';
4130
+		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>';
4131 4131
 		msgParse = msgParse.replace("%s", invalid);
4132 4132
 		msgParse = msgParse.replace("%d", total);
4133 4133
 		gdMsg += msgParse;
4134 4134
 	}
4135 4135
 	
4136 4136
 	if (images > 0) {
4137
-		gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>';
4137
+		gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>';
4138 4138
 	}
4139 4139
 	gdMsg += '<p></p>';
4140 4140
 	jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
@@ -4283,7 +4283,7 @@  discard block
 block discarded – undo
4283 4283
 		
4284 4284
 	function gd_process_export_posts(el, post_type, total_posts, chunk_size, pages, page) {
4285 4285
 		if (page < 2) {
4286
-			gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
4286
+			gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
4287 4287
 			jQuery(el).find('#gd_timer').text('00:00:01');
4288 4288
 			jQuery('#gd_ie_ex_files', el).html('');
4289 4289
 		}
@@ -4291,7 +4291,7 @@  discard block
 block discarded – undo
4291 4291
 		jQuery.ajax({
4292 4292
 			url: ajaxurl,
4293 4293
 			type: "POST",
4294
-			data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
4294
+			data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
4295 4295
 			dataType : 'json',
4296 4296
 			cache: false,
4297 4297
 			beforeSend: function (jqXHR, settings) {},
@@ -4305,11 +4305,11 @@  discard block
 block discarded – undo
4305 4305
 					} else {
4306 4306
 						if (pages < page || pages == page) {
4307 4307
 							window.clearInterval(timer_posts);
4308
-							gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
4308
+							gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
4309 4309
 						} else {
4310 4310
 							var percentage = Math.ceil(( page / pages ) * 100);
4311 4311
 							percentage = percentage > 100 ? 100 : percentage;
4312
-							gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
4312
+							gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
4313 4313
 						}
4314 4314
 						if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
4315 4315
 							var obj_files = data.files;
@@ -4339,7 +4339,7 @@  discard block
 block discarded – undo
4339 4339
 	
4340 4340
 	function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
4341 4341
 		if (page < 2) {
4342
-			gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
4342
+			gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
4343 4343
 			jQuery(el).find('#gd_timer').text('00:00:01');
4344 4344
 			jQuery('#gd_ie_ex_files', el).html('');
4345 4345
 		}
@@ -4347,7 +4347,7 @@  discard block
 block discarded – undo
4347 4347
 		jQuery.ajax({
4348 4348
 			url: ajaxurl,
4349 4349
 			type: "POST",
4350
-			data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
4350
+			data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
4351 4351
 			dataType : 'json',
4352 4352
 			cache: false,
4353 4353
 			beforeSend: function (jqXHR, settings) {},
@@ -4361,11 +4361,11 @@  discard block
 block discarded – undo
4361 4361
 					} else {
4362 4362
 						if (pages < page || pages == page) {
4363 4363
 							window.clearInterval(timer_cats);
4364
-							gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
4364
+							gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
4365 4365
 						} else {
4366 4366
 							var percentage = Math.ceil(( page / pages ) * 100);
4367 4367
 							percentage = percentage > 100 ? 100 : percentage;
4368
-							gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
4368
+							gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
4369 4369
 						}
4370 4370
 						if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
4371 4371
 							var obj_files = data.files;
@@ -4422,8 +4422,8 @@  discard block
 block discarded – undo
4422 4422
 function geodir_init_filesystem()
4423 4423
 {
4424 4424
 
4425
-    if(!function_exists('get_filesystem_method')){
4426
-        require_once(ABSPATH."/wp-admin/includes/file.php");
4425
+    if (!function_exists('get_filesystem_method')) {
4426
+        require_once(ABSPATH . "/wp-admin/includes/file.php");
4427 4427
     }
4428 4428
     $access_type = get_filesystem_method();
4429 4429
     if ($access_type === 'direct') {
@@ -4476,7 +4476,7 @@  discard block
 block discarded – undo
4476 4476
  * @package GeoDirectory
4477 4477
  */
4478 4478
 function geodir_filesystem_notice()
4479
-{   if ( defined( 'DOING_AJAX' ) ){return;}
4479
+{   if (defined('DOING_AJAX')) {return; }
4480 4480
     $access_type = get_filesystem_method();
4481 4481
     if ($access_type === 'direct') {
4482 4482
     } elseif (!defined('FTP_USER')) {
@@ -4513,61 +4513,61 @@  discard block
 block discarded – undo
4513 4513
     // try to set higher limits for import
4514 4514
     $max_input_time = ini_get('max_input_time');
4515 4515
     $max_execution_time = ini_get('max_execution_time');
4516
-    $memory_limit= ini_get('memory_limit');
4516
+    $memory_limit = ini_get('memory_limit');
4517 4517
 
4518
-    if(!$max_input_time || $max_input_time<3000){
4518
+    if (!$max_input_time || $max_input_time < 3000) {
4519 4519
         ini_set('max_input_time', 3000);
4520 4520
     }
4521 4521
 
4522
-    if(!$max_execution_time || $max_execution_time<3000){
4522
+    if (!$max_execution_time || $max_execution_time < 3000) {
4523 4523
         ini_set('max_execution_time', 3000);
4524 4524
     }
4525 4525
 
4526
-    if($memory_limit && str_replace('M','',$memory_limit)){
4527
-        if(str_replace('M','',$memory_limit)<256){
4526
+    if ($memory_limit && str_replace('M', '', $memory_limit)) {
4527
+        if (str_replace('M', '', $memory_limit) < 256) {
4528 4528
             ini_set('memory_limit', '256M');
4529 4529
         }
4530 4530
     }
4531 4531
 
4532 4532
     $json = array();
4533 4533
 
4534
-    if ( !current_user_can( 'manage_options' ) ) {
4535
-        wp_send_json( $json );
4534
+    if (!current_user_can('manage_options')) {
4535
+        wp_send_json($json);
4536 4536
     }
4537 4537
 
4538
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
4539
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
4540
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
4538
+    $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL;
4539
+    $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL;
4540
+    $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false;
4541 4541
 
4542
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
4543
-        wp_send_json( $json );
4542
+    if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
4543
+        wp_send_json($json);
4544 4544
     }
4545 4545
 
4546
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
4547
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
4546
+    $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL;
4547
+    $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL;
4548 4548
     $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
4549
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
4549
+    $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1;
4550 4550
 
4551 4551
     $wp_filesystem = geodir_init_filesystem();
4552 4552
     if (!$wp_filesystem) {
4553
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
4554
-        wp_send_json( $json );
4553
+        $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
4554
+        wp_send_json($json);
4555 4555
     }
4556 4556
 
4557 4557
     if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
4558
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
4559
-        wp_send_json( $json );
4558
+        $json['error'] = __('Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory');
4559
+        wp_send_json($json);
4560 4560
     }
4561 4561
 
4562
-    $csv_file_dir = geodir_path_import_export( false );
4563
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
4564
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
4565
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
4566
-            wp_send_json( $json );
4562
+    $csv_file_dir = geodir_path_import_export(false);
4563
+    if (!$wp_filesystem->is_dir($csv_file_dir)) {
4564
+        if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
4565
+            $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
4566
+            wp_send_json($json);
4567 4567
         }
4568 4568
     }
4569 4569
 
4570
-    switch ( $task ) {
4570
+    switch ($task) {
4571 4571
         case 'export_posts': {
4572 4572
             // WPML
4573 4573
             $is_wpml = geodir_is_wpml();
@@ -4578,12 +4578,12 @@  discard block
 block discarded – undo
4578 4578
                 $sitepress->switch_lang('all', true);
4579 4579
             }
4580 4580
             // WPML
4581
-            if ( $post_type == 'gd_event' ) {
4581
+            if ($post_type == 'gd_event') {
4582 4582
                 //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 );
4583
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
4583
+                add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
4584 4584
             }
4585
-            $file_name = $post_type . '_' . date( 'dmyHi' );
4586
-            $posts_count = geodir_get_posts_count( $post_type );
4585
+            $file_name = $post_type . '_' . date('dmyHi');
4586
+            $posts_count = geodir_get_posts_count($post_type);
4587 4587
             $file_url_base = geodir_path_import_export() . '/';
4588 4588
             $file_url = $file_url_base . $file_name . '.csv';
4589 4589
             $file_path = $csv_file_dir . '/' . $file_name . '.csv';
@@ -4591,10 +4591,10 @@  discard block
 block discarded – undo
4591 4591
             
4592 4592
             $chunk_file_paths = array();
4593 4593
 
4594
-            if ( isset( $_REQUEST['_st'] ) ) {
4595
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
4596
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
4597
-                $percentage = min( $percentage, 100 );
4594
+            if (isset($_REQUEST['_st'])) {
4595
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
4596
+                $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0;
4597
+                $percentage = min($percentage, 100);
4598 4598
                 
4599 4599
                 $json['percentage'] = $percentage;
4600 4600
                 // WPML
@@ -4602,49 +4602,49 @@  discard block
 block discarded – undo
4602 4602
                     $sitepress->switch_lang($active_lang, true);
4603 4603
                 }
4604 4604
                 // WPML
4605
-                wp_send_json( $json );
4605
+                wp_send_json($json);
4606 4606
                 exit;
4607 4607
             } else {				
4608
-                if ( !$posts_count > 0 ) {
4609
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
4608
+                if (!$posts_count > 0) {
4609
+                    $json['error'] = __('No records to export.', 'geodirectory');
4610 4610
                 } else {
4611 4611
                     $total_posts = $posts_count;
4612 4612
                     if ($chunk_per_page > $total_posts) {
4613 4613
                         $chunk_per_page = $total_posts;
4614 4614
                     }
4615
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
4615
+                    $chunk_total_pages = ceil($total_posts / $chunk_per_page);
4616 4616
                     
4617 4617
                     $j = $chunk_page_no;
4618
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
4618
+                    $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j);
4619 4619
                     
4620 4620
                     $per_page = 500;
4621 4621
                     if ($per_page > $chunk_per_page) {
4622 4622
                         $per_page = $chunk_per_page;
4623 4623
                     }
4624
-                    $total_pages = ceil( $chunk_per_page / $per_page );
4624
+                    $total_pages = ceil($chunk_per_page / $per_page);
4625 4625
                     
4626
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4627
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
4626
+                    for ($i = 0; $i <= $total_pages; $i++) {
4627
+                        $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page);
4628 4628
                         
4629 4629
                         $clear = $i == 0 ? true : false;
4630
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
4630
+                        geodir_save_csv_data($file_path_temp, $save_posts, $clear);
4631 4631
                     }
4632 4632
                         
4633
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4633
+                    if ($wp_filesystem->exists($file_path_temp)) {
4634 4634
                         $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4635 4635
                         $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4636 4636
                         $file_path = $csv_file_dir . '/' . $chunk_file_name;
4637
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4637
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
4638 4638
                         
4639 4639
                         $file_url = $file_url_base . $chunk_file_name;
4640 4640
                         $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4641 4641
                     }
4642 4642
                     
4643
-                    if ( !empty($chunk_file_paths) ) {
4643
+                    if (!empty($chunk_file_paths)) {
4644 4644
                         $json['total'] = $posts_count;
4645 4645
                         $json['files'] = $chunk_file_paths;
4646 4646
                     } else {
4647
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
4647
+                        $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
4648 4648
                     }
4649 4649
                 }
4650 4650
                 // WPML
@@ -4652,7 +4652,7 @@  discard block
 block discarded – undo
4652 4652
                     $sitepress->switch_lang($active_lang, true);
4653 4653
                 }
4654 4654
                 // WPML
4655
-                wp_send_json( $json );
4655
+                wp_send_json($json);
4656 4656
             }
4657 4657
         }
4658 4658
         break;
@@ -4666,9 +4666,9 @@  discard block
 block discarded – undo
4666 4666
                 $sitepress->switch_lang('all', true);
4667 4667
             }
4668 4668
             // WPML
4669
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
4669
+            $file_name = $post_type . 'category_' . date('dmyHi');
4670 4670
             
4671
-            $terms_count = geodir_get_terms_count( $post_type );
4671
+            $terms_count = geodir_get_terms_count($post_type);
4672 4672
             $file_url_base = geodir_path_import_export() . '/';
4673 4673
             $file_url = $file_url_base . $file_name . '.csv';
4674 4674
             $file_path = $csv_file_dir . '/' . $file_name . '.csv';
@@ -4676,10 +4676,10 @@  discard block
 block discarded – undo
4676 4676
             
4677 4677
             $chunk_file_paths = array();
4678 4678
             
4679
-            if ( isset( $_REQUEST['_st'] ) ) {
4680
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
4681
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
4682
-                $percentage = min( $percentage, 100 );
4679
+            if (isset($_REQUEST['_st'])) {
4680
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
4681
+                $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0;
4682
+                $percentage = min($percentage, 100);
4683 4683
                 
4684 4684
                 $json['percentage'] = $percentage;
4685 4685
                 // WPML
@@ -4687,48 +4687,48 @@  discard block
 block discarded – undo
4687 4687
                     $sitepress->switch_lang($active_lang, true);
4688 4688
                 }
4689 4689
                 // WPML
4690
-                wp_send_json( $json );
4690
+                wp_send_json($json);
4691 4691
             } else {				
4692
-                if ( !$terms_count > 0 ) {
4693
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
4692
+                if (!$terms_count > 0) {
4693
+                    $json['error'] = __('No records to export.', 'geodirectory');
4694 4694
                 } else {
4695 4695
                     $total_terms = $terms_count;
4696 4696
                     if ($chunk_per_page > $terms_count) {
4697 4697
                         $chunk_per_page = $terms_count;
4698 4698
                     }
4699
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
4699
+                    $chunk_total_pages = ceil($total_terms / $chunk_per_page);
4700 4700
                     
4701 4701
                     $j = $chunk_page_no;					
4702
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
4702
+                    $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j);
4703 4703
                     
4704 4704
                     $per_page = 500;
4705 4705
                     if ($per_page > $chunk_per_page) {
4706 4706
                         $per_page = $chunk_per_page;
4707 4707
                     }
4708
-                    $total_pages = ceil( $chunk_per_page / $per_page );
4708
+                    $total_pages = ceil($chunk_per_page / $per_page);
4709 4709
                     
4710
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4711
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
4710
+                    for ($i = 0; $i <= $total_pages; $i++) {
4711
+                        $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page);
4712 4712
                         
4713 4713
                         $clear = $i == 0 ? true : false;
4714
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
4714
+                        geodir_save_csv_data($file_path_temp, $save_terms, $clear);
4715 4715
                     }
4716 4716
                     
4717
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4717
+                    if ($wp_filesystem->exists($file_path_temp)) {
4718 4718
                         $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4719 4719
                         $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4720 4720
                         $file_path = $csv_file_dir . '/' . $chunk_file_name;
4721
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4721
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
4722 4722
                         
4723 4723
                         $file_url = $file_url_base . $chunk_file_name;
4724 4724
                         $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4725 4725
                     }
4726 4726
                     
4727
-                    if ( !empty($chunk_file_paths) ) {
4727
+                    if (!empty($chunk_file_paths)) {
4728 4728
                         $json['total'] = $terms_count;
4729 4729
                         $json['files'] = $chunk_file_paths;
4730 4730
                     } else {
4731
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
4731
+                        $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
4732 4732
                     }
4733 4733
                 }
4734 4734
                 // WPML
@@ -4736,67 +4736,67 @@  discard block
 block discarded – undo
4736 4736
                     $sitepress->switch_lang($active_lang, true);
4737 4737
                 }
4738 4738
                 // WPML
4739
-                wp_send_json( $json );
4739
+                wp_send_json($json);
4740 4740
             }
4741 4741
         }
4742 4742
         break;
4743 4743
         case 'export_locations': {
4744 4744
             $file_url_base = geodir_path_import_export() . '/';
4745
-            $file_name = 'gd_locations_' . date( 'dmyHi' );			
4745
+            $file_name = 'gd_locations_' . date('dmyHi');			
4746 4746
             $file_url = $file_url_base . $file_name . '.csv';
4747 4747
             $file_path = $csv_file_dir . '/' . $file_name . '.csv';
4748 4748
             $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
4749 4749
             
4750
-            $items_count = (int)geodir_location_imex_count_locations();
4750
+            $items_count = (int) geodir_location_imex_count_locations();
4751 4751
             
4752
-            if ( isset( $_REQUEST['_st'] ) ) {
4753
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
4754
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
4755
-                $percentage = min( $percentage, 100 );
4752
+            if (isset($_REQUEST['_st'])) {
4753
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
4754
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
4755
+                $percentage = min($percentage, 100);
4756 4756
                 
4757 4757
                 $json['percentage'] = $percentage;
4758
-                wp_send_json( $json );
4758
+                wp_send_json($json);
4759 4759
             } else {
4760 4760
                 $chunk_file_paths = array();
4761 4761
                 
4762
-                if ( !$items_count > 0 ) {
4763
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
4762
+                if (!$items_count > 0) {
4763
+                    $json['error'] = __('No records to export.', 'geodirectory');
4764 4764
                 } else {
4765
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
4766
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
4765
+                    $chunk_per_page = min($chunk_per_page, $items_count);
4766
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
4767 4767
                     
4768 4768
                     $j = $chunk_page_no;					
4769
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
4769
+                    $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j);
4770 4770
                     
4771 4771
                     $per_page = 500;
4772
-                    $per_page = min( $per_page, $chunk_per_page );
4773
-                    $total_pages = ceil( $chunk_per_page / $per_page );
4772
+                    $per_page = min($per_page, $chunk_per_page);
4773
+                    $total_pages = ceil($chunk_per_page / $per_page);
4774 4774
                     
4775
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4776
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
4775
+                    for ($i = 0; $i <= $total_pages; $i++) {
4776
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
4777 4777
                         
4778 4778
                         $clear = $i == 0 ? true : false;
4779
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
4779
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
4780 4780
                     }
4781 4781
                     
4782
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4782
+                    if ($wp_filesystem->exists($file_path_temp)) {
4783 4783
                         $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4784 4784
                         $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4785 4785
                         $file_path = $csv_file_dir . '/' . $chunk_file_name;
4786
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4786
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
4787 4787
                         
4788 4788
                         $file_url = $file_url_base . $chunk_file_name;
4789 4789
                         $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4790 4790
                     }
4791 4791
                     
4792
-                    if ( !empty($chunk_file_paths) ) {
4792
+                    if (!empty($chunk_file_paths)) {
4793 4793
                         $json['total'] = $items_count;
4794 4794
                         $json['files'] = $chunk_file_paths;
4795 4795
                     } else {
4796
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
4796
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
4797 4797
                     }
4798 4798
                 }
4799
-                wp_send_json( $json );
4799
+                wp_send_json($json);
4800 4800
             }
4801 4801
         }
4802 4802
         break;
@@ -4812,32 +4812,32 @@  discard block
 block discarded – undo
4812 4812
             }
4813 4813
             // WPML
4814 4814
             
4815
-            ini_set( 'auto_detect_line_endings', true );
4815
+            ini_set('auto_detect_line_endings', true);
4816 4816
             
4817 4817
             $uploads = wp_upload_dir();
4818 4818
             $uploads_dir = $uploads['path'];
4819 4819
             $uploads_subdir = $uploads['subdir'];
4820 4820
             
4821
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
4822
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
4821
+            $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL;
4822
+            $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip';
4823 4823
             
4824
-            $csv_file_arr = explode( '/', $csv_file );
4825
-            $csv_filename = end( $csv_file_arr );
4824
+            $csv_file_arr = explode('/', $csv_file);
4825
+            $csv_filename = end($csv_file_arr);
4826 4826
             $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
4827 4827
             
4828 4828
             $json['file'] = $csv_file;
4829
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4829
+            $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
4830 4830
 
4831
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4832
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4831
+            if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
4832
+                $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename);
4833 4833
                 
4834 4834
                 if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4835 4835
                     $json['error'] = NULL;
4836 4836
                     $json['rows'] = 0;
4837 4837
                     
4838
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4839
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4840
-                            if ( !empty( $data ) ) {
4838
+                    if (($handle = fopen($target_path, "r")) !== FALSE) {
4839
+                        while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
4840
+                            if (!empty($data)) {
4841 4841
                                 $file[] = $data;
4842 4842
                             }
4843 4843
                         }
@@ -4850,19 +4850,19 @@  discard block
 block discarded – undo
4850 4850
                         $json['error'] = __('No data found in csv file.', 'geodirectory');
4851 4851
                     }
4852 4852
                 } else {
4853
-                    wp_send_json( $json );
4853
+                    wp_send_json($json);
4854 4854
                 }
4855 4855
             } else {
4856
-                wp_send_json( $json );
4856
+                wp_send_json($json);
4857 4857
             }
4858 4858
             
4859
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4860
-                wp_send_json( $json );
4859
+            if ($task == 'prepare_import' || !empty($json['error'])) {
4860
+                wp_send_json($json);
4861 4861
             }
4862 4862
             
4863 4863
             $total = $json['rows'];
4864
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4865
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4864
+            $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1;
4865
+            $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0;
4866 4866
             
4867 4867
             $count = $limit;
4868 4868
             $requested_limit = $limit;
@@ -4891,13 +4891,13 @@  discard block
 block discarded – undo
4891 4891
             
4892 4892
             $post_types = geodir_get_posttypes();
4893 4893
 
4894
-            if ( $task == 'import_cat' ) {				
4894
+            if ($task == 'import_cat') {				
4895 4895
                 if (!empty($file)) {
4896 4896
                     $columns = isset($file[0]) ? $file[0] : NULL;
4897 4897
                     
4898 4898
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4899 4899
                         $json['error'] = CSV_INVAILD_FILE;
4900
-                        wp_send_json( $json );
4900
+                        wp_send_json($json);
4901 4901
                         exit;
4902 4902
                     }
4903 4903
                     
@@ -4906,7 +4906,7 @@  discard block
 block discarded – undo
4906 4906
                         
4907 4907
                         if (isset($file[$index])) {
4908 4908
                             $row = $file[$index];
4909
-                            $row = array_map( 'trim', $row );
4909
+                            $row = array_map('trim', $row);
4910 4910
                             //$row = array_map( 'utf8_encode', $row );
4911 4911
                             
4912 4912
                             $cat_id = '';
@@ -4922,26 +4922,26 @@  discard block
 block discarded – undo
4922 4922
                             $cat_language = '';
4923 4923
                             
4924 4924
                             $c = 0;
4925
-                            foreach ($columns as $column ) {
4926
-                                if ( $column == 'cat_id' ) {
4927
-                                    $cat_id = (int)$row[$c];
4928
-                                } else if ( $column == 'cat_name' ) {
4925
+                            foreach ($columns as $column) {
4926
+                                if ($column == 'cat_id') {
4927
+                                    $cat_id = (int) $row[$c];
4928
+                                } else if ($column == 'cat_name') {
4929 4929
                                     $cat_name = $row[$c];
4930
-                                } else if ( $column == 'cat_slug' ) {
4930
+                                } else if ($column == 'cat_slug') {
4931 4931
                                     $cat_slug = $row[$c];
4932
-                                } else if ( $column == 'cat_posttype' ) {
4932
+                                } else if ($column == 'cat_posttype') {
4933 4933
                                     $cat_posttype = $row[$c];
4934
-                                } else if ( $column == 'cat_parent' ) {
4934
+                                } else if ($column == 'cat_parent') {
4935 4935
                                     $cat_parent = trim($row[$c]);
4936
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4936
+                                } else if ($column == 'cat_schema' && $row[$c] != '') {
4937 4937
                                     $cat_schema = $row[$c];
4938
-                                } else if ( $column == 'cat_description' ) {
4938
+                                } else if ($column == 'cat_description') {
4939 4939
                                     $cat_description = $row[$c];
4940
-                                } else if ( $column == 'cat_top_description' ) {
4940
+                                } else if ($column == 'cat_top_description') {
4941 4941
                                     $cat_top_description = $row[$c];
4942
-                                } else if ( $column == 'cat_image' ) {
4942
+                                } else if ($column == 'cat_image') {
4943 4943
                                     $cat_image = $row[$c];
4944
-                                } else if ( $column == 'cat_icon' ) {
4944
+                                } else if ($column == 'cat_icon') {
4945 4945
                                     $cat_icon = $row[$c];
4946 4946
                                 }
4947 4947
                                 // WPML
@@ -4952,7 +4952,7 @@  discard block
 block discarded – undo
4952 4952
                                 $c++;
4953 4953
                             }
4954 4954
                             
4955
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4955
+                            if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
4956 4956
                                 $invalid++;
4957 4957
                                 continue;
4958 4958
                             }
@@ -4969,8 +4969,8 @@  discard block
 block discarded – undo
4969 4969
                             $term_data['description'] = $cat_description;
4970 4970
                             $term_data['cat_schema'] = $cat_schema;
4971 4971
                             $term_data['top_description'] = $cat_top_description;
4972
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4973
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4972
+                            $term_data['image'] = $cat_image != '' ? basename($cat_image) : '';
4973
+                            $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : '';
4974 4974
                             
4975 4975
                             //$term_data = array_map( 'utf8_encode', $term_data );
4976 4976
                             
@@ -4979,14 +4979,14 @@  discard block
 block discarded – undo
4979 4979
                             $term_data['taxonomy'] = $taxonomy;
4980 4980
 
4981 4981
                             $term_parent_id = 0;
4982
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4982
+                            if ($cat_parent != "" || (int) $cat_parent > 0) {
4983 4983
                                 $term_parent = '';
4984 4984
                                 
4985
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4985
+                                if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
4986 4986
                                     $term_parent = $term_parent;
4987
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4987
+                                } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
4988 4988
                                     $term_parent = $term_parent;
4989
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4989
+                                } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
4990 4990
                                     $term_parent = $term_parent;
4991 4991
                                 } else {
4992 4992
                                     $term_parent_data = array();
@@ -4994,47 +4994,47 @@  discard block
 block discarded – undo
4994 4994
                                     //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );										
4995 4995
                                     $term_parent_data['taxonomy'] = $taxonomy;
4996 4996
                                     
4997
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4997
+                                    $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data);
4998 4998
                                 }
4999 4999
                                 
5000
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
5001
-                                    $term_parent_id = (int)$term_parent->term_id;
5000
+                                if (!empty($term_parent) && !is_wp_error($term_parent)) {
5001
+                                    $term_parent_id = (int) $term_parent->term_id;
5002 5002
                                 }
5003 5003
                             }
5004
-                            $term_data['parent'] = (int)$term_parent_id;
5004
+                            $term_data['parent'] = (int) $term_parent_id;
5005 5005
 
5006 5006
                             $term_id = NULL;
5007
-                            if ( $import_choice == 'update' ) {
5008
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
5007
+                            if ($import_choice == 'update') {
5008
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
5009 5009
                                     $term_data['term_id'] = $term['term_id'];
5010 5010
                                     
5011
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
5011
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
5012 5012
                                         $updated++;
5013 5013
                                     } else {
5014 5014
                                         $invalid++;
5015 5015
                                     }
5016
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5016
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
5017 5017
                                     $term_data['term_id'] = $term['term_id'];
5018 5018
                                     
5019
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
5019
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
5020 5020
                                         $updated++;
5021 5021
                                     } else {
5022 5022
                                         $invalid++;
5023 5023
                                     }
5024 5024
                                 } else {
5025
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
5025
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
5026 5026
                                         $created++;
5027 5027
                                     } else {
5028 5028
                                         $invalid++;
5029 5029
                                     }
5030 5030
                                 }
5031
-                            } else if ( $import_choice == 'skip' ) {
5032
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
5031
+                            } else if ($import_choice == 'skip') {
5032
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
5033 5033
                                     $skipped++;
5034
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5034
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
5035 5035
                                     $skipped++;
5036 5036
                                 } else {
5037
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {										
5037
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {										
5038 5038
                                         $created++;
5039 5039
                                     } else {
5040 5040
                                         $invalid++;
@@ -5044,37 +5044,37 @@  discard block
 block discarded – undo
5044 5044
                                 $invalid++;
5045 5045
                             }
5046 5046
                             
5047
-                            if ( $term_id ) {
5048
-                                if ( isset( $term_data['top_description'] ) ) {
5049
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
5047
+                            if ($term_id) {
5048
+                                if (isset($term_data['top_description'])) {
5049
+                                    update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype);
5050 5050
                                 }
5051 5051
                                 
5052
-                                if ( isset( $term_data['cat_schema'] ) ) {
5053
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
5052
+                                if (isset($term_data['cat_schema'])) {
5053
+                                    update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype);
5054 5054
                                 }
5055 5055
             
5056 5056
                                 $attachment = false;
5057
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
5058
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
5059
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
5057
+                                if (isset($term_data['image']) && $term_data['image'] != '') {
5058
+                                    $cat_image = geodir_get_default_catimage($term_id, $cat_posttype);
5059
+                                    $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : '';
5060 5060
                                     
5061
-                                    if ( basename($cat_image) != $term_data['image'] ) {
5061
+                                    if (basename($cat_image) != $term_data['image']) {
5062 5062
                                         $attachment = true;
5063
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
5063
+                                        update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image']), $cat_posttype);
5064 5064
                                     }
5065 5065
                                 }
5066 5066
                                 
5067
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
5068
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
5069
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5067
+                                if (isset($term_data['icon']) && $term_data['icon'] != '') {
5068
+                                    $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype);
5069
+                                    $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
5070 5070
                                         
5071
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
5071
+                                    if (basename($cat_icon) != $term_data['icon']) {
5072 5072
                                         $attachment = true;
5073
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
5073
+                                        update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon']), $cat_posttype);
5074 5074
                                     }
5075 5075
                                 }
5076 5076
                                 
5077
-                                if ( $attachment ) {
5077
+                                if ($attachment) {
5078 5078
                                     $images++;
5079 5079
                                 }
5080 5080
                             }
@@ -5096,14 +5096,14 @@  discard block
 block discarded – undo
5096 5096
                 $json['invalid'] = $invalid;
5097 5097
                 $json['images'] = $images;
5098 5098
                 
5099
-                wp_send_json( $json );
5099
+                wp_send_json($json);
5100 5100
                 exit;
5101
-            } else if ( $task == 'import_post' ) {
5101
+            } else if ($task == 'import_post') {
5102 5102
 
5103 5103
                 //run some stuff to make the import quicker
5104
-                wp_defer_term_counting( true );
5105
-                wp_defer_comment_counting( true );
5106
-                $wpdb->query( 'SET autocommit = 0;' );
5104
+                wp_defer_term_counting(true);
5105
+                wp_defer_comment_counting(true);
5106
+                $wpdb->query('SET autocommit = 0;');
5107 5107
 
5108 5108
                 //remove_all_actions('publish_post');
5109 5109
                 //remove_all_actions('transition_post_status');
@@ -5113,26 +5113,26 @@  discard block
 block discarded – undo
5113 5113
                 if (!empty($file)) {
5114 5114
                     $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
5115 5115
                     $default_status = 'publish';
5116
-                    $current_date = date_i18n( 'Y-m-d', time() );
5116
+                    $current_date = date_i18n('Y-m-d', time());
5117 5117
                     
5118 5118
                     $columns = isset($file[0]) ? $file[0] : NULL;
5119 5119
                     
5120 5120
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5121 5121
                         $json['error'] = CSV_INVAILD_FILE;
5122
-                        wp_send_json( $json );
5122
+                        wp_send_json($json);
5123 5123
                         exit;
5124 5124
                     }
5125 5125
 
5126
-                    $processed_actual=0;
5126
+                    $processed_actual = 0;
5127 5127
                     for ($i = 1; $i <= $limit; $i++) {
5128 5128
                         $index = $processed + $i;
5129 5129
                         $gd_post = array();
5130 5130
                         
5131 5131
                         if (isset($file[$index])) {$processed_actual++;
5132 5132
                             $row = $file[$index];
5133
-                            $row = array_map( 'trim', $row );
5133
+                            $row = array_map('trim', $row);
5134 5134
                             //$row = array_map( 'utf8_encode', $row );
5135
-                            $row = array_map( 'addslashes_gpc', $row );
5135
+                            $row = array_map('addslashes_gpc', $row);
5136 5136
                             
5137 5137
                             $post_id = '';
5138 5138
                             $post_title = '';
@@ -5166,73 +5166,73 @@  discard block
 block discarded – undo
5166 5166
                             $original_post_id = '';
5167 5167
                                                         
5168 5168
                             $c = 0;
5169
-                            foreach ($columns as $column ) {
5169
+                            foreach ($columns as $column) {
5170 5170
                                 $gd_post[$column] = $row[$c];
5171 5171
                                 
5172
-                                if ( $column == 'post_id' ) {
5172
+                                if ($column == 'post_id') {
5173 5173
                                     $post_id = $row[$c];
5174
-                                } else if ( $column == 'post_title' ) {
5174
+                                } else if ($column == 'post_title') {
5175 5175
                                     $post_title = $row[$c];
5176
-                                } else if ( $column == 'post_author' ) {
5176
+                                } else if ($column == 'post_author') {
5177 5177
                                     $post_author = $row[$c];
5178
-                                } else if ( $column == 'post_content' ) {
5178
+                                } else if ($column == 'post_content') {
5179 5179
                                     $post_content = $row[$c];
5180
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
5181
-                                    $post_category_arr = explode( ',', $row[$c] );
5182
-                                } else if ( $column == 'default_category' ) {
5180
+                                } else if ($column == 'post_category' && $row[$c] != '') {
5181
+                                    $post_category_arr = explode(',', $row[$c]);
5182
+                                } else if ($column == 'default_category') {
5183 5183
                                     $default_category = wp_kses_normalize_entities($row[$c]);
5184
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
5185
-                                    $post_tags = explode( ',', $row[$c] );
5186
-                                } else if ( $column == 'post_type' ) {
5184
+                                } else if ($column == 'post_tags' && $row[$c] != '') {
5185
+                                    $post_tags = explode(',', $row[$c]);
5186
+                                } else if ($column == 'post_type') {
5187 5187
                                     $post_type = $row[$c];
5188
-                                } else if ( $column == 'post_status' ) {
5189
-                                    $post_status = sanitize_key( $row[$c] );
5190
-                                } else if ( $column == 'is_featured' ) {
5191
-                                    $is_featured = (int)$row[$c];
5192
-                                } else if ( $column == 'geodir_video' ) {
5188
+                                } else if ($column == 'post_status') {
5189
+                                    $post_status = sanitize_key($row[$c]);
5190
+                                } else if ($column == 'is_featured') {
5191
+                                    $is_featured = (int) $row[$c];
5192
+                                } else if ($column == 'geodir_video') {
5193 5193
                                     $geodir_video = $row[$c];
5194
-                                } else if ( $column == 'post_address' ) {
5194
+                                } else if ($column == 'post_address') {
5195 5195
                                     $post_address = $row[$c];
5196
-                                } else if ( $column == 'post_city' ) {
5196
+                                } else if ($column == 'post_city') {
5197 5197
                                     $post_city = $row[$c];
5198
-                                } else if ( $column == 'post_region' ) {
5198
+                                } else if ($column == 'post_region') {
5199 5199
                                     $post_region = $row[$c];
5200
-                                } else if ( $column == 'post_country' ) {
5200
+                                } else if ($column == 'post_country') {
5201 5201
                                     $post_country = $row[$c];
5202
-                                } else if ( $column == 'post_zip' ) {
5202
+                                } else if ($column == 'post_zip') {
5203 5203
                                     $post_zip = $row[$c];
5204
-                                } else if ( $column == 'post_latitude' ) {
5204
+                                } else if ($column == 'post_latitude') {
5205 5205
                                     $post_latitude = $row[$c];
5206
-                                } else if ( $column == 'post_longitude' ) {
5206
+                                } else if ($column == 'post_longitude') {
5207 5207
                                     $post_longitude = $row[$c];
5208
-                                } else if ( $column == 'geodir_timing' ) {
5208
+                                } else if ($column == 'geodir_timing') {
5209 5209
                                     $geodir_timing = $row[$c];
5210
-                                } else if ( $column == 'geodir_contact' ) {
5210
+                                } else if ($column == 'geodir_contact') {
5211 5211
                                     $geodir_contact = $row[$c];
5212
-                                } else if ( $column == 'geodir_email' ) {
5212
+                                } else if ($column == 'geodir_email') {
5213 5213
                                     $geodir_email = $row[$c];
5214
-                                } else if ( $column == 'geodir_website' ) {
5214
+                                } else if ($column == 'geodir_website') {
5215 5215
                                     $geodir_website = $row[$c];
5216
-                                } else if ( $column == 'geodir_twitter' ) {
5216
+                                } else if ($column == 'geodir_twitter') {
5217 5217
                                     $geodir_twitter = $row[$c];
5218
-                                } else if ( $column == 'geodir_facebook' ) {
5218
+                                } else if ($column == 'geodir_facebook') {
5219 5219
                                     $geodir_facebook = $row[$c];
5220
-                                } else if ( $column == 'geodir_twitter' ) {
5220
+                                } else if ($column == 'geodir_twitter') {
5221 5221
                                     $geodir_twitter = $row[$c];
5222
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
5222
+                                } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
5223 5223
                                     $post_images[] = $row[$c];
5224
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
5225
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
5226
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
5224
+                                } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
5225
+                                    $expire_date = date_i18n('Y-m-d', strtotime($current_date . '+' . (int) $row[$c] . ' days'));
5226
+                                } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
5227 5227
                                     $row[$c] = str_replace('/', '-', $row[$c]);
5228
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
5228
+                                    $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
5229 5229
                                 }
5230 5230
                                 // WPML
5231 5231
                                 if ($is_wpml) {
5232 5232
                                     if ($column == 'language') {
5233 5233
                                         $language = geodir_strtolower(trim($row[$c]));
5234 5234
                                     } else if ($column == 'original_post_id') {
5235
-                                        $original_post_id = (int)$row[$c];
5235
+                                        $original_post_id = (int) $row[$c];
5236 5236
                                     }
5237 5237
                                 }
5238 5238
                                 // WPML
@@ -5247,24 +5247,24 @@  discard block
 block discarded – undo
5247 5247
 
5248 5248
                             $gd_post['IMAGE'] = $post_images;
5249 5249
                             
5250
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
5251
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
5250
+                            $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
5251
+                            $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
5252 5252
                                                                                                                 
5253 5253
                             $valid = true;
5254 5254
                             
5255
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
5255
+                            if ($post_title == '' || !in_array($post_type, $post_types)) {
5256 5256
                                 $invalid++;
5257 5257
                                 $valid = false;
5258 5258
                             }
5259 5259
                             
5260
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5261
-                            if ( $location_allowed ) {
5260
+                            $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
5261
+                            if ($location_allowed) {
5262 5262
                                 $location_result = geodir_get_default_location();
5263
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
5263
+                                if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
5264 5264
                                     $invalid_addr++;
5265 5265
                                     $valid = false;
5266
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
5267
-                                    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 ) ) ) {
5266
+                                } else if (!empty($location_result) && $location_result->location_id == 0) {
5267
+                                    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))) {
5268 5268
                                         $invalid_addr++;
5269 5269
                                         $valid = false;
5270 5270
                                     } else {
@@ -5275,7 +5275,7 @@  discard block
 block discarded – undo
5275 5275
                                 }
5276 5276
                             }
5277 5277
                             
5278
-                            if ( !$valid ) {
5278
+                            if (!$valid) {
5279 5279
                                 continue;
5280 5280
                             }
5281 5281
 
@@ -5288,16 +5288,16 @@  discard block
 block discarded – undo
5288 5288
 
5289 5289
                             $post_category = array();
5290 5290
                             $default_category_id = NULL;
5291
-                            if ( !empty( $post_category_arr ) ) {
5292
-                                foreach ( $post_category_arr as $value ) {
5293
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
5291
+                            if (!empty($post_category_arr)) {
5292
+                                foreach ($post_category_arr as $value) {
5293
+                                    $category_name = wp_kses_normalize_entities(trim($value));
5294 5294
                                     
5295
-                                    if ( $category_name != '' ) {
5295
+                                    if ($category_name != '') {
5296 5296
                                         $term_category = array();
5297 5297
                                         
5298
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
5298
+                                        if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
5299 5299
                                             $term_category = $term;
5300
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
5300
+                                        } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
5301 5301
                                             $term_category = $term;
5302 5302
                                         } else {
5303 5303
                                             $term_data = array();
@@ -5305,13 +5305,13 @@  discard block
 block discarded – undo
5305 5305
                                             //$term_data = array_map( 'utf8_encode', $term_data );										
5306 5306
                                             $term_data['taxonomy'] = $cat_taxonomy;
5307 5307
                                             
5308
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
5309
-                                            if ( $term_id ) {
5310
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
5308
+                                            $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data);
5309
+                                            if ($term_id) {
5310
+                                                $term_category = get_term($term_id, $cat_taxonomy);
5311 5311
                                             }
5312 5312
                                         }
5313 5313
                                         
5314
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
5314
+                                        if (!empty($term_category) && !is_wp_error($term_category)) {
5315 5315
                                             //$post_category[] = $term_category->slug;
5316 5316
                                             $post_category[] = intval($term_category->term_id);
5317 5317
                                             
@@ -5333,28 +5333,28 @@  discard block
 block discarded – undo
5333 5333
                             $save_post['post_tags'] = $post_tags;
5334 5334
 
5335 5335
                             $saved_post_id = NULL;
5336
-                            if ( $import_choice == 'update' ) {
5337
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
5336
+                            if ($import_choice == 'update') {
5337
+                                if ($post_id > 0 && get_post($post_id)) {
5338 5338
                                     $save_post['ID'] = $post_id;
5339 5339
                                     
5340
-                                    if ( wp_update_post( $save_post ) ) {
5340
+                                    if (wp_update_post($save_post)) {
5341 5341
                                         $saved_post_id = $post_id;
5342 5342
                                         $updated++;
5343 5343
                                     }
5344 5344
                                 } else {
5345
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
5345
+                                    if ($saved_post_id = wp_insert_post($save_post)) {
5346 5346
                                         $created++;
5347 5347
                                     }
5348 5348
                                 }
5349 5349
                                 
5350
-                                if ( !$saved_post_id > 0 ) {
5350
+                                if (!$saved_post_id > 0) {
5351 5351
                                     $invalid++;
5352 5352
                                 }
5353
-                            } else if ( $import_choice == 'skip' ) {
5354
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
5353
+                            } else if ($import_choice == 'skip') {
5354
+                                if ($post_id > 0 && get_post($post_id)) {
5355 5355
                                     $skipped++;	
5356 5356
                                 } else {
5357
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
5357
+                                    if ($saved_post_id = wp_insert_post($save_post)) {
5358 5358
                                         $created++;	
5359 5359
                                     } else {
5360 5360
                                         $invalid++;
@@ -5364,19 +5364,19 @@  discard block
 block discarded – undo
5364 5364
                                 $invalid++;
5365 5365
                             }
5366 5366
 
5367
-                            if ( (int)$saved_post_id > 0 ) {
5367
+                            if ((int) $saved_post_id > 0) {
5368 5368
                                 // WPML
5369 5369
                                 if ($is_wpml && $original_post_id > 0 && $language != '') {
5370 5370
                                     $wpml_post_type = 'post_' . $post_type;
5371
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
5371
+                                    $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type);
5372 5372
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
5373 5373
 
5374
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
5374
+                                    $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type);
5375 5375
                                     
5376
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
5376
+                                    $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language);
5377 5377
                                 }
5378 5378
                                 // WPML
5379
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
5379
+                                $gd_post_info = geodir_get_post_info($saved_post_id);
5380 5380
                                 
5381 5381
                                 $gd_post['post_id'] = $saved_post_id;
5382 5382
                                 $gd_post['ID'] = $saved_post_id;
@@ -5388,7 +5388,7 @@  discard block
 block discarded – undo
5388 5388
                                                     
5389 5389
                                 // post location
5390 5390
                                 $post_location_id = 0;
5391
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
5391
+                                if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
5392 5392
                                     $post_location_info = array(
5393 5393
                                                                 'city' => $post_city,
5394 5394
                                                                 'region' => $post_region,
@@ -5396,21 +5396,21 @@  discard block
 block discarded – undo
5396 5396
                                                                 'geo_lat' => $post_latitude,
5397 5397
                                                                 'geo_lng' => $post_longitude
5398 5398
                                                             );
5399
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
5399
+                                    if ($location_id = (int) geodir_add_new_location($post_location_info)) {
5400 5400
                                         $post_location_id = $location_id;
5401 5401
                                     }
5402 5402
                                 }
5403 5403
                                 $gd_post['post_location_id'] = $post_location_id;
5404 5404
                                 
5405 5405
                                 // post package info
5406
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
5406
+                                $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0;
5407 5407
                                 if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
5408 5408
                                     $package_id = $gd_post_info->package_id;
5409 5409
                                 }
5410 5410
                                 
5411 5411
                                 $package_info = array();
5412 5412
                                 if ($package_id && function_exists('geodir_get_package_info_by_id')) {
5413
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
5413
+                                    $package_info = (array) geodir_get_package_info_by_id($package_id);
5414 5414
                                     
5415 5415
                                     if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
5416 5416
                                         $package_info = array();
@@ -5418,18 +5418,18 @@  discard block
 block discarded – undo
5418 5418
                                 }
5419 5419
                                 
5420 5420
                                 if (empty($package_info)) {
5421
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
5421
+                                    $package_info = (array) geodir_post_package_info(array(), '', $post_type);
5422 5422
                                 }
5423 5423
                                  
5424
-                                if (!empty($package_info))	 {
5424
+                                if (!empty($package_info)) {
5425 5425
                                     $package_id = $package_info['pid'];
5426 5426
                                     
5427 5427
                                     if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
5428 5428
                                         $gd_post['expire_date'] = $expire_date;
5429 5429
                                     } else {
5430
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
5431
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
5432
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
5430
+                                        if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
5431
+                                            $gd_post['alive_days'] = (int) $package_info['days'];
5432
+                                            $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date . '+' . (int) $package_info['days'] . ' days'));
5433 5433
                                         } else {
5434 5434
                                             $gd_post['expire_date'] = 'Never';
5435 5435
                                         }
@@ -5449,28 +5449,28 @@  discard block
 block discarded – undo
5449 5449
                                 }
5450 5450
 
5451 5451
                                 // Export franchise fields
5452
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5452
+                                $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
5453 5453
                                 if ($is_franchise_active) {
5454
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
5454
+                                    if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
5455 5455
                                         $gd_franchise_lock = array();
5456 5456
                                         
5457
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
5458
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
5459
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
5460
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
5457
+                                        if (isset($gd_post['gd_franchise_lock'])) {
5458
+                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
5459
+                                            $gd_franchise_lock = trim($gd_franchise_lock);
5460
+                                            $gd_franchise_lock = explode(",", $gd_franchise_lock);
5461 5461
                                         }
5462 5462
                                         
5463
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
5464
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
5463
+                                        update_post_meta($saved_post_id, 'gd_is_franchise', 1);
5464
+                                        update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock);
5465 5465
                                     } else {
5466
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
5467
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
5466
+                                        if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
5467
+                                            geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']);
5468 5468
                                         }
5469 5469
                                     }
5470 5470
                                 }
5471 5471
                                 
5472 5472
                                 if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
5473
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
5473
+                                    $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
5474 5474
                                     if ($default_category_id) {
5475 5475
                                         $save_post['post_default_category'] = $default_category_id;
5476 5476
                                         $gd_post['default_category'] = $default_category_id;
@@ -5479,12 +5479,12 @@  discard block
 block discarded – undo
5479 5479
                                 }
5480 5480
                                 
5481 5481
                                 // Save post info
5482
-                                geodir_save_post_info( $saved_post_id, $gd_post );
5482
+                                geodir_save_post_info($saved_post_id, $gd_post);
5483 5483
                                 // post taxonomies
5484
-                                if ( !empty( $save_post['post_category'] ) ) {
5485
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
5484
+                                if (!empty($save_post['post_category'])) {
5485
+                                    wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy);
5486 5486
                                     
5487
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
5487
+                                    $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : '';
5488 5488
                                     if ($default_category_id) {
5489 5489
                                         $post_default_category = $default_category_id;
5490 5490
                                     }
@@ -5498,15 +5498,15 @@  discard block
 block discarded – undo
5498 5498
                                     
5499 5499
                                     $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
5500 5500
                                     
5501
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
5501
+                                    geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str);
5502 5502
                                 }
5503 5503
 
5504
-                                if ( !empty( $save_post['post_tags'] ) ) {
5505
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
5504
+                                if (!empty($save_post['post_tags'])) {
5505
+                                    wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy);
5506 5506
                                 }
5507 5507
 
5508 5508
                                 // Post images
5509
-                                if ( !empty( $post_images ) ) {
5509
+                                if (!empty($post_images)) {
5510 5510
                                     $post_images = array_unique($post_images);
5511 5511
                                     
5512 5512
                                     $old_post_images_arr = array();
@@ -5514,30 +5514,30 @@  discard block
 block discarded – undo
5514 5514
                                     
5515 5515
                                     $order = 1;
5516 5516
                                     
5517
-                                    $old_post_images = geodir_get_images( $saved_post_id );
5517
+                                    $old_post_images = geodir_get_images($saved_post_id);
5518 5518
                                     if (!empty($old_post_images)) {
5519
-                                        foreach( $old_post_images as $old_post_image ) {
5519
+                                        foreach ($old_post_images as $old_post_image) {
5520 5520
                                             if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
5521 5521
                                                 $old_post_images_arr[] = $old_post_image->file;
5522 5522
                                             }
5523 5523
                                         }
5524 5524
                                     }
5525 5525
                                     
5526
-                                    foreach ( $post_images as $post_image ) {
5527
-                                        $image_name = basename( $post_image );
5526
+                                    foreach ($post_images as $post_image) {
5527
+                                        $image_name = basename($post_image);
5528 5528
                                         $saved_post_images_arr[] = $image_name;
5529 5529
                                         
5530
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
5530
+                                        if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
5531 5531
                                             continue; // Skip if image already exists.
5532 5532
                                         }
5533 5533
                                         
5534
-                                        $image_name_parts = explode( '.', $image_name );
5535
-                                        array_pop( $image_name_parts );
5536
-                                        $proper_image_name = implode( '.', $image_name_parts );
5534
+                                        $image_name_parts = explode('.', $image_name);
5535
+                                        array_pop($image_name_parts);
5536
+                                        $proper_image_name = implode('.', $image_name_parts);
5537 5537
                                         
5538
-                                        $arr_file_type = wp_check_filetype( $image_name );
5538
+                                        $arr_file_type = wp_check_filetype($image_name);
5539 5539
                                         
5540
-                                        if ( !empty( $arr_file_type ) ) {
5540
+                                        if (!empty($arr_file_type)) {
5541 5541
                                             $uploaded_file_type = $arr_file_type['type'];
5542 5542
                                             
5543 5543
                                             $attachment = array();
@@ -5550,46 +5550,46 @@  discard block
 block discarded – undo
5550 5550
                                             $attachment['is_featured'] = 0;
5551 5551
 
5552 5552
                                             $attachment_set = '';
5553
-                                            foreach ( $attachment as $key => $val ) {
5554
-                                                if ( $val != '' ) {
5553
+                                            foreach ($attachment as $key => $val) {
5554
+                                                if ($val != '') {
5555 5555
                                                     $attachment_set .= $key . " = '" . $val . "', ";
5556 5556
                                                 }
5557 5557
                                             }
5558
-                                            $attachment_set = trim( $attachment_set, ", " );
5558
+                                            $attachment_set = trim($attachment_set, ", ");
5559 5559
                                                                                         
5560 5560
                                             // Add new attachment
5561
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
5561
+                                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
5562 5562
                                                                                         
5563 5563
                                             $order++;
5564 5564
                                         }
5565 5565
                                     }
5566 5566
 
5567
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
5567
+                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
5568 5568
                                     // Remove previous attachment
5569
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
5569
+                                    $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int) $saved_post_id . " " . $saved_post_images_sql);
5570 5570
                                     
5571
-                                    if ( !empty( $saved_post_images_arr ) ) {
5571
+                                    if (!empty($saved_post_images_arr)) {
5572 5572
                                         $menu_order = 1;
5573 5573
                                         
5574
-                                        foreach ( $saved_post_images_arr as $img_name ) {
5575
-                                            $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 ) ) );
5574
+                                        foreach ($saved_post_images_arr as $img_name) {
5575
+                                            $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)));
5576 5576
                                             
5577
-                                            if( $menu_order == 1 ) {
5578
-                                                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 ) ) ) ) {
5579
-                                                    $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
5577
+                                            if ($menu_order == 1) {
5578
+                                                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)))) {
5579
+                                                    $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array($featured_image, $saved_post_id)));
5580 5580
                                                 }
5581 5581
                                             }
5582 5582
                                             $menu_order++;
5583 5583
                                         }
5584 5584
                                     }
5585 5585
                                     
5586
-                                    if ( $order > 1 ) {
5586
+                                    if ($order > 1) {
5587 5587
                                         $images++;
5588 5588
                                     }
5589 5589
                                 }
5590 5590
 
5591 5591
                                 /** This action is documented in geodirectory-functions/post-functions.php */
5592
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
5592
+                                do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
5593 5593
                                 
5594 5594
                                 if (isset($is_featured)) {
5595 5595
                                     geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
@@ -5609,10 +5609,10 @@  discard block
 block discarded – undo
5609 5609
                 }
5610 5610
 
5611 5611
                 //undo some stuff to make the import quicker
5612
-                wp_defer_term_counting( false );
5613
-                wp_defer_comment_counting( false );
5614
-                $wpdb->query( 'COMMIT;' );
5615
-                $wpdb->query( 'SET autocommit = 1;' );
5612
+                wp_defer_term_counting(false);
5613
+                wp_defer_comment_counting(false);
5614
+                $wpdb->query('COMMIT;');
5615
+                $wpdb->query('SET autocommit = 1;');
5616 5616
 
5617 5617
                 $json = array();
5618 5618
                 $json['processed'] = $processed_actual;
@@ -5623,9 +5623,9 @@  discard block
 block discarded – undo
5623 5623
                 $json['invalid_addr'] = $invalid_addr;
5624 5624
                 $json['images'] = $images;
5625 5625
                 
5626
-                wp_send_json( $json );
5626
+                wp_send_json($json);
5627 5627
                 exit;
5628
-            } else if ( $task == 'import_loc' ) {
5628
+            } else if ($task == 'import_loc') {
5629 5629
                 global $gd_post_types;
5630 5630
                 $gd_post_types = $post_types;
5631 5631
                 
@@ -5634,7 +5634,7 @@  discard block
 block discarded – undo
5634 5634
                     
5635 5635
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5636 5636
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
5637
-                        wp_send_json( $json );
5637
+                        wp_send_json($json);
5638 5638
                     }
5639 5639
                     
5640 5640
                     for ($i = 1; $i <= $limit; $i++) {
@@ -5642,59 +5642,59 @@  discard block
 block discarded – undo
5642 5642
                         
5643 5643
                         if (isset($file[$index])) {
5644 5644
                             $row = $file[$index];
5645
-                            $row = array_map( 'trim', $row );
5645
+                            $row = array_map('trim', $row);
5646 5646
                             $data = array();
5647 5647
                             
5648
-                            foreach ($columns as $c => $column ) {
5648
+                            foreach ($columns as $c => $column) {
5649 5649
                                 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'))) {
5650 5650
                                     $data[$column] = $row[$c];
5651 5651
                                 }
5652 5652
                             }
5653 5653
 
5654
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
5654
+                            if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
5655 5655
                                 $invalid++;
5656 5656
                                 continue;
5657 5657
                             }
5658 5658
                             
5659 5659
                             $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
5660 5660
                             
5661
-                            if ( $import_choice == 'update' ) {
5662
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5663
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5661
+                            if ($import_choice == 'update') {
5662
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
5663
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
5664 5664
                                         $updated++;
5665 5665
                                     } else {
5666 5666
                                         $invalid++;
5667 5667
                                     }
5668
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5669
-                                    $data['location_id'] = (int)$location->location_id;
5668
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
5669
+                                    $data['location_id'] = (int) $location->location_id;
5670 5670
                                     
5671
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
5672
-                                        $data['location_id'] = (int)$location->location_id;
5673
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
5674
-                                        $data['location_id'] = (int)$location->location_id;
5675
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
5676
-                                        $data['location_id'] = (int)$location->location_id;
5671
+                                    if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
5672
+                                        $data['location_id'] = (int) $location->location_id;
5673
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
5674
+                                        $data['location_id'] = (int) $location->location_id;
5675
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
5676
+                                        $data['location_id'] = (int) $location->location_id;
5677 5677
                                     }
5678 5678
                                     
5679
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5679
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
5680 5680
                                         $updated++;
5681 5681
                                     } else {
5682 5682
                                         $invalid++;
5683 5683
                                     }
5684 5684
                                 } else {
5685
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5685
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
5686 5686
                                         $created++;
5687 5687
                                     } else {
5688 5688
                                         $invalid++;
5689 5689
                                     }
5690 5690
                                 }
5691
-                            } elseif ( $import_choice == 'skip' ) {
5692
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5691
+                            } elseif ($import_choice == 'skip') {
5692
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
5693 5693
                                     $skipped++;
5694
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5694
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
5695 5695
                                     $skipped++;
5696 5696
                                 } else {
5697
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {										
5697
+                                    if ($location_id = geodir_location_insert_city($data, true)) {										
5698 5698
                                         $created++;
5699 5699
                                     } else {
5700 5700
                                         $invalid++;
@@ -5715,7 +5715,7 @@  discard block
 block discarded – undo
5715 5715
                 $json['invalid'] = $invalid;
5716 5716
                 $json['images'] = $images;
5717 5717
                 
5718
-                wp_send_json( $json );
5718
+                wp_send_json($json);
5719 5719
             }
5720 5720
         }
5721 5721
         break;
@@ -5759,29 +5759,29 @@  discard block
 block discarded – undo
5759 5759
  * }
5760 5760
  * @return int|bool Term id when success, false when fail.
5761 5761
  */
5762
-function geodir_imex_insert_term( $taxonomy, $term_data ) {
5763
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5762
+function geodir_imex_insert_term($taxonomy, $term_data) {
5763
+	if (empty($taxonomy) || empty($term_data)) {
5764 5764
 		return false;
5765 5765
 	}
5766 5766
 	
5767
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
5767
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
5768 5768
 	$args = array();
5769
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5770
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5771
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5769
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5770
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5771
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5772 5772
 	
5773
-	if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
5774
-		$term_args = array_merge( $term_data, $args );
5775
-		$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5776
-		$term_args = wp_parse_args( $term_args, $defaults );
5777
-		$term_args = sanitize_term( $term_args, $taxonomy, 'db' );
5778
-		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5773
+	if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
5774
+		$term_args = array_merge($term_data, $args);
5775
+		$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5776
+		$term_args = wp_parse_args($term_args, $defaults);
5777
+		$term_args = sanitize_term($term_args, $taxonomy, 'db');
5778
+		$args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args);
5779 5779
 	}
5780 5780
 	
5781
-    if( !empty( $term ) ) {
5782
-		$result = wp_insert_term( $term, $taxonomy, $args );
5783
-        if( !is_wp_error( $result ) ) {
5784
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5781
+    if (!empty($term)) {
5782
+		$result = wp_insert_term($term, $taxonomy, $args);
5783
+        if (!is_wp_error($result)) {
5784
+            return $term_id = isset($result['term_id']) ? $result['term_id'] : 0;
5785 5785
         }
5786 5786
     }
5787 5787
 	
@@ -5811,37 +5811,37 @@  discard block
 block discarded – undo
5811 5811
  * }
5812 5812
  * @return int|bool Term id when success, false when fail.
5813 5813
  */
5814
-function geodir_imex_update_term( $taxonomy, $term_data ) {
5815
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5814
+function geodir_imex_update_term($taxonomy, $term_data) {
5815
+	if (empty($taxonomy) || empty($term_data)) {
5816 5816
 		return false;
5817 5817
 	}
5818 5818
 	
5819
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
5820
-	$term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0;
5819
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
5820
+	$term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0;
5821 5821
 	
5822 5822
 	$args = array();
5823
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5824
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5825
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5823
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5824
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5825
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5826 5826
 	
5827
-	if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
5827
+	if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
5828 5828
 		$term_data['term_id'] = $term_info['term_id'];
5829 5829
 		
5830
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5830
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5831 5831
 		
5832
-		if( !is_wp_error( $result ) ) {
5833
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5832
+		if (!is_wp_error($result)) {
5833
+            return $term_id = isset($result['term_id']) ? $result['term_id'] : 0;
5834 5834
         }
5835
-	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5835
+	} else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
5836 5836
 		$term_data['term_id'] = $term_info['term_id'];
5837 5837
 		
5838
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5838
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5839 5839
 		
5840
-		if( !is_wp_error( $result ) ) {
5841
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5840
+		if (!is_wp_error($result)) {
5841
+            return $term_id = isset($result['term_id']) ? $result['term_id'] : 0;
5842 5842
         }
5843 5843
 	} else {
5844
-		return geodir_imex_insert_term( $taxonomy, $term_data );
5844
+		return geodir_imex_insert_term($taxonomy, $term_data);
5845 5845
 	}
5846 5846
 	
5847 5847
 	return false;
@@ -5856,9 +5856,9 @@  discard block
 block discarded – undo
5856 5856
  * @param string $post_type Post type.
5857 5857
  * @return int Posts count.
5858 5858
  */
5859
-function geodir_get_posts_count( $post_type ) {
5860
-	$posts_count = wp_count_posts( $post_type );
5861
-	$posts_count = array_sum( (array)$posts_count );
5859
+function geodir_get_posts_count($post_type) {
5860
+	$posts_count = wp_count_posts($post_type);
5861
+	$posts_count = array_sum((array) $posts_count);
5862 5862
 	
5863 5863
 	/**
5864 5864
 	 * Modify returned post counts for the current post type.
@@ -5869,7 +5869,7 @@  discard block
 block discarded – undo
5869 5869
 	 * @param int $posts_count Post counts.
5870 5870
 	 * @param string $post_type Post type.
5871 5871
 	 */
5872
-	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );	 
5872
+	$posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);	 
5873 5873
 	
5874 5874
 	return $posts_count;
5875 5875
 }
@@ -5887,8 +5887,8 @@  discard block
 block discarded – undo
5887 5887
  * @param string $post_type Post type.
5888 5888
  * @return int Posts count.
5889 5889
  */
5890
-function geodir_imex_count_events( $posts_count, $post_type ) {
5891
-	if ( $post_type == 'gd_event' ) {
5890
+function geodir_imex_count_events($posts_count, $post_type) {
5891
+	if ($post_type == 'gd_event') {
5892 5892
 		global $wpdb, $plugin_prefix;
5893 5893
 		
5894 5894
 		$table = $plugin_prefix . $post_type . '_detail';
@@ -5896,7 +5896,7 @@  discard block
 block discarded – undo
5896 5896
 
5897 5897
 		$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";
5898 5898
 		
5899
-		$posts_count = (int)$wpdb->get_var( $wpdb->prepare( $query, $post_type ) );
5899
+		$posts_count = (int) $wpdb->get_var($wpdb->prepare($query, $post_type));
5900 5900
 	}
5901 5901
 	
5902 5902
 	return $posts_count;
@@ -5918,15 +5918,15 @@  discard block
 block discarded – undo
5918 5918
  * @param int $page_no Page number. Default 0.
5919 5919
  * @return array Array of posts data.
5920 5920
  */
5921
-function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {	
5921
+function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {	
5922 5922
 	global $wp_filesystem;
5923 5923
 
5924
-	$posts = geodir_get_export_posts( $post_type, $per_page, $page_no );
5924
+	$posts = geodir_get_export_posts($post_type, $per_page, $page_no);
5925 5925
 
5926 5926
 	$csv_rows = array();
5927 5927
 	
5928
-	if ( !empty( $posts ) ) {
5929
-		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5928
+	if (!empty($posts)) {
5929
+		$is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
5930 5930
 		
5931 5931
 		$csv_row = array();
5932 5932
 		$csv_row[] = 'post_id';
@@ -5937,7 +5937,7 @@  discard block
 block discarded – undo
5937 5937
 		$csv_row[] = 'default_category';
5938 5938
 		$csv_row[] = 'post_tags';
5939 5939
 		$csv_row[] = 'post_type';
5940
-		if ( $post_type == 'gd_event' ) {
5940
+		if ($post_type == 'gd_event') {
5941 5941
 			$csv_row[] = 'event_date';
5942 5942
 			$csv_row[] = 'event_enddate';
5943 5943
 			$csv_row[] = 'starttime';
@@ -5986,15 +5986,15 @@  discard block
 block discarded – undo
5986 5986
 		}
5987 5987
 		// WPML
5988 5988
 
5989
-		$custom_fields = geodir_imex_get_custom_fields( $post_type );
5990
-		if ( !empty( $custom_fields ) ) {
5991
-			foreach ( $custom_fields as $custom_field ) {
5989
+		$custom_fields = geodir_imex_get_custom_fields($post_type);
5990
+		if (!empty($custom_fields)) {
5991
+			foreach ($custom_fields as $custom_field) {
5992 5992
 				$csv_row[] = $custom_field->htmlvar_name;
5993 5993
 			}
5994 5994
 		}
5995 5995
 
5996 5996
 		// Export franchise fields
5997
-		$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5997
+		$is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
5998 5998
 		if ($is_franchise_active) {
5999 5999
 			$csv_row[] = 'gd_is_franchise';
6000 6000
 			$csv_row[] = 'gd_franchise_lock';
@@ -6004,12 +6004,12 @@  discard block
 block discarded – undo
6004 6004
 		$csv_rows[] = $csv_row;
6005 6005
 
6006 6006
 		$images_count = 5;
6007
-        $xx=0;
6008
-		foreach ( $posts as $post ) {$xx++;
6007
+        $xx = 0;
6008
+		foreach ($posts as $post) {$xx++;
6009 6009
 			$post_id = $post['ID'];
6010 6010
 			
6011
-			$gd_post_info = geodir_get_post_info( $post_id );
6012
-			$post_info = (array)$gd_post_info;
6011
+			$gd_post_info = geodir_get_post_info($post_id);
6012
+			$post_info = (array) $gd_post_info;
6013 6013
 						
6014 6014
 			$taxonomy_category = $post_type . 'category';
6015 6015
 			$taxonomy_tags = $post_type . '_tags';
@@ -6018,14 +6018,14 @@  discard block
 block discarded – undo
6018 6018
 			$default_category_id = $gd_post_info->default_category;
6019 6019
 			$default_category = '';
6020 6020
 			$post_tags = '';
6021
-			$terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) );
6021
+			$terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags));
6022 6022
 			
6023
-			if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
6023
+			if (!empty($terms) && !is_wp_error($terms)) {
6024 6024
 				$post_category = array();
6025 6025
 				$post_tags = array();
6026 6026
 			
6027
-				foreach ( $terms as $term ) {
6028
-					if ( $term->taxonomy == $taxonomy_category ) {
6027
+				foreach ($terms as $term) {
6028
+					if ($term->taxonomy == $taxonomy_category) {
6029 6029
 						$post_category[] = $term->name;
6030 6030
 						
6031 6031
 						if ($default_category_id == $term->term_id) {
@@ -6033,7 +6033,7 @@  discard block
 block discarded – undo
6033 6033
 						}
6034 6034
 					}
6035 6035
 					
6036
-					if ( $term->taxonomy == $taxonomy_tags ) {
6036
+					if ($term->taxonomy == $taxonomy_tags) {
6037 6037
 						$post_tags[] = $term->name;
6038 6038
 					}
6039 6039
 				}
@@ -6041,8 +6041,8 @@  discard block
 block discarded – undo
6041 6041
 				if (empty($default_category) && !empty($post_category)) {
6042 6042
 					$default_category = $post_category[0]; // Set first one as default category.
6043 6043
 				}
6044
-				$post_category = !empty( $post_category ) ? implode( ',', $post_category ) : '';
6045
-				$post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : '';
6044
+				$post_category = !empty($post_category) ? implode(',', $post_category) : '';
6045
+				$post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
6046 6046
 			}
6047 6047
 
6048 6048
 			// Franchise data
@@ -6050,42 +6050,42 @@  discard block
 block discarded – undo
6050 6050
 			$franchise_info = array();
6051 6051
 			$locked_fields = array();
6052 6052
 			
6053
-			if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
6053
+			if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
6054 6054
 				$franchise_id = $post_info['franchise'];
6055 6055
 				$gd_franchise_info = geodir_get_post_info($franchise_id);
6056 6056
 
6057 6057
 				if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
6058
-					$franchise_info = (array)$gd_franchise_info;
6058
+					$franchise_info = (array) $gd_franchise_info;
6059 6059
 					$locked_fields = geodir_franchise_get_locked_fields($franchise_id, true);
6060 6060
 					
6061 6061
 					if (!empty($locked_fields)) {
6062
-						foreach( $locked_fields as $locked_field) {
6062
+						foreach ($locked_fields as $locked_field) {
6063 6063
 							if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
6064 6064
 								$post_info[$locked_field] = $franchise_info[$locked_field];
6065 6065
 							}
6066 6066
 							
6067 6067
 							if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
6068
-								$franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) );
6068
+								$franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags));
6069 6069
 			
6070
-								if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
6070
+								if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
6071 6071
 									$franchise_post_category = array();
6072 6072
 									$franchise_post_tags = array();
6073 6073
 								
6074
-									foreach ( $franchise_terms as $franchise_term ) {
6075
-										if ( $franchise_term->taxonomy == $taxonomy_category ) {
6074
+									foreach ($franchise_terms as $franchise_term) {
6075
+										if ($franchise_term->taxonomy == $taxonomy_category) {
6076 6076
 											$franchise_post_category[] = $franchise_term->name;
6077 6077
 										}
6078 6078
 										
6079
-										if ( $franchise_term->taxonomy == $taxonomy_tags ) {
6079
+										if ($franchise_term->taxonomy == $taxonomy_tags) {
6080 6080
 											$franchise_post_tags[] = $franchise_term->name;
6081 6081
 										}
6082 6082
 									}
6083 6083
 									
6084 6084
 									if (in_array($taxonomy_category, $locked_fields)) {
6085
-										$post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : '';
6085
+										$post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
6086 6086
 									}
6087 6087
 									if (in_array('post_tags', $locked_fields)) {
6088
-										$post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : '';
6088
+										$post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
6089 6089
 									}
6090 6090
 								}
6091 6091
 							}
@@ -6094,18 +6094,18 @@  discard block
 block discarded – undo
6094 6094
 				}
6095 6095
 			}
6096 6096
 						
6097
-			$post_images = geodir_get_images( $post_id );
6097
+			$post_images = geodir_get_images($post_id);
6098 6098
 			$current_images = array();
6099
-			if ( !empty( $post_images ) ) {
6100
-				foreach ( $post_images as $post_image ) {
6101
-					$post_image = (array)$post_image;
6102
-					$image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : '';
6103
-					if ( $image ) {
6099
+			if (!empty($post_images)) {
6100
+				foreach ($post_images as $post_image) {
6101
+					$post_image = (array) $post_image;
6102
+					$image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : '';
6103
+					if ($image) {
6104 6104
 						$current_images[] = $image;
6105 6105
 					}
6106 6106
 				}
6107 6107
 				
6108
-				$images_count = max( $images_count, count( $current_images ) );
6108
+				$images_count = max($images_count, count($current_images));
6109 6109
 			}
6110 6110
 
6111 6111
 			$csv_row = array();
@@ -6117,7 +6117,7 @@  discard block
 block discarded – undo
6117 6117
 			$csv_row[] = $default_category; // default_category
6118 6118
 			$csv_row[] = $post_tags; // post_tags
6119 6119
 			$csv_row[] = $post_type; // post_type
6120
-			if ( $post_type == 'gd_event' ) {
6120
+			if ($post_type == 'gd_event') {
6121 6121
 				$event_data = geodir_imex_get_event_data($post, $gd_post_info);
6122 6122
 				$csv_row[] = $event_data['event_date']; // event_date
6123 6123
 				$csv_row[] = $event_data['event_enddate']; // enddate
@@ -6138,9 +6138,9 @@  discard block
 block discarded – undo
6138 6138
 				$csv_row[] = $event_data['recurring_end_date']; // repeat_end
6139 6139
 			}
6140 6140
 			$csv_row[] = $post_info['post_status']; // post_status
6141
-			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
6141
+			$csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured
6142 6142
 			if ($is_payment_plugin) {
6143
-				$csv_row[] = (int)$post_info['package_id']; // package_id
6143
+				$csv_row[] = (int) $post_info['package_id']; // package_id
6144 6144
 				$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
6145 6145
 			}
6146 6146
 			$csv_row[] = $post_info['geodir_video']; // geodir_video
@@ -6161,14 +6161,14 @@  discard block
 block discarded – undo
6161 6161
 			$csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers
6162 6162
 			// WPML
6163 6163
 			if ($is_wpml) {
6164
-				$csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type );
6165
-				$csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type );
6164
+				$csv_row[] = geodir_get_language_for_element($post_id, 'post_' . $post_type);
6165
+				$csv_row[] = geodir_imex_original_post_id($post_id, 'post_' . $post_type);
6166 6166
 			}
6167 6167
 			// WPML
6168 6168
 			
6169
-			if ( !empty( $custom_fields ) ) {
6170
-				foreach ( $custom_fields as $custom_field ) {
6171
-					$csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : '';
6169
+			if (!empty($custom_fields)) {
6170
+				foreach ($custom_fields as $custom_field) {
6171
+					$csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : '';
6172 6172
 				}
6173 6173
 			}
6174 6174
 			
@@ -6179,26 +6179,26 @@  discard block
 block discarded – undo
6179 6179
 				$franchise = '';
6180 6180
 					
6181 6181
 				if (geodir_franchise_pkg_is_active($gd_post_info)) {
6182
-					$gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true );
6183
-					$locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : '';
6182
+					$gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true);
6183
+					$locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : '';
6184 6184
 					$locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
6185
-					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id
6185
+					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id
6186 6186
 				}
6187 6187
 				
6188
-				$csv_row[] = (int)$gd_is_franchise; // gd_is_franchise
6188
+				$csv_row[] = (int) $gd_is_franchise; // gd_is_franchise
6189 6189
 				$csv_row[] = $locaked_fields; // gd_franchise_lock fields
6190
-				$csv_row[] = (int)$franchise; // franchise id
6190
+				$csv_row[] = (int) $franchise; // franchise id
6191 6191
 			}
6192 6192
 			
6193
-			for ( $c = 0; $c < $images_count; $c++ ) {
6194
-				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
6193
+			for ($c = 0; $c < $images_count; $c++) {
6194
+				$csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE
6195 6195
 			}
6196 6196
 			
6197 6197
 			$csv_rows[] = $csv_row;
6198 6198
 
6199 6199
 		}
6200 6200
 
6201
-		for ( $c = 0; $c < $images_count; $c++ ) {
6201
+		for ($c = 0; $c < $images_count; $c++) {
6202 6202
 			$csv_rows[0][] = 'IMAGE';
6203 6203
 		}
6204 6204
 	}
@@ -6220,19 +6220,19 @@  discard block
 block discarded – undo
6220 6220
  * @param int $page_no Page number. Default 0.
6221 6221
  * @return array Array of posts data.
6222 6222
  */
6223
-function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
6223
+function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
6224 6224
 	global $wpdb, $plugin_prefix;
6225 6225
 
6226
-	if ( ! post_type_exists( $post_type ) )
6226
+	if (!post_type_exists($post_type))
6227 6227
 		return new stdClass;
6228 6228
 		
6229 6229
 	$table = $plugin_prefix . $post_type . '_detail';
6230 6230
 	
6231 6231
 	$limit = '';
6232
-	if ( $per_page > 0 && $page_no > 0 ) {
6233
-		$offset = ( $page_no - 1 ) * $per_page;
6232
+	if ($per_page > 0 && $page_no > 0) {
6233
+		$offset = ($page_no - 1) * $per_page;
6234 6234
 		
6235
-		if ( $offset > 0 ) {
6235
+		if ($offset > 0) {
6236 6236
 			$limit = " LIMIT " . $offset . "," . $per_page;
6237 6237
 		} else {
6238 6238
 			$limit = " LIMIT " . $per_page;
@@ -6249,9 +6249,9 @@  discard block
 block discarded – undo
6249 6249
 	 * @param int $query The SQL query.
6250 6250
 	 * @param string $post_type Post type.
6251 6251
 	 */
6252
-	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
6252
+	$query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
6253 6253
 
6254
-	$results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
6254
+	$results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A);
6255 6255
 
6256 6256
 	/**
6257 6257
 	 * Modify returned post results for the current post type.
@@ -6262,7 +6262,7 @@  discard block
 block discarded – undo
6262 6262
 	 * @param object $results An object containing all post ids.
6263 6263
 	 * @param string $post_type Post type.
6264 6264
 	 */
6265
-	return apply_filters( 'geodir_export_posts', $results, $post_type );
6265
+	return apply_filters('geodir_export_posts', $results, $post_type);
6266 6266
 }
6267 6267
 
6268 6268
 /**
@@ -6279,8 +6279,8 @@  discard block
 block discarded – undo
6279 6279
  * @param string $post_type Post type.
6280 6280
  * @return string The SQL query.
6281 6281
  */
6282
-function geodir_imex_get_events_query( $query, $post_type ) {
6283
-	if ( $post_type == 'gd_event' ) {
6282
+function geodir_imex_get_events_query($query, $post_type) {
6283
+	if ($post_type == 'gd_event') {
6284 6284
 		global $wpdb, $plugin_prefix;
6285 6285
 		
6286 6286
 		$table = $plugin_prefix . $post_type . '_detail';
@@ -6301,15 +6301,15 @@  discard block
 block discarded – undo
6301 6301
  * @param  string $post_type Post type.
6302 6302
  * @return int Total terms count.
6303 6303
  */
6304
-function geodir_get_terms_count( $post_type ) {
6305
-	$args = array( 'hide_empty' => 0 );
6304
+function geodir_get_terms_count($post_type) {
6305
+	$args = array('hide_empty' => 0);
6306 6306
 	
6307
-	remove_all_filters( 'get_terms' );
6307
+	remove_all_filters('get_terms');
6308 6308
 	
6309 6309
 	$taxonomy = $post_type . 'category';
6310 6310
 
6311
-	$count_terms = wp_count_terms( $taxonomy, $args );
6312
-	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
6311
+	$count_terms = wp_count_terms($taxonomy, $args);
6312
+	$count_terms = !is_wp_error($count_terms) ? $count_terms : 0;
6313 6313
 	 
6314 6314
 	return $count_terms;
6315 6315
 }
@@ -6326,23 +6326,23 @@  discard block
 block discarded – undo
6326 6326
  * @param int $page_no Page number. Default 0.
6327 6327
  * @return array Array of terms data.
6328 6328
  */
6329
-function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
6330
-	$args = array( 'hide_empty' => 0, 'orderby' => 'id' );
6329
+function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
6330
+	$args = array('hide_empty' => 0, 'orderby' => 'id');
6331 6331
 	
6332
-	remove_all_filters( 'get_terms' );
6332
+	remove_all_filters('get_terms');
6333 6333
 	
6334 6334
 	$taxonomy = $post_type . 'category';
6335 6335
 	
6336
-	if ( $per_page > 0 && $page_no > 0 ) {
6337
-		$args['offset'] = ( $page_no - 1 ) * $per_page;
6336
+	if ($per_page > 0 && $page_no > 0) {
6337
+		$args['offset'] = ($page_no - 1) * $per_page;
6338 6338
 		$args['number'] = $per_page;
6339 6339
 	}
6340 6340
 	
6341
-	$terms = get_terms( $taxonomy, $args );
6341
+	$terms = get_terms($taxonomy, $args);
6342 6342
 
6343 6343
 	$csv_rows = array();
6344 6344
 	
6345
-	if ( !empty( $terms ) ) {
6345
+	if (!empty($terms)) {
6346 6346
 		$csv_row = array();
6347 6347
 		$csv_row[] = 'cat_id';
6348 6348
 		$csv_row[] = 'cat_name';
@@ -6363,16 +6363,16 @@  discard block
 block discarded – undo
6363 6363
 		
6364 6364
 		$csv_rows[] = $csv_row;
6365 6365
 		
6366
-		foreach ( $terms as $term ) {			
6367
-			$cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type );
6368
-			$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
6366
+		foreach ($terms as $term) {			
6367
+			$cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type);
6368
+			$cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
6369 6369
 			
6370
-			$cat_image = geodir_get_default_catimage( $term->term_id, $post_type );
6371
-			$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; 
6370
+			$cat_image = geodir_get_default_catimage($term->term_id, $post_type);
6371
+			$cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; 
6372 6372
 			
6373 6373
 			$cat_parent = '';
6374
-			if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
6375
-				$parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy );
6374
+			if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
6375
+				$parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
6376 6376
 				$cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : '';
6377 6377
 			}
6378 6378
 			
@@ -6382,14 +6382,14 @@  discard block
 block discarded – undo
6382 6382
 			$csv_row[] = $term->slug;
6383 6383
 			$csv_row[] = $post_type;
6384 6384
 			$csv_row[] = $cat_parent;
6385
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
6385
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type);
6386 6386
 			$csv_row[] = $term->description;
6387
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type );
6387
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type);
6388 6388
 			$csv_row[] = $cat_image;
6389 6389
 			$csv_row[] = $cat_icon;
6390 6390
 			// WPML
6391 6391
 			if ($is_wpml) {
6392
-				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
6392
+				$csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_' . $taxonomy);
6393 6393
 			}
6394 6394
 			// WPML
6395 6395
 			
@@ -6408,7 +6408,7 @@  discard block
 block discarded – undo
6408 6408
  * @param  bool $relative True for relative path & False for absolute path.
6409 6409
  * @return string Path to the cache directory.
6410 6410
  */
6411
-function geodir_path_import_export( $relative = true ) {
6411
+function geodir_path_import_export($relative = true) {
6412 6412
 	$upload_dir = wp_upload_dir();
6413 6413
 	
6414 6414
 	return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache';
@@ -6427,8 +6427,8 @@  discard block
 block discarded – undo
6427 6427
  * @param  bool $clear If true then it overwrite data otherwise add rows at the end of file.
6428 6428
  * @return bool true if success otherwise false.
6429 6429
  */
6430
-function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
6431
-	if ( empty( $csv_data ) ) {
6430
+function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
6431
+	if (empty($csv_data)) {
6432 6432
 		return false;
6433 6433
 	}
6434 6434
 	
@@ -6436,17 +6436,17 @@  discard block
 block discarded – undo
6436 6436
 	
6437 6437
 	$mode = $clear ? 'w+' : 'a+';
6438 6438
 	
6439
-	if ( function_exists( 'fputcsv' ) ) {
6440
-		$file = fopen( $file_path, $mode );
6441
-		foreach( $csv_data as $csv_row ) {
6439
+	if (function_exists('fputcsv')) {
6440
+		$file = fopen($file_path, $mode);
6441
+		foreach ($csv_data as $csv_row) {
6442 6442
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
6443
-			$write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' );
6443
+			$write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"');
6444 6444
 		}
6445
-		fclose( $file );
6445
+		fclose($file);
6446 6446
 	} else {
6447
-		foreach( $csv_data as $csv_row ) {
6447
+		foreach ($csv_data as $csv_row) {
6448 6448
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
6449
-			$wp_filesystem->put_contents( $file_path, $csv_row );
6449
+			$wp_filesystem->put_contents($file_path, $csv_row);
6450 6450
 		}
6451 6451
 	}
6452 6452
 		
@@ -6464,14 +6464,14 @@  discard block
 block discarded – undo
6464 6464
  * @param  string $file Full path to file.
6465 6465
  * @return int No of file rows.
6466 6466
  */
6467
-function geodir_import_export_line_count( $file ) {
6467
+function geodir_import_export_line_count($file) {
6468 6468
 	global $wp_filesystem;
6469 6469
 	
6470
-	if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
6471
-		$contents = $wp_filesystem->get_contents_array( $file );
6470
+	if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
6471
+		$contents = $wp_filesystem->get_contents_array($file);
6472 6472
 		
6473
-		if ( !empty( $contents ) && is_array( $contents ) ) {
6474
-			return count( $contents ) - 1;
6473
+		if (!empty($contents) && is_array($contents)) {
6474
+			return count($contents) - 1;
6475 6475
 		}
6476 6476
 	}
6477 6477
 	
@@ -6488,11 +6488,11 @@  discard block
 block discarded – undo
6488 6488
  * @param string $post_type The post type.
6489 6489
  * @return object Queried object.
6490 6490
  */
6491
-function geodir_imex_get_custom_fields( $post_type ) {
6491
+function geodir_imex_get_custom_fields($post_type) {
6492 6492
 	global $wpdb;
6493 6493
 	 
6494
-	$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 ) );
6495
-	$rows = $wpdb->get_results( $sql );
6494
+	$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));
6495
+	$rows = $wpdb->get_results($sql);
6496 6496
 	 
6497 6497
 	return $rows;
6498 6498
 }
@@ -6574,9 +6574,9 @@  discard block
 block discarded – undo
6574 6574
 	$post_table = $plugin_prefix . $post_type . '_detail';
6575 6575
 	
6576 6576
 	$query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
6577
-	$data = (array)$wpdb->get_row($query);
6577
+	$data = (array) $wpdb->get_row($query);
6578 6578
 	
6579
-	if ( !empty( $data ) ) {
6579
+	if (!empty($data)) {
6580 6580
 		$data['post_id'] = $tr_post_id;
6581 6581
 		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
6582 6582
 		
@@ -6604,7 +6604,7 @@  discard block
 block discarded – undo
6604 6604
 	global $sitepress, $wpdb;
6605 6605
 	$post_type = get_post_type($master_post_id);
6606 6606
 	
6607
-	remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
6607
+	remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
6608 6608
 
6609 6609
 	$taxonomies = get_object_taxonomies($post_type);
6610 6610
 	foreach ($taxonomies as $taxonomy) {
@@ -6613,9 +6613,9 @@  discard block
 block discarded – undo
6613 6613
 		
6614 6614
 		if ($terms) {
6615 6615
 			foreach ($terms as $term) {
6616
-				$tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
6616
+				$tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
6617 6617
 				
6618
-				if (!is_null($tr_id)){
6618
+				if (!is_null($tr_id)) {
6619 6619
 					// not using get_term - unfiltered get_term
6620 6620
 					$translated_term = $wpdb->get_row($wpdb->prepare("
6621 6621
 						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));
@@ -6624,8 +6624,8 @@  discard block
 block discarded – undo
6624 6624
 				}
6625 6625
 			}
6626 6626
 
6627
-			if (!is_taxonomy_hierarchical($taxonomy)){
6628
-				$terms_array = array_unique( array_map( 'intval', $terms_array ) );
6627
+			if (!is_taxonomy_hierarchical($taxonomy)) {
6628
+				$terms_array = array_unique(array_map('intval', $terms_array));
6629 6629
 			}
6630 6630
 
6631 6631
 			wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
@@ -6658,9 +6658,9 @@  discard block
 block discarded – undo
6658 6658
 	$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));
6659 6659
 	$post_images = $wpdb->get_results($query);
6660 6660
 	
6661
-	if ( !empty( $post_images ) ) {
6662
-		foreach ( $post_images as $post_image) {
6663
-			$image_data = (array)$post_image;
6661
+	if (!empty($post_images)) {
6662
+		foreach ($post_images as $post_image) {
6663
+			$image_data = (array) $post_image;
6664 6664
 			unset($image_data['ID']);
6665 6665
 			$image_data['post_id'] = $tr_post_id;
6666 6666
 			
@@ -6686,10 +6686,10 @@  discard block
 block discarded – undo
6686 6686
  * @return array Event data array.
6687 6687
  */
6688 6688
 function geodir_imex_get_event_data($post, $gd_post_info) {
6689
-	$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'] ) ) : '';
6689
+	$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'])) : '';
6690 6690
 	$event_enddate = $event_date;
6691
-	$starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : '';
6692
-	$endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : '';
6691
+	$starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
6692
+	$endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
6693 6693
 	
6694 6694
 	$is_recurring_event = '';
6695 6695
 	$event_duration_days = '';
@@ -6707,15 +6707,15 @@  discard block
 block discarded – undo
6707 6707
 		
6708 6708
 	$recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array();
6709 6709
 	if (!empty($recurring_data)) {
6710
-		$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;
6711
-		$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;
6712
-		$starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime;
6713
-		$endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime;
6710
+		$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;
6711
+		$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;
6712
+		$starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
6713
+		$endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
6714 6714
 		$is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : '';
6715 6715
 		$different_times = !empty($recurring_data['different_times']) ? true : false;
6716 6716
 	
6717
-		$recurring_pkg = geodir_event_recurring_pkg( $gd_post_info );
6718
-		$is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true;
6717
+		$recurring_pkg = geodir_event_recurring_pkg($gd_post_info);
6718
+		$is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true;
6719 6719
 			
6720 6720
 		if ($recurring_pkg && $is_recurring) {
6721 6721
 			$recurring_dates = $event_date;
@@ -6725,13 +6725,13 @@  discard block
 block discarded – undo
6725 6725
 			$recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
6726 6726
 			
6727 6727
 			if (!empty($recurring_data['event_recurring_dates'])) {
6728
-				$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
6728
+				$event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
6729 6729
 				
6730 6730
 				if (!empty($event_recurring_dates)) {
6731 6731
 					$recurring_dates = array();
6732 6732
 					
6733 6733
 					foreach ($event_recurring_dates as $date) {
6734
-						$recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) );
6734
+						$recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
6735 6735
 					}
6736 6736
 					
6737 6737
 					$recurring_dates = implode(",", $recurring_dates);
@@ -6747,7 +6747,7 @@  discard block
 block discarded – undo
6747 6747
 						$times = array();
6748 6748
 						
6749 6749
 						foreach ($recurring_data['starttimes'] as $time) {
6750
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6750
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6751 6751
 						}
6752 6752
 						
6753 6753
 						$event_starttimes = implode(",", $times);
@@ -6757,7 +6757,7 @@  discard block
 block discarded – undo
6757 6757
 						$times = array();
6758 6758
 						
6759 6759
 						foreach ($recurring_data['endtimes'] as $time) {
6760
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6760
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6761 6761
 						}
6762 6762
 						
6763 6763
 						$event_endtimes = implode(",", $times);
@@ -6769,8 +6769,8 @@  discard block
 block discarded – undo
6769 6769
 					}
6770 6770
 				}
6771 6771
 			} else {
6772
-				$event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1;
6773
-				$recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6772
+				$event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1;
6773
+				$recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6774 6774
 				
6775 6775
 				if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
6776 6776
 					$week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
@@ -6786,11 +6786,11 @@  discard block
 block discarded – undo
6786 6786
 				}
6787 6787
 				
6788 6788
 				$recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
6789
-				if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
6790
-					$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'] ) ) : '';
6789
+				if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
6790
+					$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'])) : '';
6791 6791
 					$max_recurring_count = empty($recurring_end_date) ? 1 : '';
6792 6792
 				} else {
6793
-					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1);
6793
+					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1);
6794 6794
 				}
6795 6795
 			}
6796 6796
 		}
@@ -6854,9 +6854,9 @@  discard block
 block discarded – undo
6854 6854
  * @return array Event data array.
6855 6855
  */
6856 6856
 function geodir_imex_process_event_data($gd_post) {
6857
-	$recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post );
6857
+	$recurring_pkg = geodir_event_recurring_pkg((object) $gd_post);
6858 6858
 
6859
-	$is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true;
6859
+	$is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true;
6860 6860
 	$event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : '';
6861 6861
 	$event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date;
6862 6862
 	$all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false;
@@ -6903,17 +6903,17 @@  discard block
 block discarded – undo
6903 6903
 				$event_recurring_dates = implode(",", $event_recurring_dates);
6904 6904
 			}
6905 6905
 		} else {
6906
-			$duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1;
6907
-			$repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1;
6908
-			$max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1;
6909
-			$repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6906
+			$duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1;
6907
+			$repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1;
6908
+			$max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1;
6909
+			$repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6910 6910
 			
6911 6911
 			$repeat_end_type = $repeat_end != '' ? 1 : 0;
6912 6912
 			$max_repeat = $repeat_end != '' ? '' : $max_repeat;
6913 6913
 			
6914 6914
 			$week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
6915 6915
 			
6916
-			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6916
+			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6917 6917
 			$repeat_days = array();
6918 6918
 			if (!empty($a_repeat_days)) {
6919 6919
 				foreach ($a_repeat_days as $repeat_day) {
@@ -6931,7 +6931,7 @@  discard block
 block discarded – undo
6931 6931
 			$repeat_weeks = array();
6932 6932
 			if (!empty($a_repeat_weeks)) {
6933 6933
 				foreach ($a_repeat_weeks as $repeat_week) {
6934
-					$repeat_weeks[] = (int)$repeat_week;
6934
+					$repeat_weeks[] = (int) $repeat_week;
6935 6935
 				}
6936 6936
 				
6937 6937
 				$repeat_weeks = array_unique($repeat_weeks);
@@ -7052,7 +7052,7 @@  discard block
 block discarded – undo
7052 7052
  */
7053 7053
 function geodir_admin_upgrade_notice() {
7054 7054
     $class = "error";
7055
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
7055
+    $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
7056 7056
     echo"<div class=\"$class\"> <p>$message</p></div>";
7057 7057
 }
7058 7058
 
@@ -7067,7 +7067,7 @@  discard block
 block discarded – undo
7067 7067
  * @param (object) $r
7068 7068
  * @return (string) $output
7069 7069
  */
7070
-function geodire_admin_upgrade_notice( $plugin_data, $r )
7070
+function geodire_admin_upgrade_notice($plugin_data, $r)
7071 7071
 {
7072 7072
     // readme contents
7073 7073
     $args = array(
@@ -7075,7 +7075,7 @@  discard block
 block discarded – undo
7075 7075
         'redirection' => 5
7076 7076
     );
7077 7077
     $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
7078
-    $data       = wp_remote_get( $url, $args );
7078
+    $data = wp_remote_get($url, $args);
7079 7079
 
7080 7080
     if (!is_wp_error($data) && $data['response']['code'] == 200) {
7081 7081
 
@@ -7090,20 +7090,20 @@  discard block
 block discarded – undo
7090 7090
 function geodir_in_plugin_update_message($content) {
7091 7091
     // Output Upgrade Notice
7092 7092
     $matches        = null;
7093
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
7093
+    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote(GEODIRECTORY_VERSION) . '\s*=|$)~Uis';
7094 7094
     $upgrade_notice = '';
7095
-    if ( preg_match( $regexp, $content, $matches ) ) {
7096
-        if(empty($matches)){return;}
7095
+    if (preg_match($regexp, $content, $matches)) {
7096
+        if (empty($matches)) {return; }
7097 7097
         //print_r($matches );
7098
-        $version = trim( $matches[1] );
7099
-        if($version && $version>GEODIRECTORY_VERSION){
7098
+        $version = trim($matches[1]);
7099
+        if ($version && $version > GEODIRECTORY_VERSION) {
7100 7100
 
7101 7101
 
7102
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
7103
-        if ( version_compare( WC_VERSION, $version, '<' ) ) {
7102
+        $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
7103
+        if (version_compare(WC_VERSION, $version, '<')) {
7104 7104
             $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
7105
-            foreach ( $notices as $index => $line ) {
7106
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
7105
+            foreach ($notices as $index => $line) {
7106
+                $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
7107 7107
             }
7108 7108
             $upgrade_notice .= '</div> ';
7109 7109
         }
@@ -7127,7 +7127,7 @@  discard block
 block discarded – undo
7127 7127
 		$default_language = $sitepress->get_default_language();
7128 7128
 		if ($current_language != 'all' && $current_language != $default_language) {
7129 7129
 	?>
7130
-	<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>
7130
+	<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>
7131 7131
 	<?php
7132 7132
 		}
7133 7133
 	}
Please login to merge, or discard this patch.
Braces   +240 added lines, -133 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
                 }
@@ -663,10 +675,11 @@  discard block
 block discarded – undo
663 675
                     }
664 676
 
665 677
 
666
-                    if (geodir_dummy_folder_exists())
667
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
668
-                    else
669
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
678
+                    if (geodir_dummy_folder_exists()) {
679
+                                            $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
680
+                    } else {
681
+                                            $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
682
+                    }
670 683
                     $catname = str_replace(' ', '_', $catname);
671 684
                     $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
672 685
 
@@ -704,10 +717,11 @@  discard block
 block discarded – undo
704 717
             if (!term_exists($catname, 'gd_placecategory')) {
705 718
                 $last_catid = wp_insert_term($catname, 'gd_placecategory');
706 719
 
707
-                if (geodir_dummy_folder_exists())
708
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
709
-                else
710
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
720
+                if (geodir_dummy_folder_exists()) {
721
+                                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
722
+                } else {
723
+                                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
724
+                }
711 725
                 $catname = str_replace(' ', '_', $catname);
712 726
                 $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
713 727
 
@@ -759,11 +773,14 @@  discard block
 block discarded – undo
759 773
 {
760 774
    // print_r($_POST);    print_r($options);    exit;
761 775
 
762
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
776
+    if ((!isset($_POST) || !$_POST) && !$dummy) {
777
+    	return false;
778
+    }
763 779
 
764 780
     foreach ($options as $value) {
765
-        if ($dummy && isset($value['std']))
766
-            $_POST[$value['id']] = $value['std'];
781
+        if ($dummy && isset($value['std'])) {
782
+                    $_POST[$value['id']] = $value['std'];
783
+        }
767 784
 
768 785
 
769 786
         if (isset($value['type']) && $value['type'] == 'checkbox') :
@@ -772,25 +789,23 @@  discard block
 block discarded – undo
772 789
                 update_option($value['id'], $_POST[$value['id']]);
773 790
             } else {
774 791
                 update_option($value['id'], 0);
775
-            }
776
-
777
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
792
+            } elseif (isset($value['type']) && $value['type'] == 'image_width') :
778 793
 
779 794
             if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
780 795
                 update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
781 796
                 update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
782 797
                 if (isset($_POST[$value['id'] . '_crop'])) :
783 798
                     update_option($value['id'] . '_crop', 1);
784
-                else :
785
-                    update_option($value['id'] . '_crop', 0);
799
+                else {
800
+                	:
801
+                    update_option($value['id'] . '_crop', 0);
802
+                }
786 803
                 endif;
787 804
             } else {
788 805
                 update_option($value['id'] . '_width', $value['std']);
789 806
                 update_option($value['id'] . '_height', $value['std']);
790 807
                 update_option($value['id'] . '_crop', 1);
791
-            }
792
-
793
-        elseif (isset($value['type']) && $value['type'] == 'map') :
808
+            } elseif (isset($value['type']) && $value['type'] == 'map') :
794 809
             $post_types = array();
795 810
             $categories = array();
796 811
             $i = 0;
@@ -836,8 +851,9 @@  discard block
 block discarded – undo
836 851
                     $image_name_arr = explode('/', get_option($value['id']));
837 852
                     $noimg_name = end($image_name_arr);
838 853
                     $img_path = $uploads['path'] . '/' . $noimg_name;
839
-                    if (file_exists($img_path))
840
-                        unlink($img_path);
854
+                    if (file_exists($img_path)) {
855
+                                            unlink($img_path);
856
+                    }
841 857
                 }
842 858
 
843 859
                 update_option($value['id'], '');
@@ -853,8 +869,10 @@  discard block
 block discarded – undo
853 869
                 foreach ($uploadedfile as $key => $uplaod):
854 870
                     if ($key == 'name'):
855 871
                         $uplaods[$key] = $filename;
856
-                    else :
857
-                        $uplaods[$key] = $uplaod;
872
+                    else {
873
+                    	:
874
+                        $uplaods[$key] = $uplaod;
875
+                    }
858 876
                     endif;
859 877
                 endforeach;
860 878
 
@@ -864,8 +882,9 @@  discard block
 block discarded – undo
864 882
                     $image_name_arr = explode('/', get_option($value['id']));
865 883
                     $noimg_name = end($image_name_arr);
866 884
                     $img_path = $uploads['path'] . '/' . $noimg_name;
867
-                    if (file_exists($img_path))
868
-                        unlink($img_path);
885
+                    if (file_exists($img_path)) {
886
+                                            unlink($img_path);
887
+                    }
869 888
                 }
870 889
 
871 890
                 $upload_overrides = array('test_form' => false);
@@ -880,10 +899,12 @@  discard block
 block discarded – undo
880 899
             endif;
881 900
 
882 901
 
883
-        else :
902
+        else {
903
+        	:
884 904
             // same menu setting per theme.
885 905
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
886
-                $theme = wp_get_theme();
906
+                $theme = wp_get_theme();
907
+        }
887 908
                 update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
888 909
             }
889 910
 
@@ -895,8 +916,9 @@  discard block
 block discarded – undo
895 916
 
896 917
         endif;
897 918
     }
898
-    if ($dummy)
899
-        unset($_POST);
919
+    if ($dummy) {
920
+            unset($_POST);
921
+    }
900 922
     return true;
901 923
 
902 924
 }
@@ -1041,9 +1063,12 @@  discard block
 block discarded – undo
1041 1063
         $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1042 1064
             'categorys' => __('Categories', 'geodirectory'));
1043 1065
 
1044
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1066
+        if (($offset = array_search('author', array_keys($columns))) === false) {
1067
+        	// if the key doesn't exist
1045 1068
         {
1046
-            $offset = 0; // should we prepend $array with $data?
1069
+            $offset = 0;
1070
+        }
1071
+        // should we prepend $array with $data?
1047 1072
             $offset = count($columns); // or should we append $array with $data? lets pick this one...
1048 1073
         }
1049 1074
 
@@ -1103,11 +1128,13 @@  discard block
 block discarded – undo
1103 1128
                     $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1104 1129
                 }
1105 1130
                 /* If no expire_date is found, output a default message. */
1106
-                if (empty($expire_date))
1107
-                    echo __('Unknown', 'geodirectory');
1131
+                if (empty($expire_date)) {
1132
+                                    echo __('Unknown', 'geodirectory');
1133
+                }
1108 1134
                 /* If there is a expire_date, append 'days left' to the text string. */
1109
-                else
1110
-                    echo $expire_date . $date_diff_text;
1135
+                else {
1136
+                                    echo $expire_date . $date_diff_text;
1137
+                }
1111 1138
                 break;
1112 1139
 
1113 1140
             /* If displaying the 'categorys' column. */
@@ -1180,21 +1207,26 @@  discard block
 block discarded – undo
1180 1207
 
1181 1208
     $geodir_posttypes = geodir_get_posttypes();
1182 1209
 
1183
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1184
-        return;
1210
+    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1211
+            return;
1212
+    }
1185 1213
 
1186 1214
     if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1187
-        if (isset($_REQUEST['_status']))
1188
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1215
+        if (isset($_REQUEST['_status'])) {
1216
+                    geodir_change_post_status($post_id, $_REQUEST['_status']);
1217
+        }
1189 1218
 
1190
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1191
-            return;
1219
+        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) {
1220
+                    return;
1221
+        }
1192 1222
 
1193
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1194
-            return;
1223
+        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) {
1224
+                    return;
1225
+        }
1195 1226
 
1196
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1197
-            return;
1227
+        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) {
1228
+                    return;
1229
+        }
1198 1230
 
1199 1231
         geodir_save_listing($_REQUEST);
1200 1232
     }
@@ -2002,8 +2034,9 @@  discard block
 block discarded – undo
2002 2034
                                         'geo_lng' => $post_longitude);
2003 2035
 
2004 2036
                                     $post_location_info = $request_info['post_location'];
2005
-                                    if ($location_id = geodir_add_new_location($post_location_info))
2006
-                                        $post_location_id = $location_id;
2037
+                                    if ($location_id = geodir_add_new_location($post_location_info)) {
2038
+                                                                            $post_location_id = $location_id;
2039
+                                    }
2007 2040
 
2008 2041
                                 } else {
2009 2042
                                     $post_location_id = 0;
@@ -2067,8 +2100,9 @@  discard block
 block discarded – undo
2067 2100
                                     $attachment_set = '';
2068 2101
 
2069 2102
                                     foreach ($attachment as $key => $val) {
2070
-                                        if ($val != '')
2071
-                                            $attachment_set .= $key . " = '" . $val . "', ";
2103
+                                        if ($val != '') {
2104
+                                                                                    $attachment_set .= $key . " = '" . $val . "', ";
2105
+                                        }
2072 2106
                                     }
2073 2107
 
2074 2108
                                     $attachment_set = trim($attachment_set, ", ");
@@ -2118,8 +2152,9 @@  discard block
 block discarded – undo
2118 2152
                 fclose($fd);
2119 2153
                 //unlink($csv_target_path);
2120 2154
                 //rmdir($destination_path);
2121
-                if (!empty($filename))
2122
-                    geodir_remove_temp_images();
2155
+                if (!empty($filename)) {
2156
+                                    geodir_remove_temp_images();
2157
+                }
2123 2158
 
2124 2159
 
2125 2160
                 echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&msg=success&rowcount=' . $countpost . '&invalidcount=' . $address_invalid . '&blank_address=' . $blank_address . '&upload_files=' . $upload_files . '&invalid_post_type=' . $invalid_post_type . '&invalid_title=' . $invalid_title . '&total_records=' . $total_records;
@@ -2152,10 +2187,18 @@  discard block
 block discarded – undo
2152 2187
     $tab_id = '';
2153 2188
     $i = 0;
2154 2189
     foreach ($options as $value) :
2155
-        if (!isset($value['name'])) $value['name'] = '';
2156
-        if (!isset($value['class'])) $value['class'] = '';
2157
-        if (!isset($value['css'])) $value['css'] = '';
2158
-        if (!isset($value['std'])) $value['std'] = '';
2190
+        if (!isset($value['name'])) {
2191
+        	$value['name'] = '';
2192
+        }
2193
+        if (!isset($value['class'])) {
2194
+        	$value['class'] = '';
2195
+        }
2196
+        if (!isset($value['css'])) {
2197
+        	$value['css'] = '';
2198
+        }
2199
+        if (!isset($value['std'])) {
2200
+        	$value['std'] = '';
2201
+        }
2159 2202
         $desc = '';
2160 2203
         switch ($value['type']) :
2161 2204
             case 'dummy_installer':
@@ -2174,11 +2217,13 @@  discard block
 block discarded – undo
2174 2217
 
2175 2218
                 $i++;
2176 2219
 
2177
-                if (isset($value['id']) && $value['id'])
2178
-                    $tab_id = $value['id'];
2220
+                if (isset($value['id']) && $value['id']) {
2221
+                                    $tab_id = $value['id'];
2222
+                }
2179 2223
 
2180
-                if (isset($value['desc']) && $value['desc'])
2181
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
2224
+                if (isset($value['desc']) && $value['desc']) {
2225
+                                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
2226
+                }
2182 2227
 
2183 2228
                 if (isset($value['name']) && $value['name']) {
2184 2229
                     if ($first_title === true) {
@@ -2209,10 +2254,12 @@  discard block
 block discarded – undo
2209 2254
                 break;
2210 2255
 
2211 2256
             case 'sectionstart':
2212
-                if (isset($value['desc']) && $value['desc'])
2213
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
2214
-                if (isset($value['name']) && $value['name'])
2215
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
2257
+                if (isset($value['desc']) && $value['desc']) {
2258
+                                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
2259
+                }
2260
+                if (isset($value['name']) && $value['name']) {
2261
+                                    echo '<h3>' . $value['name'] . $desc . '</h3>';
2262
+                }
2216 2263
                 /**
2217 2264
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
2218 2265
                  *
@@ -2220,7 +2267,9 @@  discard block
 block discarded – undo
2220 2267
                  *
2221 2268
                  * @since 1.0.0
2222 2269
                  */
2223
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
2270
+                if (isset($value['id']) && $value['id']) {
2271
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
2272
+                }
2224 2273
                 echo '<table class="form-table">' . "\n\n";
2225 2274
 
2226 2275
                 break;
@@ -2232,7 +2281,9 @@  discard block
 block discarded – undo
2232 2281
                  *
2233 2282
                  * @since 1.0.0
2234 2283
                  */
2235
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
2284
+                if (isset($value['id']) && $value['id']) {
2285
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
2286
+                }
2236 2287
                 echo '</table>';
2237 2288
                 /**
2238 2289
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -2241,7 +2292,9 @@  discard block
 block discarded – undo
2241 2292
                  *
2242 2293
                  * @since 1.0.0
2243 2294
                  */
2244
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
2295
+                if (isset($value['id']) && $value['id']) {
2296
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
2297
+                }
2245 2298
                 break;
2246 2299
             case 'text':
2247 2300
                 ?>
@@ -2313,17 +2366,32 @@  discard block
 block discarded – undo
2313 2366
                     <?php _e('Width', 'geodirectory'); ?> <input
2314 2367
                         name="<?php echo esc_attr($value['id']); ?>_width"
2315 2368
                         id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3"
2316
-                        value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
2369
+                        value="<?php if ($size = get_option($value['id'] . '_width')) {
2370
+	echo stripslashes($size);
2371
+} else {
2372
+	echo $value['std'];
2373
+}
2374
+?>"/>
2317 2375
 
2318 2376
                     <?php _e('Height', 'geodirectory'); ?> <input
2319 2377
                         name="<?php echo esc_attr($value['id']); ?>_height"
2320 2378
                         id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3"
2321
-                        value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
2379
+                        value="<?php if ($size = get_option($value['id'] . '_height')) {
2380
+	echo stripslashes($size);
2381
+} else {
2382
+	echo $value['std'];
2383
+}
2384
+?>"/>
2322 2385
 
2323 2386
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
2324 2387
                             name="<?php echo esc_attr($value['id']); ?>_crop"
2325 2388
                             id="<?php echo esc_attr($value['id']); ?>_crop"
2326
-                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label>
2389
+                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') {
2390
+	checked(get_option($value['id'] . '_crop'), 1);
2391
+} else {
2392
+	checked(1);
2393
+}
2394
+?> /></label>
2327 2395
 
2328 2396
                     <span class="description"><?php echo $value['desc'] ?></span></td>
2329 2397
                 </tr><?php
@@ -2335,17 +2403,22 @@  discard block
 block discarded – undo
2335 2403
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
2336 2404
                                             id="<?php echo esc_attr($value['id']); ?>"
2337 2405
                                             style="<?php echo esc_attr($value['css']); ?>"
2338
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
2406
+                                            class="<?php if (isset($value['class'])) {
2407
+	echo $value['class'];
2408
+}
2409
+?>"
2339 2410
                                             option-ajaxchosen="false">
2340 2411
                         <?php
2341 2412
                         foreach ($value['options'] as $key => $val) {
2342 2413
                             $geodir_select_value = '';
2343 2414
                             if (get_option($value['id']) != '') {
2344
-                                if (get_option($value['id']) != '' && get_option($value['id']) == $key)
2345
-                                    $geodir_select_value = ' selected="selected" ';
2415
+                                if (get_option($value['id']) != '' && get_option($value['id']) == $key) {
2416
+                                                                    $geodir_select_value = ' selected="selected" ';
2417
+                                }
2346 2418
                             } else {
2347
-                                if ($value['std'] == $key)
2348
-                                    $geodir_select_value = ' selected="selected" ';
2419
+                                if ($value['std'] == $key) {
2420
+                                                                    $geodir_select_value = ' selected="selected" ';
2421
+                                }
2349 2422
                             }
2350 2423
 
2351 2424
 
@@ -2367,8 +2440,14 @@  discard block
 block discarded – undo
2367 2440
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
2368 2441
                                             id="<?php echo esc_attr($value['id']); ?>"
2369 2442
                                             style="<?php echo esc_attr($value['css']); ?>"
2370
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
2371
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
2443
+                                            class="<?php if (isset($value['class'])) {
2444
+	echo $value['class'];
2445
+}
2446
+?>"
2447
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) {
2448
+	echo $value['placeholder_text'];
2449
+}
2450
+?>"
2372 2451
                                             option-ajaxchosen="false">
2373 2452
                         <?php
2374 2453
                         foreach ($value['options'] as $key => $val) {
@@ -2397,7 +2476,10 @@  discard block
 block discarded – undo
2397 2476
                 <td class="forminp">
2398 2477
                     <input type="file" name="<?php echo esc_attr($value['id']); ?>"
2399 2478
                            id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>"
2400
-                           class="<?php if (isset($value['class'])) echo $value['class']; ?>"/>
2479
+                           class="<?php if (isset($value['class'])) {
2480
+	echo $value['class'];
2481
+}
2482
+?>"/>
2401 2483
                     <?php if (get_option($value['id'])) { ?>
2402 2484
                         <input type="hidden" name="<?php echo esc_attr($value['id']); ?>_remove"
2403 2485
                                id="<?php echo esc_attr($value['id']); ?>_remove" value="0">
@@ -2478,13 +2560,15 @@  discard block
 block discarded – undo
2478 2560
                                 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
2479 2561
                             );
2480 2562
                             $geodir_default_map_language = get_option('geodir_default_map_language');
2481
-                            if (empty($geodir_default_map_language))
2482
-                                $geodir_default_map_language = 'en';
2563
+                            if (empty($geodir_default_map_language)) {
2564
+                                                            $geodir_default_map_language = 'en';
2565
+                            }
2483 2566
                             foreach ($arr_map_langages as $language_key => $language_txt) {
2484
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
2485
-                                    $geodir_default_language_selected = "selected='selected'";
2486
-                                else
2487
-                                    $geodir_default_language_selected = '';
2567
+                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) {
2568
+                                                                    $geodir_default_language_selected = "selected='selected'";
2569
+                                } else {
2570
+                                                                    $geodir_default_language_selected = '';
2571
+                                }
2488 2572
 
2489 2573
                                 ?>
2490 2574
                                 <option
@@ -2504,14 +2588,16 @@  discard block
 block discarded – undo
2504 2588
                             <?php
2505 2589
                             $post_types = geodir_get_posttypes('array');
2506 2590
                             $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
2507
-                            if (empty($geodir_default_map_search_pt))
2508
-                                $geodir_default_map_search_pt = 'gd_place';
2591
+                            if (empty($geodir_default_map_search_pt)) {
2592
+                                                            $geodir_default_map_search_pt = 'gd_place';
2593
+                            }
2509 2594
                             if (is_array($post_types)) {
2510 2595
                                 foreach ($post_types as $key => $post_types_obj) {
2511
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
2512
-                                        $geodir_search_pt_selected = "selected='selected'";
2513
-                                    else
2514
-                                        $geodir_search_pt_selected = '';
2596
+                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) {
2597
+                                                                            $geodir_search_pt_selected = "selected='selected'";
2598
+                                    } else {
2599
+                                                                            $geodir_search_pt_selected = '';
2600
+                                    }
2515 2601
 
2516 2602
                                     ?>
2517 2603
                                     <option
@@ -2631,7 +2717,7 @@  discard block
 block discarded – undo
2631 2717
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
2632 2718
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
2633 2719
                             echo 'checked="checked"';
2634
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
2720
+                        } elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
2635 2721
                         <?php echo $value['desc']; ?></label><br>
2636 2722
                 </fieldset>
2637 2723
                 <?php
@@ -2651,10 +2737,18 @@  discard block
 block discarded – undo
2651 2737
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2652 2738
                 <td class="forminp">
2653 2739
                     <textarea
2654
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
2740
+                        <?php if (isset($value['args'])) {
2741
+	echo $value['args'] . ' ';
2742
+}
2743
+?>name="<?php echo esc_attr($value['id']); ?>"
2655 2744
                         id="<?php echo esc_attr($value['id']); ?>"
2656 2745
                         <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2657
-                        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
2746
+                        style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) {
2747
+	echo esc_textarea(stripslashes(get_option($value['id'])));
2748
+} else {
2749
+	echo esc_textarea($value['std']);
2750
+}
2751
+?></textarea><span
2658 2752
                         class="description"><?php echo $value['desc'] ?></span>
2659 2753
 
2660 2754
                 </td>
@@ -2668,10 +2762,11 @@  discard block
 block discarded – undo
2668 2762
                 <td class="forminp"><?php
2669 2763
 
2670 2764
                     $content = '';
2671
-                    if (get_option($value['id']))
2672
-                        $content = stripslashes(get_option($value['id']));
2673
-                    else
2674
-                        $content = $value['std'];
2765
+                    if (get_option($value['id'])) {
2766
+                                            $content = stripslashes(get_option($value['id']));
2767
+                    } else {
2768
+                                            $content = $value['std'];
2769
+                    }
2675 2770
 
2676 2771
                     $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
2677 2772
 
@@ -2711,7 +2806,9 @@  discard block
 block discarded – undo
2711 2806
                     'echo' => false,
2712 2807
                     'selected' => $page_setting);
2713 2808
 
2714
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
2809
+                if (isset($value['args'])) {
2810
+                	$args = wp_parse_args($value['args'], $args);
2811
+                }
2715 2812
 
2716 2813
                 ?>
2717 2814
                 <tr valign="top" class="single_select_page">
@@ -2731,8 +2828,10 @@  discard block
 block discarded – undo
2731 2828
                 if (strstr($country_setting, ':')) :
2732 2829
                     $country = current(explode(':', $country_setting));
2733 2830
                     $state = end(explode(':', $country_setting));
2734
-                else :
2735
-                    $country = $country_setting;
2831
+                else {
2832
+                	:
2833
+                    $country = $country_setting;
2834
+                }
2736 2835
                     $state = '*';
2737 2836
                 endif;
2738 2837
                 ?>
@@ -2759,8 +2858,10 @@  discard block
 block discarded – undo
2759 2858
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
2760 2859
                             title="Country" class="chosen_select">
2761 2860
                         <?php
2762
-                        if ($countries) foreach ($countries as $key => $val) :
2763
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
2861
+                        if ($countries) {
2862
+                        	foreach ($countries as $key => $val) :
2863
+                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
2864
+                        }
2764 2865
                         endforeach;
2765 2866
                         ?>
2766 2867
                     </select>
@@ -3011,8 +3112,9 @@  discard block
 block discarded – undo
3011 3112
         endforeach;
3012 3113
     endif;
3013 3114
 
3014
-    if (!empty($place_img_array))
3015
-        $curImages = implode(',', $place_img_array);
3115
+    if (!empty($place_img_array)) {
3116
+            $curImages = implode(',', $place_img_array);
3117
+    }
3016 3118
 
3017 3119
 
3018 3120
     // adjust values here
@@ -3359,16 +3461,17 @@  discard block
 block discarded – undo
3359 3461
 	
3360 3462
 	$post_type = NULL;
3361 3463
 	
3362
-	if ($post && isset($post->post_type))
3363
-		$post_type = $post->post_type;
3364
-	elseif ($typenow)
3365
-		$post_type = $typenow;
3366
-	elseif ($current_screen && isset($current_screen->post_type))
3367
-		$post_type = $current_screen->post_type;
3368
-	elseif (isset($_REQUEST['post_type']))
3369
-		$post_type = sanitize_key($_REQUEST['post_type']);
3370
-	elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
3371
-		$post_type = get_post_type($_REQUEST['post']);
3464
+	if ($post && isset($post->post_type)) {
3465
+			$post_type = $post->post_type;
3466
+	} elseif ($typenow) {
3467
+			$post_type = $typenow;
3468
+	} elseif ($current_screen && isset($current_screen->post_type)) {
3469
+			$post_type = $current_screen->post_type;
3470
+	} elseif (isset($_REQUEST['post_type'])) {
3471
+			$post_type = sanitize_key($_REQUEST['post_type']);
3472
+	} elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) {
3473
+			$post_type = get_post_type($_REQUEST['post']);
3474
+	}
3372 3475
 
3373 3476
 	return $post_type;
3374 3477
 }
@@ -3427,9 +3530,10 @@  discard block
 block discarded – undo
3427 3530
 function geodir_hide_admin_preview_button() {
3428 3531
     global $post_type;
3429 3532
     $post_types = geodir_get_posttypes();
3430
-    if(in_array($post_type, $post_types))
3431
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
3432
-}
3533
+    if(in_array($post_type, $post_types)) {
3534
+            echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
3535
+    }
3536
+    }
3433 3537
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
3434 3538
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
3435 3539
 
@@ -6223,8 +6327,9 @@  discard block
 block discarded – undo
6223 6327
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
6224 6328
 	global $wpdb, $plugin_prefix;
6225 6329
 
6226
-	if ( ! post_type_exists( $post_type ) )
6227
-		return new stdClass;
6330
+	if ( ! post_type_exists( $post_type ) ) {
6331
+			return new stdClass;
6332
+	}
6228 6333
 		
6229 6334
 	$table = $plugin_prefix . $post_type . '_detail';
6230 6335
 	
@@ -7004,7 +7109,9 @@  discard block
 block discarded – undo
7004 7109
 
7005 7110
     if ($page_found) :
7006 7111
         // Page exists
7007
-        if (!$option_value) update_option($option, $page_found);
7112
+        if (!$option_value) {
7113
+        	update_option($option, $page_found);
7114
+        }
7008 7115
         return;
7009 7116
     endif;
7010 7117
 
Please login to merge, or discard this patch.
Indentation   +2761 added lines, -2761 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);
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
+		}
288 276
 
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;
277
+		// Loop through menu order and do some rearranging
278
+		foreach ($menu_order as $index => $item) :
294 279
 
295
-        endforeach;
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;
296 288
 
297
-        // Return order
298
-        return $geodir_menu_order;
299
-    }
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
-    {
445
-
446
-        global $wpdb, $plugin_prefix;
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 {
451
-
452
-            $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
453
-
454
-            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
455
-
456
-            if ($post_counts > 0) {
457
-                $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
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"';
467
-
468
-                    $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
469
-                }
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
+	{
470 445
 
471
-                $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
446
+		global $wpdb, $plugin_prefix;
472 447
 
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>';
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 {
475 451
 
476
-            }
477
-            echo $dummy_msg;
478
-            ?>
452
+			$geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
453
+
454
+			$post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
455
+
456
+			if ($post_counts > 0) {
457
+				$nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
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"';
467
+
468
+					$options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
469
+				}
470
+
471
+				$nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
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>';
475
+
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
 /**
@@ -638,110 +638,110 @@  discard block
 block discarded – undo
638 638
 function geodir_default_taxonomies()
639 639
 {
640 640
 
641
-    global $wpdb, $dummy_image_path;
641
+	global $wpdb, $dummy_image_path;
642 642
 
643
-    $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
643
+	$category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
644 644
 
645
-    $last_catid = isset($last_catid) ? $last_catid : '';
645
+	$last_catid = isset($last_catid) ? $last_catid : '';
646 646
 
647
-    $last_term = get_term($last_catid, 'gd_placecategory');
647
+	$last_term = get_term($last_catid, 'gd_placecategory');
648 648
 
649
-    $uploads = wp_upload_dir(); // Array of key => value pairs
650
-    //print_r($uploads) ;
651
-    for ($i = 0; $i < count($category_array); $i++) {
652
-        $parent_catid = 0;
653
-        if (is_array($category_array[$i])) {
654
-            $cat_name_arr = $category_array[$i];
655
-            for ($j = 0; $j < count($cat_name_arr); $j++) {
656
-                $catname = $cat_name_arr[$j];
649
+	$uploads = wp_upload_dir(); // Array of key => value pairs
650
+	//print_r($uploads) ;
651
+	for ($i = 0; $i < count($category_array); $i++) {
652
+		$parent_catid = 0;
653
+		if (is_array($category_array[$i])) {
654
+			$cat_name_arr = $category_array[$i];
655
+			for ($j = 0; $j < count($cat_name_arr); $j++) {
656
+				$catname = $cat_name_arr[$j];
657 657
 
658
-                if (!term_exists($catname, 'gd_placecategory')) {
659
-                    $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
658
+				if (!term_exists($catname, 'gd_placecategory')) {
659
+					$last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
660 660
 
661
-                    if ($j == 0) {
662
-                        $parent_catid = $last_catid;
663
-                    }
661
+					if ($j == 0) {
662
+						$parent_catid = $last_catid;
663
+					}
664 664
 
665 665
 
666
-                    if (geodir_dummy_folder_exists())
667
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
668
-                    else
669
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
670
-                    $catname = str_replace(' ', '_', $catname);
671
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
666
+					if (geodir_dummy_folder_exists())
667
+						$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
668
+					else
669
+						$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
670
+					$catname = str_replace(' ', '_', $catname);
671
+					$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
672 672
 
673
-                    if (empty($uploaded['error'])) {
674
-                        $new_path = $uploaded['file'];
675
-                        $new_url = $uploaded['url'];
676
-                    }
673
+					if (empty($uploaded['error'])) {
674
+						$new_path = $uploaded['file'];
675
+						$new_url = $uploaded['url'];
676
+					}
677 677
 
678
-                    $wp_filetype = wp_check_filetype(basename($new_path), null);
679
-
680
-                    $attachment = array(
681
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
682
-                        'post_mime_type' => $wp_filetype['type'],
683
-                        'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
684
-                        'post_content' => '',
685
-                        'post_status' => 'inherit'
686
-                    );
687
-                    $attach_id = wp_insert_attachment($attachment, $new_path);
688
-
689
-                    // you must first include the image.php file
690
-                    // for the function wp_generate_attachment_metadata() to work
691
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
692
-                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
693
-                    wp_update_attachment_metadata($attach_id, $attach_data);
694
-
695
-                    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
696
-                        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
697
-                    }
698
-                }
699
-            }
678
+					$wp_filetype = wp_check_filetype(basename($new_path), null);
679
+
680
+					$attachment = array(
681
+						'guid' => $uploads['baseurl'] . '/' . basename($new_path),
682
+						'post_mime_type' => $wp_filetype['type'],
683
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
684
+						'post_content' => '',
685
+						'post_status' => 'inherit'
686
+					);
687
+					$attach_id = wp_insert_attachment($attachment, $new_path);
688
+
689
+					// you must first include the image.php file
690
+					// for the function wp_generate_attachment_metadata() to work
691
+					require_once(ABSPATH . 'wp-admin/includes/image.php');
692
+					$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
693
+					wp_update_attachment_metadata($attach_id, $attach_data);
694
+
695
+					if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
696
+						update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
697
+					}
698
+				}
699
+			}
700 700
 
701
-        } else {
702
-            $catname = $category_array[$i];
701
+		} else {
702
+			$catname = $category_array[$i];
703 703
 
704
-            if (!term_exists($catname, 'gd_placecategory')) {
705
-                $last_catid = wp_insert_term($catname, 'gd_placecategory');
704
+			if (!term_exists($catname, 'gd_placecategory')) {
705
+				$last_catid = wp_insert_term($catname, 'gd_placecategory');
706 706
 
707
-                if (geodir_dummy_folder_exists())
708
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
709
-                else
710
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
711
-                $catname = str_replace(' ', '_', $catname);
712
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
707
+				if (geodir_dummy_folder_exists())
708
+					$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
709
+				else
710
+					$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
711
+				$catname = str_replace(' ', '_', $catname);
712
+				$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
713 713
 
714
-                if (empty($uploaded['error'])) {
715
-                    $new_path = $uploaded['file'];
716
-                    $new_url = $uploaded['url'];
717
-                }
714
+				if (empty($uploaded['error'])) {
715
+					$new_path = $uploaded['file'];
716
+					$new_url = $uploaded['url'];
717
+				}
718 718
 
719
-                $wp_filetype = wp_check_filetype(basename($new_path), null);
719
+				$wp_filetype = wp_check_filetype(basename($new_path), null);
720 720
 
721
-                $attachment = array(
722
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
723
-                    'post_mime_type' => $wp_filetype['type'],
724
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
725
-                    'post_content' => '',
726
-                    'post_status' => 'inherit'
727
-                );
721
+				$attachment = array(
722
+					'guid' => $uploads['baseurl'] . '/' . basename($new_path),
723
+					'post_mime_type' => $wp_filetype['type'],
724
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
725
+					'post_content' => '',
726
+					'post_status' => 'inherit'
727
+				);
728 728
 
729
-                $attach_id = wp_insert_attachment($attachment, $new_path);
729
+				$attach_id = wp_insert_attachment($attachment, $new_path);
730 730
 
731 731
 
732
-                // you must first include the image.php file
733
-                // for the function wp_generate_attachment_metadata() to work
734
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
735
-                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
736
-                wp_update_attachment_metadata($attach_id, $attach_data);
732
+				// you must first include the image.php file
733
+				// for the function wp_generate_attachment_metadata() to work
734
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
735
+				$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
736
+				wp_update_attachment_metadata($attach_id, $attach_data);
737 737
 
738
-                if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
739
-                    update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
740
-                }
741
-            }
742
-        }
738
+				if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
739
+					update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
740
+				}
741
+			}
742
+		}
743 743
 
744
-    }
744
+	}
745 745
 }
746 746
 
747 747
 /**
@@ -759,145 +759,145 @@  discard block
 block discarded – undo
759 759
 {
760 760
    // print_r($_POST);    print_r($options);    exit;
761 761
 
762
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
762
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
763 763
 
764
-    foreach ($options as $value) {
765
-        if ($dummy && isset($value['std']))
766
-            $_POST[$value['id']] = $value['std'];
764
+	foreach ($options as $value) {
765
+		if ($dummy && isset($value['std']))
766
+			$_POST[$value['id']] = $value['std'];
767 767
 
768 768
 
769
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
769
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
770 770
 
771
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
772
-                update_option($value['id'], $_POST[$value['id']]);
773
-            } else {
774
-                update_option($value['id'], 0);
775
-            }
771
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
772
+				update_option($value['id'], $_POST[$value['id']]);
773
+			} else {
774
+				update_option($value['id'], 0);
775
+			}
776 776
 
777
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
778
-
779
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
780
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
781
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
782
-                if (isset($_POST[$value['id'] . '_crop'])) :
783
-                    update_option($value['id'] . '_crop', 1);
784
-                else :
785
-                    update_option($value['id'] . '_crop', 0);
786
-                endif;
787
-            } else {
788
-                update_option($value['id'] . '_width', $value['std']);
789
-                update_option($value['id'] . '_height', $value['std']);
790
-                update_option($value['id'] . '_crop', 1);
791
-            }
777
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
792 778
 
793
-        elseif (isset($value['type']) && $value['type'] == 'map') :
794
-            $post_types = array();
795
-            $categories = array();
796
-            $i = 0;
779
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
780
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
781
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
782
+				if (isset($_POST[$value['id'] . '_crop'])) :
783
+					update_option($value['id'] . '_crop', 1);
784
+				else :
785
+					update_option($value['id'] . '_crop', 0);
786
+				endif;
787
+			} else {
788
+				update_option($value['id'] . '_width', $value['std']);
789
+				update_option($value['id'] . '_height', $value['std']);
790
+				update_option($value['id'] . '_crop', 1);
791
+			}
797 792
 
798
-            if (!empty($_POST['home_map_post_types'])) :
799
-                foreach ($_POST['home_map_post_types'] as $post_type) :
800
-                    $post_types[] = $post_type;
801
-                endforeach;
802
-            endif;
793
+		elseif (isset($value['type']) && $value['type'] == 'map') :
794
+			$post_types = array();
795
+			$categories = array();
796
+			$i = 0;
803 797
 
804
-            update_option('geodir_exclude_post_type_on_map', $post_types);
798
+			if (!empty($_POST['home_map_post_types'])) :
799
+				foreach ($_POST['home_map_post_types'] as $post_type) :
800
+					$post_types[] = $post_type;
801
+				endforeach;
802
+			endif;
805 803
 
806
-            if (!empty($_POST['post_category'])) :
807
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
808
-                    $categories[$texonomy] = array();
809
-                    foreach ($cat_arr as $category) :
810
-                        $categories[$texonomy][] = $category;
811
-                    endforeach;
812
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
813
-                endforeach;
814
-            endif;
815
-            update_option('geodir_exclude_cat_on_map', $categories);
816
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
817
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
804
+			update_option('geodir_exclude_post_type_on_map', $post_types);
818 805
 
806
+			if (!empty($_POST['post_category'])) :
807
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
808
+					$categories[$texonomy] = array();
809
+					foreach ($cat_arr as $category) :
810
+						$categories[$texonomy][] = $category;
811
+					endforeach;
812
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
813
+				endforeach;
814
+			endif;
815
+			update_option('geodir_exclude_cat_on_map', $categories);
816
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
817
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
819 818
 
820
-            if (!empty($_POST['geodir_default_map_language'])):
821
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
822
-            endif;
823 819
 
820
+			if (!empty($_POST['geodir_default_map_language'])):
821
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
822
+			endif;
824 823
 
825
-            if (!empty($_POST['geodir_default_map_search_pt'])):
826
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
827
-            endif;
828 824
 
825
+			if (!empty($_POST['geodir_default_map_search_pt'])):
826
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
827
+			endif;
829 828
 
830
-        elseif (isset($value['type']) && $value['type'] == 'file') :
831 829
 
830
+		elseif (isset($value['type']) && $value['type'] == 'file') :
832 831
 
833
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
834 832
 
835
-                if (get_option($value['id'])) {
836
-                    $image_name_arr = explode('/', get_option($value['id']));
837
-                    $noimg_name = end($image_name_arr);
838
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
839
-                    if (file_exists($img_path))
840
-                        unlink($img_path);
841
-                }
833
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
842 834
 
843
-                update_option($value['id'], '');
844
-            }
835
+				if (get_option($value['id'])) {
836
+					$image_name_arr = explode('/', get_option($value['id']));
837
+					$noimg_name = end($image_name_arr);
838
+					$img_path = $uploads['path'] . '/' . $noimg_name;
839
+					if (file_exists($img_path))
840
+						unlink($img_path);
841
+				}
845 842
 
846
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
847
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
848
-
849
-            if (!empty($filename)):
850
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
851
-                $uplaods = array();
852
-
853
-                foreach ($uploadedfile as $key => $uplaod):
854
-                    if ($key == 'name'):
855
-                        $uplaods[$key] = $filename;
856
-                    else :
857
-                        $uplaods[$key] = $uplaod;
858
-                    endif;
859
-                endforeach;
860
-
861
-                $uploads = wp_upload_dir();
862
-
863
-                if (get_option($value['id'])) {
864
-                    $image_name_arr = explode('/', get_option($value['id']));
865
-                    $noimg_name = end($image_name_arr);
866
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
867
-                    if (file_exists($img_path))
868
-                        unlink($img_path);
869
-                }
843
+				update_option($value['id'], '');
844
+			}
870 845
 
871
-                $upload_overrides = array('test_form' => false);
872
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
846
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
847
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
848
+
849
+			if (!empty($filename)):
850
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
851
+				$uplaods = array();
852
+
853
+				foreach ($uploadedfile as $key => $uplaod):
854
+					if ($key == 'name'):
855
+						$uplaods[$key] = $filename;
856
+					else :
857
+						$uplaods[$key] = $uplaod;
858
+					endif;
859
+				endforeach;
860
+
861
+				$uploads = wp_upload_dir();
862
+
863
+				if (get_option($value['id'])) {
864
+					$image_name_arr = explode('/', get_option($value['id']));
865
+					$noimg_name = end($image_name_arr);
866
+					$img_path = $uploads['path'] . '/' . $noimg_name;
867
+					if (file_exists($img_path))
868
+						unlink($img_path);
869
+				}
873 870
 
874
-                update_option($value['id'], $movefile['url']);
871
+				$upload_overrides = array('test_form' => false);
872
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
875 873
 
876
-            endif;
874
+				update_option($value['id'], $movefile['url']);
877 875
 
878
-            if (!get_option($value['id']) && isset($value['value'])):
879
-                update_option($value['id'], $value['value']);
880
-            endif;
876
+			endif;
881 877
 
878
+			if (!get_option($value['id']) && isset($value['value'])):
879
+				update_option($value['id'], $value['value']);
880
+			endif;
882 881
 
883
-        else :
884
-            // same menu setting per theme.
885
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
886
-                $theme = wp_get_theme();
887
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
888
-            }
889 882
 
890
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
891
-                update_option($value['id'], $_POST[$value['id']]);
892
-            } else {
893
-                delete_option($value['id']);
894
-            }
883
+		else :
884
+			// same menu setting per theme.
885
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
886
+				$theme = wp_get_theme();
887
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
888
+			}
895 889
 
896
-        endif;
897
-    }
898
-    if ($dummy)
899
-        unset($_POST);
900
-    return true;
890
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
891
+				update_option($value['id'], $_POST[$value['id']]);
892
+			} else {
893
+				delete_option($value['id']);
894
+			}
895
+
896
+		endif;
897
+	}
898
+	if ($dummy)
899
+		unset($_POST);
900
+	return true;
901 901
 
902 902
 }
903 903
 
@@ -946,33 +946,33 @@  discard block
 block discarded – undo
946 946
 function places_custom_fields_tab($tabs)
947 947
 {
948 948
 
949
-    $geodir_post_types = get_option('geodir_post_types');
949
+	$geodir_post_types = get_option('geodir_post_types');
950 950
 
951
-    if (!empty($geodir_post_types)) {
951
+	if (!empty($geodir_post_types)) {
952 952
 
953
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
953
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
954 954
 
955
-            $listing_slug = $geodir_posttype_info['labels']['singular_name'];
955
+			$listing_slug = $geodir_posttype_info['labels']['singular_name'];
956 956
 
957
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
958
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
959
-                'subtabs' => array(
960
-                    array('subtab' => 'custom_fields',
961
-                        'label' => __('Custom Fields', 'geodirectory'),
962
-                        'request' => array('listing_type' => $geodir_post_type)),
963
-                    array('subtab' => 'sorting_options',
964
-                        'label' => __('Sorting Options', 'geodirectory'),
965
-                        'request' => array('listing_type' => $geodir_post_type)),
966
-                ),
967
-                'tab_index' => 9,
968
-                'request' => array('listing_type' => $geodir_post_type)
969
-            );
957
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
958
+				'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
959
+				'subtabs' => array(
960
+					array('subtab' => 'custom_fields',
961
+						'label' => __('Custom Fields', 'geodirectory'),
962
+						'request' => array('listing_type' => $geodir_post_type)),
963
+					array('subtab' => 'sorting_options',
964
+						'label' => __('Sorting Options', 'geodirectory'),
965
+						'request' => array('listing_type' => $geodir_post_type)),
966
+				),
967
+				'tab_index' => 9,
968
+				'request' => array('listing_type' => $geodir_post_type)
969
+			);
970 970
 
971
-        endforeach;
971
+		endforeach;
972 972
 
973
-    }
973
+	}
974 974
 
975
-    return $tabs;
975
+	return $tabs;
976 976
 }
977 977
 
978 978
 
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
  */
989 989
 function geodir_tools_setting_tab($tabs)
990 990
 {
991
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
992
-    return $tabs;
991
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
992
+	return $tabs;
993 993
 }
994 994
 
995 995
 /**
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
  */
1005 1005
 function geodir_compatibility_setting_tab($tabs)
1006 1006
 {
1007
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1008
-    return $tabs;
1007
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1008
+	return $tabs;
1009 1009
 }
1010 1010
 
1011 1011
 
@@ -1021,144 +1021,144 @@  discard block
 block discarded – undo
1021 1021
  */
1022 1022
 function geodir_extend_geodirectory_setting_tab($tabs)
1023 1023
 {
1024
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1025
-    return $tabs;
1024
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1025
+	return $tabs;
1026 1026
 }
1027 1027
 
1028 1028
 
1029 1029
 if (!function_exists('geodir_edit_post_columns')) {
1030
-    /**
1031
-     * Modify admin post listing page columns.
1032
-     *
1033
-     * @since 1.0.0
1034
-     * @package GeoDirectory
1035
-     * @param array $columns The column array.
1036
-     * @return array Altered column array.
1037
-     */
1038
-    function geodir_edit_post_columns($columns)
1039
-    {
1040
-
1041
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1042
-            'categorys' => __('Categories', 'geodirectory'));
1043
-
1044
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1045
-        {
1046
-            $offset = 0; // should we prepend $array with $data?
1047
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
1048
-        }
1030
+	/**
1031
+	 * Modify admin post listing page columns.
1032
+	 *
1033
+	 * @since 1.0.0
1034
+	 * @package GeoDirectory
1035
+	 * @param array $columns The column array.
1036
+	 * @return array Altered column array.
1037
+	 */
1038
+	function geodir_edit_post_columns($columns)
1039
+	{
1049 1040
 
1050
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1041
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1042
+			'categorys' => __('Categories', 'geodirectory'));
1051 1043
 
1052
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1044
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1045
+		{
1046
+			$offset = 0; // should we prepend $array with $data?
1047
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
1048
+		}
1053 1049
 
1054
-        return $columns;
1055
-    }
1050
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1051
+
1052
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1053
+
1054
+		return $columns;
1055
+	}
1056 1056
 }
1057 1057
 
1058 1058
 
1059 1059
 if (!function_exists('geodir_manage_post_columns')) {
1060
-    /**
1061
-     * Adds content to our custom post listing page columns.
1062
-     *
1063
-     * @since 1.0.0
1064
-     * @package GeoDirectory
1065
-     * @global object $wpdb WordPress Database object.
1066
-     * @global object $post WordPress Post object.
1067
-     * @param string $column The column name.
1068
-     * @param int $post_id The post ID.
1069
-     */
1070
-    function geodir_manage_post_columns($column, $post_id)
1071
-    {
1072
-        global $post, $wpdb;
1073
-
1074
-        switch ($column):
1075
-            /* If displaying the 'city' column. */
1076
-            case 'location' :
1077
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1078
-                $location = geodir_get_location($location_id);
1079
-                /* If no city is found, output a default message. */
1080
-                if (empty($location)) {
1081
-                    _e('Unknown', 'geodirectory');
1082
-                } else {
1083
-                    /* If there is a city id, append 'city name' to the text string. */
1084
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1085
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1086
-                }
1087
-                break;
1088
-
1089
-            /* If displaying the 'expire' column. */
1090
-            case 'expire' :
1091
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1092
-                $d1 = $expire_date; // get expire_date
1093
-                $d2 = date('Y-m-d'); // get current date
1094
-                $state = __('days left', 'geodirectory');
1095
-                $date_diff_text = '';
1096
-                $expire_class = 'expire_left';
1097
-                if ($expire_date != 'Never') {
1098
-                    if (strtotime($d1) < strtotime($d2)) {
1099
-                        $state = __('days overdue', 'geodirectory');
1100
-                        $expire_class = 'expire_over';
1101
-                    }
1102
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the differance in days
1103
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1104
-                }
1105
-                /* If no expire_date is found, output a default message. */
1106
-                if (empty($expire_date))
1107
-                    echo __('Unknown', 'geodirectory');
1108
-                /* If there is a expire_date, append 'days left' to the text string. */
1109
-                else
1110
-                    echo $expire_date . $date_diff_text;
1111
-                break;
1112
-
1113
-            /* If displaying the 'categorys' column. */
1114
-            case 'categorys' :
1115
-
1116
-                /* Get the categorys for the post. */
1117
-
1118
-
1119
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1120
-
1121
-                /* If terms were found. */
1122
-                if (!empty($terms)) {
1123
-                    $out = array();
1124
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
1125
-                    foreach ($terms as $term) {
1126
-                        if (!strstr($term->taxonomy, 'tag')) {
1127
-                            $out[] = sprintf('<a href="%s">%s</a>',
1128
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1129
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1130
-                            );
1131
-                        }
1132
-                    }
1133
-                    /* Join the terms, separating them with a comma. */
1134
-                    echo(join(', ', $out));
1135
-                } /* If no terms were found, output a default message. */
1136
-                else {
1137
-                    _e('No Categories', 'geodirectory');
1138
-                }
1139
-                break;
1060
+	/**
1061
+	 * Adds content to our custom post listing page columns.
1062
+	 *
1063
+	 * @since 1.0.0
1064
+	 * @package GeoDirectory
1065
+	 * @global object $wpdb WordPress Database object.
1066
+	 * @global object $post WordPress Post object.
1067
+	 * @param string $column The column name.
1068
+	 * @param int $post_id The post ID.
1069
+	 */
1070
+	function geodir_manage_post_columns($column, $post_id)
1071
+	{
1072
+		global $post, $wpdb;
1073
+
1074
+		switch ($column):
1075
+			/* If displaying the 'city' column. */
1076
+			case 'location' :
1077
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1078
+				$location = geodir_get_location($location_id);
1079
+				/* If no city is found, output a default message. */
1080
+				if (empty($location)) {
1081
+					_e('Unknown', 'geodirectory');
1082
+				} else {
1083
+					/* If there is a city id, append 'city name' to the text string. */
1084
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1085
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1086
+				}
1087
+				break;
1088
+
1089
+			/* If displaying the 'expire' column. */
1090
+			case 'expire' :
1091
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1092
+				$d1 = $expire_date; // get expire_date
1093
+				$d2 = date('Y-m-d'); // get current date
1094
+				$state = __('days left', 'geodirectory');
1095
+				$date_diff_text = '';
1096
+				$expire_class = 'expire_left';
1097
+				if ($expire_date != 'Never') {
1098
+					if (strtotime($d1) < strtotime($d2)) {
1099
+						$state = __('days overdue', 'geodirectory');
1100
+						$expire_class = 'expire_over';
1101
+					}
1102
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the differance in days
1103
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1104
+				}
1105
+				/* If no expire_date is found, output a default message. */
1106
+				if (empty($expire_date))
1107
+					echo __('Unknown', 'geodirectory');
1108
+				/* If there is a expire_date, append 'days left' to the text string. */
1109
+				else
1110
+					echo $expire_date . $date_diff_text;
1111
+				break;
1140 1112
 
1141
-        endswitch;
1142
-    }
1113
+			/* If displaying the 'categorys' column. */
1114
+			case 'categorys' :
1115
+
1116
+				/* Get the categorys for the post. */
1117
+
1118
+
1119
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1120
+
1121
+				/* If terms were found. */
1122
+				if (!empty($terms)) {
1123
+					$out = array();
1124
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
1125
+					foreach ($terms as $term) {
1126
+						if (!strstr($term->taxonomy, 'tag')) {
1127
+							$out[] = sprintf('<a href="%s">%s</a>',
1128
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1129
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1130
+							);
1131
+						}
1132
+					}
1133
+					/* Join the terms, separating them with a comma. */
1134
+					echo(join(', ', $out));
1135
+				} /* If no terms were found, output a default message. */
1136
+				else {
1137
+					_e('No Categories', 'geodirectory');
1138
+				}
1139
+				break;
1140
+
1141
+		endswitch;
1142
+	}
1143 1143
 }
1144 1144
 
1145 1145
 
1146 1146
 if (!function_exists('geodir_post_sortable_columns')) {
1147
-    /**
1148
-     * Makes admin post listing page columns sortable.
1149
-     *
1150
-     * @since 1.0.0
1151
-     * @package GeoDirectory
1152
-     * @param array $columns The column array.
1153
-     * @return array Altered column array.
1154
-     */
1155
-    function geodir_post_sortable_columns($columns)
1156
-    {
1157
-
1158
-        $columns['expire'] = 'expire';
1159
-
1160
-        return $columns;
1161
-    }
1147
+	/**
1148
+	 * Makes admin post listing page columns sortable.
1149
+	 *
1150
+	 * @since 1.0.0
1151
+	 * @package GeoDirectory
1152
+	 * @param array $columns The column array.
1153
+	 * @return array Altered column array.
1154
+	 */
1155
+	function geodir_post_sortable_columns($columns)
1156
+	{
1157
+
1158
+		$columns['expire'] = 'expire';
1159
+
1160
+		return $columns;
1161
+	}
1162 1162
 }
1163 1163
 
1164 1164
 /**
@@ -1172,49 +1172,49 @@  discard block
 block discarded – undo
1172 1172
  * @param int $post_id The post ID.
1173 1173
  */
1174 1174
 function geodir_post_information_save($post_id, $post) {
1175
-    global $wpdb, $current_user;
1175
+	global $wpdb, $current_user;
1176 1176
 
1177
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1178
-        return;
1179
-    }
1177
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1178
+		return;
1179
+	}
1180 1180
 
1181
-    $geodir_posttypes = geodir_get_posttypes();
1181
+	$geodir_posttypes = geodir_get_posttypes();
1182 1182
 
1183
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1184
-        return;
1183
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1184
+		return;
1185 1185
 
1186
-    if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1187
-        if (isset($_REQUEST['_status']))
1188
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1186
+	if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1187
+		if (isset($_REQUEST['_status']))
1188
+			geodir_change_post_status($post_id, $_REQUEST['_status']);
1189 1189
 
1190
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1191
-            return;
1190
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1191
+			return;
1192 1192
 
1193
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1194
-            return;
1193
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1194
+			return;
1195 1195
 
1196
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1197
-            return;
1196
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1197
+			return;
1198 1198
 
1199
-        geodir_save_listing($_REQUEST);
1200
-    }
1199
+		geodir_save_listing($_REQUEST);
1200
+	}
1201 1201
 }
1202 1202
 
1203 1203
 if (!function_exists('geodir_insert_csv_post_data') && get_option('geodir_installed')) {
1204
-    /**
1205
-     * Function to insert csv post data.
1206
-     *
1207
-     * @since 1.0.0
1208
-     * @package GeoDirectory
1209
-     * @global object $wpdb WordPress Database object.
1210
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1211
-     */
1212
-    function geodir_insert_csv_post_data()
1213
-    {
1214
-        global $wpdb, $plugin_prefix;
1215
-
1216
-        $svalue = '';
1217
-        ?>
1204
+	/**
1205
+	 * Function to insert csv post data.
1206
+	 *
1207
+	 * @since 1.0.0
1208
+	 * @package GeoDirectory
1209
+	 * @global object $wpdb WordPress Database object.
1210
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1211
+	 */
1212
+	function geodir_insert_csv_post_data()
1213
+	{
1214
+		global $wpdb, $plugin_prefix;
1215
+
1216
+		$svalue = '';
1217
+		?>
1218 1218
         <script type="text/javascript">
1219 1219
             jQuery(document).ready(function () {
1220 1220
                 jQuery("#import_data").click(function () {
@@ -1254,50 +1254,50 @@  discard block
 block discarded – undo
1254 1254
         </script>
1255 1255
         <?php
1256 1256
 
1257
-        if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] == 'csv_upload_settings') {
1258
-            if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'success') {
1259
-                $rowcount = (int)$_REQUEST['rowcount'];
1260
-                $uploads = wp_upload_dir();
1261
-                ?>
1257
+		if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] == 'csv_upload_settings') {
1258
+			if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'success') {
1259
+				$rowcount = (int)$_REQUEST['rowcount'];
1260
+				$uploads = wp_upload_dir();
1261
+				?>
1262 1262
                 <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204); margin-left:0px; margin-top:0px; margin-bottom:10px;">
1263 1263
                 <?php
1264
-                    if ($_REQUEST['invalidcount'] == 0 && $_REQUEST['blank_address'] == 0 && $_REQUEST['invalid_post_type'] == 0 && $_REQUEST['invalid_title'] == 0) {
1265
-                        echo '<p>' . CSV_INSERT_DATA . '</p>';
1266
-                    }
1267
-                    echo '<p>';
1268
-                    printf(CSV_TOTAL_RECORD, $rowcount);
1269
-                    echo '</p>';
1270
-
1271
-                    if (isset($_REQUEST['invalidcount']) && $_REQUEST['invalidcount'] > 0) {
1272
-                        echo '<p>';
1273
-                        printf(CSV_INVALID_DEFUALT_ADDRESS, (int)$_REQUEST['invalidcount'], (int)$_REQUEST['total_records']);
1274
-                        echo '</p>';
1275
-                    }
1264
+					if ($_REQUEST['invalidcount'] == 0 && $_REQUEST['blank_address'] == 0 && $_REQUEST['invalid_post_type'] == 0 && $_REQUEST['invalid_title'] == 0) {
1265
+						echo '<p>' . CSV_INSERT_DATA . '</p>';
1266
+					}
1267
+					echo '<p>';
1268
+					printf(CSV_TOTAL_RECORD, $rowcount);
1269
+					echo '</p>';
1270
+
1271
+					if (isset($_REQUEST['invalidcount']) && $_REQUEST['invalidcount'] > 0) {
1272
+						echo '<p>';
1273
+						printf(CSV_INVALID_DEFUALT_ADDRESS, (int)$_REQUEST['invalidcount'], (int)$_REQUEST['total_records']);
1274
+						echo '</p>';
1275
+					}
1276 1276
 
1277
-                    if (isset($_REQUEST['blank_address']) && $_REQUEST['blank_address'] > 0) {
1278
-                        echo '<p>';
1279
-                        printf(CSV_INVALID_TOTAL_RECORD, (int)$_REQUEST['blank_address'], (int)$_REQUEST['total_records']);
1280
-                        echo '</p>';
1281
-                    }
1277
+					if (isset($_REQUEST['blank_address']) && $_REQUEST['blank_address'] > 0) {
1278
+						echo '<p>';
1279
+						printf(CSV_INVALID_TOTAL_RECORD, (int)$_REQUEST['blank_address'], (int)$_REQUEST['total_records']);
1280
+						echo '</p>';
1281
+					}
1282 1282
 
1283
-                    if (isset($_REQUEST['invalid_post_type']) && $_REQUEST['invalid_post_type'] > 0) {
1284
-                        echo '<p>';
1285
-                        printf(CSV_INVALID_POST_TYPE, (int)$_REQUEST['invalid_post_type'], (int)$_REQUEST['total_records']);
1286
-                        echo '</p>';
1287
-                    }
1283
+					if (isset($_REQUEST['invalid_post_type']) && $_REQUEST['invalid_post_type'] > 0) {
1284
+						echo '<p>';
1285
+						printf(CSV_INVALID_POST_TYPE, (int)$_REQUEST['invalid_post_type'], (int)$_REQUEST['total_records']);
1286
+						echo '</p>';
1287
+					}
1288 1288
 
1289
-                    if (isset($_REQUEST['invalid_title']) && $_REQUEST['invalid_title'] > 0) {
1290
-                        echo '<p>';
1291
-                        printf(CSV_BLANK_POST_TITLE, (int)$_REQUEST['invalid_title'], (int)$_REQUEST['total_records']);
1292
-                        echo '</p>';
1293
-                    }
1289
+					if (isset($_REQUEST['invalid_title']) && $_REQUEST['invalid_title'] > 0) {
1290
+						echo '<p>';
1291
+						printf(CSV_BLANK_POST_TITLE, (int)$_REQUEST['invalid_title'], (int)$_REQUEST['total_records']);
1292
+						echo '</p>';
1293
+					}
1294 1294
 
1295
-                    if (isset($_REQUEST['upload_files']) && $_REQUEST['upload_files'] > 0) {
1296
-                        echo '<p>';
1297
-                        printf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir']);
1298
-                        echo '</p>';
1299
-                    }
1300
-                    ?>
1295
+					if (isset($_REQUEST['upload_files']) && $_REQUEST['upload_files'] > 0) {
1296
+						echo '<p>';
1297
+						printf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir']);
1298
+						echo '</p>';
1299
+					}
1300
+					?>
1301 1301
                 </div>
1302 1302
             <?php } ?>
1303 1303
             <?php if (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'wrong') { ?>
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
                     <p><?php echo CSV_UPLOAD_ONLY; ?></p>
1313 1313
                 </div>
1314 1314
             <?php }
1315
-        } ?>
1315
+		} ?>
1316 1316
         <?php /* ?>
1317 1317
     <table class="form-table">
1318 1318
         <tbody>
@@ -1350,10 +1350,10 @@  discard block
 block discarded – undo
1350 1350
     </table>
1351 1351
 	<?php */ ?>
1352 1352
         <?php
1353
-        $id = "gd_import_csv";
1354
-        $multiple = false; // allow multiple files upload
1355
-        $uploads = wp_upload_dir();
1356
-        ?>
1353
+		$id = "gd_import_csv";
1354
+		$multiple = false; // allow multiple files upload
1355
+		$uploads = wp_upload_dir();
1356
+		?>
1357 1357
         <style>
1358 1358
             .gd-csv-form-table .filelist div.file:last-child {
1359 1359
                 display: block !important;
@@ -1711,12 +1711,12 @@  discard block
 block discarded – undo
1711 1711
                                 <br/>
1712 1712
                                 <a href="<?php echo geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'?>"><?php _e("Download sample csv", 'geodirectory')?></a>
1713 1713
                                 <?php
1714
-                                /**
1715
-                                 * Called just after the sample CSV download link.
1716
-                                 *
1717
-                                 * @since 1.0.0
1718
-                                 */
1719
-                                do_action('geodir_sample_csv_download_link'); ?>
1714
+								/**
1715
+								 * Called just after the sample CSV download link.
1716
+								 *
1717
+								 * @since 1.0.0
1718
+								 */
1719
+								do_action('geodir_sample_csv_download_link'); ?>
1720 1720
                                 <span class="ajaxnonceplu"
1721 1721
                                       id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span><br/>
1722 1722
                                 <br/>
@@ -1775,362 +1775,362 @@  discard block
 block discarded – undo
1775 1775
 }
1776 1776
 
1777 1777
 if (!function_exists('geodir_import_data')) {
1778
-    /**
1779
-     * Imports data from csv file.
1780
-     *
1781
-     * @since 1.0.0
1782
-     * @package GeoDirectory
1783
-     * @global object $wpdb WordPress Database object.
1784
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1785
-     * @global object $current_user Current user object.
1786
-     */
1787
-    function geodir_import_data()
1788
-    {
1778
+	/**
1779
+	 * Imports data from csv file.
1780
+	 *
1781
+	 * @since 1.0.0
1782
+	 * @package GeoDirectory
1783
+	 * @global object $wpdb WordPress Database object.
1784
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1785
+	 * @global object $current_user Current user object.
1786
+	 */
1787
+	function geodir_import_data()
1788
+	{
1789 1789
 
1790
-        global $wpdb, $plugin_prefix, $current_user;
1790
+		global $wpdb, $plugin_prefix, $current_user;
1791 1791
 
1792
-        if (isset($_REQUEST['geodir_import_data']) && !empty($_REQUEST['geodir_import_data'])) {
1793
-            $uploads = wp_upload_dir();
1794
-            $uploads_dir = $uploads['path'];
1792
+		if (isset($_REQUEST['geodir_import_data']) && !empty($_REQUEST['geodir_import_data'])) {
1793
+			$uploads = wp_upload_dir();
1794
+			$uploads_dir = $uploads['path'];
1795 1795
 
1796
-            $curr_img_url = $_REQUEST['filename'];
1796
+			$curr_img_url = $_REQUEST['filename'];
1797 1797
 
1798
-            $image_name_arr = explode('/', $curr_img_url);
1798
+			$image_name_arr = explode('/', $curr_img_url);
1799 1799
 
1800
-            $filename = end($image_name_arr);
1800
+			$filename = end($image_name_arr);
1801 1801
 
1802
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1802
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1803 1803
 
1804
-            $destination_path = $uploads_dir . '/temp_' . $current_user->data->ID;
1804
+			$destination_path = $uploads_dir . '/temp_' . $current_user->data->ID;
1805 1805
 
1806
-            $csv_target_path = $target_path;
1806
+			$csv_target_path = $target_path;
1807 1807
 
1808
-            ini_set('auto_detect_line_endings', true);
1808
+			ini_set('auto_detect_line_endings', true);
1809 1809
 
1810
-            $fd = fopen($target_path, "rt");
1810
+			$fd = fopen($target_path, "rt");
1811 1811
 
1812
-            $total_records = 0;
1813
-            $rowcount = 0;
1814
-            $address_invalid = 0;
1815
-            $blank_address = 0;
1816
-            $upload_files = 0;
1817
-            $invalid_post_type = 0;
1818
-            $invalid_title = 0;
1812
+			$total_records = 0;
1813
+			$rowcount = 0;
1814
+			$address_invalid = 0;
1815
+			$blank_address = 0;
1816
+			$upload_files = 0;
1817
+			$invalid_post_type = 0;
1818
+			$invalid_title = 0;
1819 1819
 
1820
-            $customKeyarray = array();
1820
+			$customKeyarray = array();
1821 1821
 
1822
-            $gd_post_info = array();
1822
+			$gd_post_info = array();
1823 1823
 
1824
-            $post_location = array();
1825
-            $countpost = 0;
1824
+			$post_location = array();
1825
+			$countpost = 0;
1826 1826
 
1827
-            $uploaded_file_type = pathinfo($filename, PATHINFO_EXTENSION);
1827
+			$uploaded_file_type = pathinfo($filename, PATHINFO_EXTENSION);
1828 1828
 
1829
-            $extensionarr = array('csv', 'CSV');
1829
+			$extensionarr = array('csv', 'CSV');
1830 1830
 
1831
-            if (in_array($uploaded_file_type, $extensionarr)) {
1831
+			if (in_array($uploaded_file_type, $extensionarr)) {
1832 1832
 
1833
-                while (!feof($fd)) {
1834
-                    $buffer = fgetcsv($fd, 40960);
1833
+				while (!feof($fd)) {
1834
+					$buffer = fgetcsv($fd, 40960);
1835 1835
 
1836
-                    if ($rowcount == 0) {
1837
-                        for ($k = 0; $k < count($buffer); $k++) {
1838
-                            $customKeyarray[$k] = $buffer[$k];
1839
-                        }
1836
+					if ($rowcount == 0) {
1837
+						for ($k = 0; $k < count($buffer); $k++) {
1838
+							$customKeyarray[$k] = $buffer[$k];
1839
+						}
1840 1840
 
1841
-                        if ($customKeyarray[0] == '') {
1842
-                            echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=wrong';
1843
-                            exit;
1844
-                        }
1845
-                    } elseif (!empty($buffer)) {
1846
-
1847
-                        $total_records++;
1848
-
1849
-                        $post_title = addslashes($buffer[0]);
1850
-                        $current_post_author = $buffer[1];
1851
-                        $post_desc = addslashes($buffer[2]);
1852
-                        $post_cat = array();
1853
-                        $catids_arr = array();
1854
-                        $post_cat = trim($buffer[3]); // comma seperated category name
1855
-
1856
-                        if ($post_cat) {
1857
-                            $post_cat_arr = explode(',', $post_cat);
1858
-
1859
-                            for ($c = 0; $c < count($post_cat_arr); $c++) {
1860
-                                $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1861
-                                if (!empty($buffer[5])) {
1862
-                                    if (in_array($buffer[5], geodir_get_posttypes())) {
1863
-                                        $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1864
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
1865
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1866
-                                            $catids_arr[] = $cat->slug;
1867
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1868
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1869
-                                            $catids_arr[] = $cat->slug;
1870
-                                        }
1871
-                                    }
1872
-                                }
1873
-                            }
1874
-                        }
1841
+						if ($customKeyarray[0] == '') {
1842
+							echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=wrong';
1843
+							exit;
1844
+						}
1845
+					} elseif (!empty($buffer)) {
1846
+
1847
+						$total_records++;
1848
+
1849
+						$post_title = addslashes($buffer[0]);
1850
+						$current_post_author = $buffer[1];
1851
+						$post_desc = addslashes($buffer[2]);
1852
+						$post_cat = array();
1853
+						$catids_arr = array();
1854
+						$post_cat = trim($buffer[3]); // comma seperated category name
1855
+
1856
+						if ($post_cat) {
1857
+							$post_cat_arr = explode(',', $post_cat);
1858
+
1859
+							for ($c = 0; $c < count($post_cat_arr); $c++) {
1860
+								$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1861
+								if (!empty($buffer[5])) {
1862
+									if (in_array($buffer[5], geodir_get_posttypes())) {
1863
+										$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1864
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
1865
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1866
+											$catids_arr[] = $cat->slug;
1867
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1868
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1869
+											$catids_arr[] = $cat->slug;
1870
+										}
1871
+									}
1872
+								}
1873
+							}
1874
+						}
1875 1875
 
1876
-                        if (!$catids_arr) {
1877
-                            $catids_arr[] = 1;
1878
-                        }
1876
+						if (!$catids_arr) {
1877
+							$catids_arr[] = 1;
1878
+						}
1879 1879
 
1880
-                        $post_tags = trim($buffer[4]); // comma seperated tags
1880
+						$post_tags = trim($buffer[4]); // comma seperated tags
1881 1881
 
1882
-                        $tag_arr = '';
1883
-                        if ($post_tags) {
1882
+						$tag_arr = '';
1883
+						if ($post_tags) {
1884 1884
 
1885
-                            $tag_arr = explode(',', $post_tags);
1886
-                        }
1885
+							$tag_arr = explode(',', $post_tags);
1886
+						}
1887 1887
 
1888
-                        $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1888
+						$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1889 1889
 
1890
-                        $error = '';
1891
-                        if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1890
+						$error = '';
1891
+						if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1892 1892
 
1893
-                            $invalid_post_type++;
1894
-                            continue;
1893
+							$invalid_post_type++;
1894
+							continue;
1895 1895
 
1896
-                        }
1896
+						}
1897 1897
 
1898
-                        if ($post_title != '') {
1898
+						if ($post_title != '') {
1899 1899
 
1900
-                            $menu_order = 0;
1900
+							$menu_order = 0;
1901 1901
 
1902
-                            $image_folder_name = 'uplaod/';
1902
+							$image_folder_name = 'uplaod/';
1903 1903
 
1904
-                            $image_names = array();
1904
+							$image_names = array();
1905 1905
 
1906
-                            for ($c = 5; $c < count($customKeyarray); $c++) {
1907
-                                $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1906
+							for ($c = 5; $c < count($customKeyarray); $c++) {
1907
+								$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1908 1908
 
1909
-                                if ($customKeyarray[$c] == 'IMAGE') {
1910
-                                    $buffer[$c] = trim($buffer[$c]);
1911
-                                    if (!empty($buffer[$c])) {
1912
-                                        $image_names[] = $buffer[$c];
1913
-                                    }
1909
+								if ($customKeyarray[$c] == 'IMAGE') {
1910
+									$buffer[$c] = trim($buffer[$c]);
1911
+									if (!empty($buffer[$c])) {
1912
+										$image_names[] = $buffer[$c];
1913
+									}
1914 1914
 
1915
-                                }
1915
+								}
1916 1916
 
1917
-                                if ($customKeyarray[$c] == 'alive_days') {
1918
-                                    if ($buffer[$c] != '0' && $buffer[$c] != '') {
1919
-                                        $submitdata = date('Y-m-d');
1920
-                                        $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1921
-                                    } else {
1922
-                                        $gd_post_info['expire_date'] = 'Never';
1923
-                                    }
1924
-                                }
1917
+								if ($customKeyarray[$c] == 'alive_days') {
1918
+									if ($buffer[$c] != '0' && $buffer[$c] != '') {
1919
+										$submitdata = date('Y-m-d');
1920
+										$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1921
+									} else {
1922
+										$gd_post_info['expire_date'] = 'Never';
1923
+									}
1924
+								}
1925 1925
 
1926 1926
 
1927
-                                if ($customKeyarray[$c] == 'post_city') {
1928
-                                    $post_city = addslashes($buffer[$c]);
1929
-                                }
1927
+								if ($customKeyarray[$c] == 'post_city') {
1928
+									$post_city = addslashes($buffer[$c]);
1929
+								}
1930 1930
 
1931
-                                if ($customKeyarray[$c] == 'post_region') {
1932
-                                    $post_region = addslashes($buffer[$c]);
1933
-                                }
1931
+								if ($customKeyarray[$c] == 'post_region') {
1932
+									$post_region = addslashes($buffer[$c]);
1933
+								}
1934 1934
 
1935
-                                if ($customKeyarray[$c] == 'post_country') {
1936
-                                    $post_country = addslashes($buffer[$c]);
1937
-                                }
1935
+								if ($customKeyarray[$c] == 'post_country') {
1936
+									$post_country = addslashes($buffer[$c]);
1937
+								}
1938 1938
 
1939
-                                if ($customKeyarray[$c] == 'post_latitude') {
1940
-                                    $post_latitude = addslashes($buffer[$c]);
1941
-                                }
1939
+								if ($customKeyarray[$c] == 'post_latitude') {
1940
+									$post_latitude = addslashes($buffer[$c]);
1941
+								}
1942 1942
 
1943
-                                if ($customKeyarray[$c] == 'post_longitude') {
1944
-                                    $post_longitude = addslashes($buffer[$c]);
1945
-                                }
1943
+								if ($customKeyarray[$c] == 'post_longitude') {
1944
+									$post_longitude = addslashes($buffer[$c]);
1945
+								}
1946 1946
 
1947
-                            }
1947
+							}
1948 1948
 
1949
-                            /* ================ before array create ============== */
1949
+							/* ================ before array create ============== */
1950 1950
 
1951
-                            $location_result = geodir_get_default_location();
1951
+							$location_result = geodir_get_default_location();
1952 1952
 
1953
-                            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'] == '')) {
1953
+							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'] == '')) {
1954 1954
 
1955
-                                $blank_address++;
1956
-                                continue;
1955
+								$blank_address++;
1956
+								continue;
1957 1957
 
1958
-                            } elseif ($location_result->location_id == 0) {
1958
+							} elseif ($location_result->location_id == 0) {
1959 1959
 
1960
-                                if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) ||
1961
-                                    (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) ||
1962
-                                    (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))
1963
-                                ) {
1960
+								if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) ||
1961
+									(geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) ||
1962
+									(geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))
1963
+								) {
1964 1964
 
1965
-                                    $address_invalid++;
1966
-                                    continue;
1965
+									$address_invalid++;
1966
+									continue;
1967 1967
 
1968
-                                }
1968
+								}
1969 1969
 
1970
-                            }
1970
+							}
1971 1971
 
1972 1972
 
1973
-                            $my_post['post_title'] = $post_title;
1974
-                            $my_post['post_content'] = $post_desc;
1975
-                            $my_post['post_type'] = addslashes($buffer[5]);
1976
-                            $my_post['post_author'] = $current_post_author;
1977
-                            $my_post['post_status'] = 'publish';
1978
-                            $my_post['post_category'] = $catids_arr;
1979
-                            $my_post['post_tags'] = $tag_arr;
1973
+							$my_post['post_title'] = $post_title;
1974
+							$my_post['post_content'] = $post_desc;
1975
+							$my_post['post_type'] = addslashes($buffer[5]);
1976
+							$my_post['post_author'] = $current_post_author;
1977
+							$my_post['post_status'] = 'publish';
1978
+							$my_post['post_category'] = $catids_arr;
1979
+							$my_post['post_tags'] = $tag_arr;
1980 1980
 
1981 1981
 
1982
-                            $gd_post_info['post_tags'] = $tag_arr;
1983
-                            $gd_post_info['post_title'] = $post_title;
1984
-                            $gd_post_info['post_status'] = 'publish';
1985
-                            $gd_post_info['submit_time'] = time();
1986
-                            $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1982
+							$gd_post_info['post_tags'] = $tag_arr;
1983
+							$gd_post_info['post_title'] = $post_title;
1984
+							$gd_post_info['post_status'] = 'publish';
1985
+							$gd_post_info['submit_time'] = time();
1986
+							$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1987 1987
 
1988 1988
 
1989
-                            $last_postid = wp_insert_post($my_post);
1990
-                            $countpost++;
1989
+							$last_postid = wp_insert_post($my_post);
1990
+							$countpost++;
1991 1991
 
1992 1992
 
1993
-                            // Check if we need to save post location as new location
1993
+							// Check if we need to save post location as new location
1994 1994
 
1995
-                            if ($location_result->location_id > 0) {
1996
-                                if (isset($post_city) && isset($post_region)) {
1995
+							if ($location_result->location_id > 0) {
1996
+								if (isset($post_city) && isset($post_region)) {
1997 1997
 
1998
-                                    $request_info['post_location'] = array('city' => $post_city,
1999
-                                        'region' => $post_region,
2000
-                                        'country' => $post_country,
2001
-                                        'geo_lat' => $post_latitude,
2002
-                                        'geo_lng' => $post_longitude);
1998
+									$request_info['post_location'] = array('city' => $post_city,
1999
+										'region' => $post_region,
2000
+										'country' => $post_country,
2001
+										'geo_lat' => $post_latitude,
2002
+										'geo_lng' => $post_longitude);
2003 2003
 
2004
-                                    $post_location_info = $request_info['post_location'];
2005
-                                    if ($location_id = geodir_add_new_location($post_location_info))
2006
-                                        $post_location_id = $location_id;
2004
+									$post_location_info = $request_info['post_location'];
2005
+									if ($location_id = geodir_add_new_location($post_location_info))
2006
+										$post_location_id = $location_id;
2007 2007
 
2008
-                                } else {
2009
-                                    $post_location_id = 0;
2010
-                                }
2011
-                            } else {
2012
-                                $post_location_id = 0;
2013
-                            }
2008
+								} else {
2009
+									$post_location_id = 0;
2010
+								}
2011
+							} else {
2012
+								$post_location_id = 0;
2013
+							}
2014 2014
 
2015
-                            /* ------- get default package info ----- */
2016
-                            $payment_info = array();
2017
-                            $package_info = array();
2015
+							/* ------- get default package info ----- */
2016
+							$payment_info = array();
2017
+							$package_info = array();
2018 2018
 
2019
-                            $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2020
-                            $package_id = '';
2021
-                            if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2022
-                                $package_id = $gd_post_info['package_id'];
2023
-                            }
2019
+							$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2020
+							$package_id = '';
2021
+							if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2022
+								$package_id = $gd_post_info['package_id'];
2023
+							}
2024 2024
 
2025
-                            if (!empty($package_info)) {
2026
-                                $payment_info['package_id'] = $package_info['pid'];
2027
-                                if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2028
-                                    $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2029
-                                } else {
2030
-                                    $payment_info['expire_date'] = 'Never';
2031
-                                }
2025
+							if (!empty($package_info)) {
2026
+								$payment_info['package_id'] = $package_info['pid'];
2027
+								if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2028
+									$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2029
+								} else {
2030
+									$payment_info['expire_date'] = 'Never';
2031
+								}
2032 2032
 
2033
-                                $gd_post_info = array_merge($gd_post_info, $payment_info);
2034
-                            }
2033
+								$gd_post_info = array_merge($gd_post_info, $payment_info);
2034
+							}
2035 2035
 
2036 2036
 
2037
-                            $gd_post_info['post_location_id'] = $post_location_id;
2037
+							$gd_post_info['post_location_id'] = $post_location_id;
2038 2038
 
2039
-                            $post_type = get_post_type($last_postid);
2039
+							$post_type = get_post_type($last_postid);
2040 2040
 
2041
-                            $table = $plugin_prefix . $post_type . '_detail';
2041
+							$table = $plugin_prefix . $post_type . '_detail';
2042 2042
 
2043
-                            geodir_save_post_info($last_postid, $gd_post_info);
2043
+							geodir_save_post_info($last_postid, $gd_post_info);
2044 2044
 
2045
-                            if (!empty($image_names)) {
2046
-                                $upload_files++;
2047
-                                $menu_order = 1;
2048
-                                foreach ($image_names as $image_name) {
2045
+							if (!empty($image_names)) {
2046
+								$upload_files++;
2047
+								$menu_order = 1;
2048
+								foreach ($image_names as $image_name) {
2049 2049
 
2050
-                                    $img_name_arr = explode('.', $image_name);
2050
+									$img_name_arr = explode('.', $image_name);
2051 2051
 
2052
-                                    $uploads = wp_upload_dir();
2053
-                                    $sub_dir = $uploads['subdir'];
2052
+									$uploads = wp_upload_dir();
2053
+									$sub_dir = $uploads['subdir'];
2054 2054
 
2055
-                                    $arr_file_type = wp_check_filetype($image_name);
2056
-                                    $uploaded_file_type = $arr_file_type['type'];
2055
+									$arr_file_type = wp_check_filetype($image_name);
2056
+									$uploaded_file_type = $arr_file_type['type'];
2057 2057
 
2058
-                                    $attachment = array();
2059
-                                    $attachment['post_id'] = $last_postid;
2060
-                                    $attachment['title'] = $img_name_arr[0];
2061
-                                    $attachment['content'] = '';
2062
-                                    $attachment['file'] = $sub_dir . '/' . $image_name;
2063
-                                    $attachment['mime_type'] = $uploaded_file_type;
2064
-                                    $attachment['menu_order'] = $menu_order;
2065
-                                    $attachment['is_featured'] = 0;
2058
+									$attachment = array();
2059
+									$attachment['post_id'] = $last_postid;
2060
+									$attachment['title'] = $img_name_arr[0];
2061
+									$attachment['content'] = '';
2062
+									$attachment['file'] = $sub_dir . '/' . $image_name;
2063
+									$attachment['mime_type'] = $uploaded_file_type;
2064
+									$attachment['menu_order'] = $menu_order;
2065
+									$attachment['is_featured'] = 0;
2066 2066
 
2067
-                                    $attachment_set = '';
2067
+									$attachment_set = '';
2068 2068
 
2069
-                                    foreach ($attachment as $key => $val) {
2070
-                                        if ($val != '')
2071
-                                            $attachment_set .= $key . " = '" . $val . "', ";
2072
-                                    }
2069
+									foreach ($attachment as $key => $val) {
2070
+										if ($val != '')
2071
+											$attachment_set .= $key . " = '" . $val . "', ";
2072
+									}
2073 2073
 
2074
-                                    $attachment_set = trim($attachment_set, ", ");
2074
+									$attachment_set = trim($attachment_set, ", ");
2075 2075
 
2076
-                                    $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2076
+									$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2077 2077
 
2078
-                                    if ($menu_order == 1) {
2078
+									if ($menu_order == 1) {
2079 2079
 
2080
-                                        $post_type = get_post_type($last_postid);
2080
+										$post_type = get_post_type($last_postid);
2081 2081
 
2082
-                                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2082
+										$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2083 2083
 
2084
-                                    }
2084
+									}
2085 2085
 
2086
-                                    $menu_order++;
2087
-                                }
2088
-                            }
2086
+									$menu_order++;
2087
+								}
2088
+							}
2089 2089
 
2090
-                            $gd_post_info['package_id'] = $package_id;
2090
+							$gd_post_info['package_id'] = $package_id;
2091 2091
 
2092
-                            /** This action is documented in geodirectory-functions/post-functions.php */
2093
-                            do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2092
+							/** This action is documented in geodirectory-functions/post-functions.php */
2093
+							do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2094 2094
 
2095
-                            if (!empty($buffer[5])) {
2096
-                                if (in_array($buffer[5], geodir_get_posttypes())) {
2095
+							if (!empty($buffer[5])) {
2096
+								if (in_array($buffer[5], geodir_get_posttypes())) {
2097 2097
 
2098
-                                    $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2099
-                                    wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2100
-                                    wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2098
+									$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2099
+									wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2100
+									wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2101 2101
 
2102 2102
 
2103
-                                    $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2103
+									$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2104 2104
 
2105
-                                    $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2106
-                                    geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2105
+									$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2106
+									geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2107 2107
 
2108
-                                }
2108
+								}
2109 2109
 
2110
-                            }
2110
+							}
2111
+
2112
+						} else {
2113
+							$invalid_title++;
2114
+						}
2115
+					}
2116
+					$rowcount++;
2117
+				}
2118
+				fclose($fd);
2119
+				//unlink($csv_target_path);
2120
+				//rmdir($destination_path);
2121
+				if (!empty($filename))
2122
+					geodir_remove_temp_images();
2111 2123
 
2112
-                        } else {
2113
-                            $invalid_title++;
2114
-                        }
2115
-                    }
2116
-                    $rowcount++;
2117
-                }
2118
-                fclose($fd);
2119
-                //unlink($csv_target_path);
2120
-                //rmdir($destination_path);
2121
-                if (!empty($filename))
2122
-                    geodir_remove_temp_images();
2123
-
2124
-
2125
-                echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&msg=success&rowcount=' . $countpost . '&invalidcount=' . $address_invalid . '&blank_address=' . $blank_address . '&upload_files=' . $upload_files . '&invalid_post_type=' . $invalid_post_type . '&invalid_title=' . $invalid_title . '&total_records=' . $total_records;
2126
-                exit;
2127
-            } else {
2128
-                echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=csvonly';
2129
-                exit;
2130
-            }
2131
-        }
2132 2124
 
2133
-    }
2125
+				echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&msg=success&rowcount=' . $countpost . '&invalidcount=' . $address_invalid . '&blank_address=' . $blank_address . '&upload_files=' . $upload_files . '&invalid_post_type=' . $invalid_post_type . '&invalid_title=' . $invalid_title . '&total_records=' . $total_records;
2126
+				exit;
2127
+			} else {
2128
+				echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=csvonly';
2129
+				exit;
2130
+			}
2131
+		}
2132
+
2133
+	}
2134 2134
 }
2135 2135
 
2136 2136
 /**
@@ -2146,105 +2146,105 @@  discard block
 block discarded – undo
2146 2146
  */
2147 2147
 function geodir_admin_fields($options)
2148 2148
 {
2149
-    global $geodirectory;
2150
-
2151
-    $first_title = true;
2152
-    $tab_id = '';
2153
-    $i = 0;
2154
-    foreach ($options as $value) :
2155
-        if (!isset($value['name'])) $value['name'] = '';
2156
-        if (!isset($value['class'])) $value['class'] = '';
2157
-        if (!isset($value['css'])) $value['css'] = '';
2158
-        if (!isset($value['std'])) $value['std'] = '';
2159
-        $desc = '';
2160
-        switch ($value['type']) :
2161
-            case 'dummy_installer':
2162
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
2163
-                geodir_autoinstall_admin_header($post_type);
2164
-                break;
2165
-            case 'csv_installer':
2166
-                geodir_insert_csv_post_data();
2167
-                break;
2168
-            case 'title':
2169
-
2170
-                if ($i == 0) {
2171
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
2172
-                    echo '<div class="inner_content_tab_main">';
2173
-                }
2149
+	global $geodirectory;
2150
+
2151
+	$first_title = true;
2152
+	$tab_id = '';
2153
+	$i = 0;
2154
+	foreach ($options as $value) :
2155
+		if (!isset($value['name'])) $value['name'] = '';
2156
+		if (!isset($value['class'])) $value['class'] = '';
2157
+		if (!isset($value['css'])) $value['css'] = '';
2158
+		if (!isset($value['std'])) $value['std'] = '';
2159
+		$desc = '';
2160
+		switch ($value['type']) :
2161
+			case 'dummy_installer':
2162
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
2163
+				geodir_autoinstall_admin_header($post_type);
2164
+				break;
2165
+			case 'csv_installer':
2166
+				geodir_insert_csv_post_data();
2167
+				break;
2168
+			case 'title':
2169
+
2170
+				if ($i == 0) {
2171
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
2172
+					echo '<div class="inner_content_tab_main">';
2173
+				}
2174 2174
 
2175
-                $i++;
2175
+				$i++;
2176 2176
 
2177
-                if (isset($value['id']) && $value['id'])
2178
-                    $tab_id = $value['id'];
2177
+				if (isset($value['id']) && $value['id'])
2178
+					$tab_id = $value['id'];
2179 2179
 
2180
-                if (isset($value['desc']) && $value['desc'])
2181
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
2180
+				if (isset($value['desc']) && $value['desc'])
2181
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
2182 2182
 
2183
-                if (isset($value['name']) && $value['name']) {
2184
-                    if ($first_title === true) {
2185
-                        $first_title = false;
2186
-                    } else {
2187
-                        echo '</div>';
2188
-                    }
2189
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
2183
+				if (isset($value['name']) && $value['name']) {
2184
+					if ($first_title === true) {
2185
+						$first_title = false;
2186
+					} else {
2187
+						echo '</div>';
2188
+					}
2189
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
2190 2190
 
2191
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
2192
-                }
2191
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
2192
+				}
2193 2193
 
2194
-                /**
2195
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
2196
-                 *
2197
-                 * The action is called dynamically geodir_settings_$value['id'].
2198
-                 *
2199
-                 * @since 1.0.0
2200
-                 */
2201
-                do_action('geodir_settings_' . sanitize_title($value['id']));
2202
-                break;
2203
-
2204
-            case 'no_tabs':
2205
-
2206
-                echo '<div class="inner_content_tab_main">';
2207
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
2208
-
2209
-                break;
2210
-
2211
-            case 'sectionstart':
2212
-                if (isset($value['desc']) && $value['desc'])
2213
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
2214
-                if (isset($value['name']) && $value['name'])
2215
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
2216
-                /**
2217
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
2218
-                 *
2219
-                 * The action is called dynamically geodir_settings_$value['id']_start.
2220
-                 *
2221
-                 * @since 1.0.0
2222
-                 */
2223
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
2224
-                echo '<table class="form-table">' . "\n\n";
2225
-
2226
-                break;
2227
-            case 'sectionend':
2228
-                /**
2229
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
2230
-                 *
2231
-                 * The action is called dynamically geodir_settings_$value['id']_end.
2232
-                 *
2233
-                 * @since 1.0.0
2234
-                 */
2235
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
2236
-                echo '</table>';
2237
-                /**
2238
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
2239
-                 *
2240
-                 * The action is called dynamically geodir_settings_$value['id']_end.
2241
-                 *
2242
-                 * @since 1.0.0
2243
-                 */
2244
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
2245
-                break;
2246
-            case 'text':
2247
-                ?>
2194
+				/**
2195
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
2196
+				 *
2197
+				 * The action is called dynamically geodir_settings_$value['id'].
2198
+				 *
2199
+				 * @since 1.0.0
2200
+				 */
2201
+				do_action('geodir_settings_' . sanitize_title($value['id']));
2202
+				break;
2203
+
2204
+			case 'no_tabs':
2205
+
2206
+				echo '<div class="inner_content_tab_main">';
2207
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
2208
+
2209
+				break;
2210
+
2211
+			case 'sectionstart':
2212
+				if (isset($value['desc']) && $value['desc'])
2213
+					$desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
2214
+				if (isset($value['name']) && $value['name'])
2215
+					echo '<h3>' . $value['name'] . $desc . '</h3>';
2216
+				/**
2217
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
2218
+				 *
2219
+				 * The action is called dynamically geodir_settings_$value['id']_start.
2220
+				 *
2221
+				 * @since 1.0.0
2222
+				 */
2223
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
2224
+				echo '<table class="form-table">' . "\n\n";
2225
+
2226
+				break;
2227
+			case 'sectionend':
2228
+				/**
2229
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
2230
+				 *
2231
+				 * The action is called dynamically geodir_settings_$value['id']_end.
2232
+				 *
2233
+				 * @since 1.0.0
2234
+				 */
2235
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
2236
+				echo '</table>';
2237
+				/**
2238
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
2239
+				 *
2240
+				 * The action is called dynamically geodir_settings_$value['id']_end.
2241
+				 *
2242
+				 * @since 1.0.0
2243
+				 */
2244
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
2245
+				break;
2246
+			case 'text':
2247
+				?>
2248 2248
                 <tr valign="top">
2249 2249
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
2250 2250
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -2253,15 +2253,15 @@  discard block
 block discarded – undo
2253 2253
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2254 2254
                                            style=" <?php echo esc_attr($value['css']); ?>"
2255 2255
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
2256
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
2257
-                                           } else {
2258
-                                               echo esc_attr($value['std']);
2259
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
2256
+											   echo esc_attr(stripslashes(get_option($value['id'])));
2257
+										   } else {
2258
+											   echo esc_attr($value['std']);
2259
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
2260 2260
                 </tr><?php
2261
-                break;
2261
+				break;
2262 2262
 
2263
-            case 'password':
2264
-                ?>
2263
+			case 'password':
2264
+				?>
2265 2265
                 <tr valign="top">
2266 2266
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
2267 2267
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -2270,42 +2270,42 @@  discard block
 block discarded – undo
2270 2270
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
2271 2271
                                            style="<?php echo esc_attr($value['css']); ?>"
2272 2272
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
2273
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
2274
-                                           } else {
2275
-                                               echo esc_attr($value['std']);
2276
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
2273
+											   echo esc_attr(stripslashes(get_option($value['id'])));
2274
+										   } else {
2275
+											   echo esc_attr($value['std']);
2276
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
2277 2277
                 </tr><?php
2278
-                break;
2278
+				break;
2279 2279
 
2280
-            case 'html_content':
2281
-                ?>
2280
+			case 'html_content':
2281
+				?>
2282 2282
                 <tr valign="top">
2283 2283
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
2284 2284
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
2285 2285
                 </tr><?php
2286
-                break;
2286
+				break;
2287 2287
 
2288
-            case 'color' :
2289
-                ?>
2288
+			case 'color' :
2289
+				?>
2290 2290
                 <tr valign="top">
2291 2291
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
2292 2292
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
2293 2293
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
2294 2294
                                            style="<?php echo esc_attr($value['css']); ?>"
2295 2295
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
2296
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
2297
-                                           } else {
2298
-                                               echo esc_attr($value['std']);
2299
-                                           } ?>" class="colorpick"/> <span
2296
+											   echo esc_attr(stripslashes(get_option($value['id'])));
2297
+										   } else {
2298
+											   echo esc_attr($value['std']);
2299
+										   } ?>" class="colorpick"/> <span
2300 2300
                         class="description"><?php echo $value['desc']; ?></span>
2301 2301
 
2302 2302
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
2303 2303
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
2304 2304
                 </td>
2305 2305
                 </tr><?php
2306
-                break;
2307
-            case 'image_width' :
2308
-                ?>
2306
+				break;
2307
+			case 'image_width' :
2308
+				?>
2309 2309
                 <tr valign="top">
2310 2310
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2311 2311
                 <td class="forminp">
@@ -2327,9 +2327,9 @@  discard block
 block discarded – undo
2327 2327
 
2328 2328
                     <span class="description"><?php echo $value['desc'] ?></span></td>
2329 2329
                 </tr><?php
2330
-                break;
2331
-            case 'select':
2332
-                ?>
2330
+				break;
2331
+			case 'select':
2332
+				?>
2333 2333
                 <tr valign="top">
2334 2334
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2335 2335
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -2338,30 +2338,30 @@  discard block
 block discarded – undo
2338 2338
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
2339 2339
                                             option-ajaxchosen="false">
2340 2340
                         <?php
2341
-                        foreach ($value['options'] as $key => $val) {
2342
-                            $geodir_select_value = '';
2343
-                            if (get_option($value['id']) != '') {
2344
-                                if (get_option($value['id']) != '' && get_option($value['id']) == $key)
2345
-                                    $geodir_select_value = ' selected="selected" ';
2346
-                            } else {
2347
-                                if ($value['std'] == $key)
2348
-                                    $geodir_select_value = ' selected="selected" ';
2349
-                            }
2341
+						foreach ($value['options'] as $key => $val) {
2342
+							$geodir_select_value = '';
2343
+							if (get_option($value['id']) != '') {
2344
+								if (get_option($value['id']) != '' && get_option($value['id']) == $key)
2345
+									$geodir_select_value = ' selected="selected" ';
2346
+							} else {
2347
+								if ($value['std'] == $key)
2348
+									$geodir_select_value = ' selected="selected" ';
2349
+							}
2350 2350
 
2351 2351
 
2352
-                            ?>
2352
+							?>
2353 2353
                             <option
2354 2354
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option>
2355 2355
                         <?php
2356
-                        }
2357
-                        ?>
2356
+						}
2357
+						?>
2358 2358
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
2359 2359
                 </td>
2360 2360
                 </tr><?php
2361
-                break;
2361
+				break;
2362 2362
 
2363
-            case 'multiselect':
2364
-                ?>
2363
+			case 'multiselect':
2364
+				?>
2365 2365
                 <tr valign="top">
2366 2366
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
2367 2367
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -2371,27 +2371,27 @@  discard block
 block discarded – undo
2371 2371
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
2372 2372
                                             option-ajaxchosen="false">
2373 2373
                         <?php
2374
-                        foreach ($value['options'] as $key => $val) {
2375
-                            if (strpos($key, 'optgroup_start-') === 0) {
2376
-                                ?><optgroup label="<?php echo ucfirst($val); ?>"><?php
2377
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
2378
-                                ?></optgroup><?php
2379
-                            } else {
2380
-                                ?>
2374
+						foreach ($value['options'] as $key => $val) {
2375
+							if (strpos($key, 'optgroup_start-') === 0) {
2376
+								?><optgroup label="<?php echo ucfirst($val); ?>"><?php
2377
+							} else if (strpos($key, 'optgroup_end-') === 0) {
2378
+								?></optgroup><?php
2379
+							} else {
2380
+								?>
2381 2381
                                 <option
2382 2382
                                     value="<?php echo esc_attr($key); ?>" <?php if (is_array(get_option($value['id']))) {
2383
-                                    if (in_array($key, get_option($value['id']))) { ?> selected="selected" <?php }
2384
-                                } ?>><?php echo ucfirst($val) ?></option>
2383
+									if (in_array($key, get_option($value['id']))) { ?> selected="selected" <?php }
2384
+								} ?>><?php echo ucfirst($val) ?></option>
2385 2385
                             <?php
2386
-                            }
2387
-                        }
2388
-                        ?>
2386
+							}
2387
+						}
2388
+						?>
2389 2389
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
2390 2390
                 </td>
2391 2391
                 </tr><?php
2392
-                break;
2393
-            case 'file':
2394
-                ?>
2392
+				break;
2393
+			case 'file':
2394
+				?>
2395 2395
                 <tr valign="top">
2396 2396
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
2397 2397
                 <td class="forminp">
@@ -2411,87 +2411,87 @@  discard block
 block discarded – undo
2411 2411
                     <?php } ?>
2412 2412
                 </td>
2413 2413
                 </tr><?php
2414
-                break;
2415
-            case 'map_default_settings' :
2416
-                ?>
2414
+				break;
2415
+			case 'map_default_settings' :
2416
+				?>
2417 2417
 
2418 2418
                 <tr valign="top">
2419 2419
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
2420 2420
                     <td width="60%">
2421 2421
                         <select name="geodir_default_map_language" style="width:60%">
2422 2422
                             <?php
2423
-                            $arr_map_langages = array(
2424
-                                'ar' => __('ARABIC', 'geodirectory'),
2425
-                                'eu' => __('BASQUE', 'geodirectory'),
2426
-                                'bg' => __('BULGARIAN', 'geodirectory'),
2427
-                                'bn' => __('BENGALI', 'geodirectory'),
2428
-                                'ca' => __('CATALAN', 'geodirectory'),
2429
-                                'cs' => __('CZECH', 'geodirectory'),
2430
-                                'da' => __('DANISH', 'geodirectory'),
2431
-                                'de' => __('GERMAN', 'geodirectory'),
2432
-                                'el' => __('GREEK', 'geodirectory'),
2433
-                                'en' => __('ENGLISH', 'geodirectory'),
2434
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
2435
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
2436
-                                'es' => __('SPANISH', 'geodirectory'),
2437
-                                'eu' => __('BASQUE', 'geodirectory'),
2438
-                                'fa' => __('FARSI', 'geodirectory'),
2439
-                                'fi' => __('FINNISH', 'geodirectory'),
2440
-                                'fil' => __('FILIPINO', 'geodirectory'),
2441
-                                'fr' => __('FRENCH', 'geodirectory'),
2442
-                                'gl' => __('GALICIAN', 'geodirectory'),
2443
-                                'gu' => __('GUJARATI', 'geodirectory'),
2444
-                                'hi' => __('HINDI', 'geodirectory'),
2445
-                                'hr' => __('CROATIAN', 'geodirectory'),
2446
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
2447
-                                'id' => __('INDONESIAN', 'geodirectory'),
2448
-                                'it' => __('ITALIAN', 'geodirectory'),
2449
-                                'iw' => __('HEBREW', 'geodirectory'),
2450
-                                'ja' => __('JAPANESE', 'geodirectory'),
2451
-                                'kn' => __('KANNADA', 'geodirectory'),
2452
-                                'ko' => __('KOREAN', 'geodirectory'),
2453
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
2454
-                                'lv' => __('LATVIAN', 'geodirectory'),
2455
-                                'ml' => __('MALAYALAM', 'geodirectory'),
2456
-                                'mr' => __('MARATHI', 'geodirectory'),
2457
-                                'nl' => __('DUTCH', 'geodirectory'),
2458
-                                'no' => __('NORWEGIAN', 'geodirectory'),
2459
-                                'pl' => __('POLISH', 'geodirectory'),
2460
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
2461
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
2462
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
2463
-                                'ro' => __('ROMANIAN', 'geodirectory'),
2464
-                                'ru' => __('RUSSIAN', 'geodirectory'),
2465
-                                'ru' => __('RUSSIAN', 'geodirectory'),
2466
-                                'sk' => __('SLOVAK', 'geodirectory'),
2467
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
2468
-                                'sr' => __('SERBIAN', 'geodirectory'),
2469
-                                'sv' => __('	SWEDISH', 'geodirectory'),
2470
-                                'tl' => __('TAGALOG', 'geodirectory'),
2471
-                                'ta' => __('TAMIL', 'geodirectory'),
2472
-                                'te' => __('TELUGU', 'geodirectory'),
2473
-                                'th' => __('THAI', 'geodirectory'),
2474
-                                'tr' => __('TURKISH', 'geodirectory'),
2475
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
2476
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
2477
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
2478
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
2479
-                            );
2480
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
2481
-                            if (empty($geodir_default_map_language))
2482
-                                $geodir_default_map_language = 'en';
2483
-                            foreach ($arr_map_langages as $language_key => $language_txt) {
2484
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
2485
-                                    $geodir_default_language_selected = "selected='selected'";
2486
-                                else
2487
-                                    $geodir_default_language_selected = '';
2488
-
2489
-                                ?>
2423
+							$arr_map_langages = array(
2424
+								'ar' => __('ARABIC', 'geodirectory'),
2425
+								'eu' => __('BASQUE', 'geodirectory'),
2426
+								'bg' => __('BULGARIAN', 'geodirectory'),
2427
+								'bn' => __('BENGALI', 'geodirectory'),
2428
+								'ca' => __('CATALAN', 'geodirectory'),
2429
+								'cs' => __('CZECH', 'geodirectory'),
2430
+								'da' => __('DANISH', 'geodirectory'),
2431
+								'de' => __('GERMAN', 'geodirectory'),
2432
+								'el' => __('GREEK', 'geodirectory'),
2433
+								'en' => __('ENGLISH', 'geodirectory'),
2434
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
2435
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
2436
+								'es' => __('SPANISH', 'geodirectory'),
2437
+								'eu' => __('BASQUE', 'geodirectory'),
2438
+								'fa' => __('FARSI', 'geodirectory'),
2439
+								'fi' => __('FINNISH', 'geodirectory'),
2440
+								'fil' => __('FILIPINO', 'geodirectory'),
2441
+								'fr' => __('FRENCH', 'geodirectory'),
2442
+								'gl' => __('GALICIAN', 'geodirectory'),
2443
+								'gu' => __('GUJARATI', 'geodirectory'),
2444
+								'hi' => __('HINDI', 'geodirectory'),
2445
+								'hr' => __('CROATIAN', 'geodirectory'),
2446
+								'hu' => __('HUNGARIAN', 'geodirectory'),
2447
+								'id' => __('INDONESIAN', 'geodirectory'),
2448
+								'it' => __('ITALIAN', 'geodirectory'),
2449
+								'iw' => __('HEBREW', 'geodirectory'),
2450
+								'ja' => __('JAPANESE', 'geodirectory'),
2451
+								'kn' => __('KANNADA', 'geodirectory'),
2452
+								'ko' => __('KOREAN', 'geodirectory'),
2453
+								'lt' => __('LITHUANIAN', 'geodirectory'),
2454
+								'lv' => __('LATVIAN', 'geodirectory'),
2455
+								'ml' => __('MALAYALAM', 'geodirectory'),
2456
+								'mr' => __('MARATHI', 'geodirectory'),
2457
+								'nl' => __('DUTCH', 'geodirectory'),
2458
+								'no' => __('NORWEGIAN', 'geodirectory'),
2459
+								'pl' => __('POLISH', 'geodirectory'),
2460
+								'pt' => __('PORTUGUESE', 'geodirectory'),
2461
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
2462
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
2463
+								'ro' => __('ROMANIAN', 'geodirectory'),
2464
+								'ru' => __('RUSSIAN', 'geodirectory'),
2465
+								'ru' => __('RUSSIAN', 'geodirectory'),
2466
+								'sk' => __('SLOVAK', 'geodirectory'),
2467
+								'sl' => __('SLOVENIAN', 'geodirectory'),
2468
+								'sr' => __('SERBIAN', 'geodirectory'),
2469
+								'sv' => __('	SWEDISH', 'geodirectory'),
2470
+								'tl' => __('TAGALOG', 'geodirectory'),
2471
+								'ta' => __('TAMIL', 'geodirectory'),
2472
+								'te' => __('TELUGU', 'geodirectory'),
2473
+								'th' => __('THAI', 'geodirectory'),
2474
+								'tr' => __('TURKISH', 'geodirectory'),
2475
+								'uk' => __('UKRAINIAN', 'geodirectory'),
2476
+								'vi' => __('VIETNAMESE', 'geodirectory'),
2477
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
2478
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
2479
+							);
2480
+							$geodir_default_map_language = get_option('geodir_default_map_language');
2481
+							if (empty($geodir_default_map_language))
2482
+								$geodir_default_map_language = 'en';
2483
+							foreach ($arr_map_langages as $language_key => $language_txt) {
2484
+								if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
2485
+									$geodir_default_language_selected = "selected='selected'";
2486
+								else
2487
+									$geodir_default_language_selected = '';
2488
+
2489
+								?>
2490 2490
                                 <option
2491 2491
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
2492 2492
 
2493 2493
                             <?php }
2494
-                            ?>
2494
+							?>
2495 2495
                         </select>
2496 2496
                     </td>
2497 2497
                 </tr>
@@ -2502,46 +2502,46 @@  discard block
 block discarded – undo
2502 2502
                     <td width="60%">
2503 2503
                         <select name="geodir_default_map_search_pt" style="width:60%">
2504 2504
                             <?php
2505
-                            $post_types = geodir_get_posttypes('array');
2506
-                            $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
2507
-                            if (empty($geodir_default_map_search_pt))
2508
-                                $geodir_default_map_search_pt = 'gd_place';
2509
-                            if (is_array($post_types)) {
2510
-                                foreach ($post_types as $key => $post_types_obj) {
2511
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
2512
-                                        $geodir_search_pt_selected = "selected='selected'";
2513
-                                    else
2514
-                                        $geodir_search_pt_selected = '';
2515
-
2516
-                                    ?>
2505
+							$post_types = geodir_get_posttypes('array');
2506
+							$geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
2507
+							if (empty($geodir_default_map_search_pt))
2508
+								$geodir_default_map_search_pt = 'gd_place';
2509
+							if (is_array($post_types)) {
2510
+								foreach ($post_types as $key => $post_types_obj) {
2511
+									if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
2512
+										$geodir_search_pt_selected = "selected='selected'";
2513
+									else
2514
+										$geodir_search_pt_selected = '';
2515
+
2516
+									?>
2517 2517
                                     <option
2518 2518
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option>
2519 2519
 
2520 2520
                                 <?php }
2521 2521
 
2522
-                            }
2522
+							}
2523 2523
 
2524
-                            ?>
2524
+							?>
2525 2525
                         </select>
2526 2526
                     </td>
2527 2527
                 </tr>
2528 2528
 
2529 2529
                 <?php
2530
-                break;
2530
+				break;
2531 2531
 
2532
-            case 'map':
2533
-                ?>
2532
+			case 'map':
2533
+				?>
2534 2534
                 <tr valign="top">
2535 2535
                     <td class="forminp">
2536 2536
                         <?php
2537
-                        global $post_cat, $cat_display;
2538
-                        $post_types = geodir_get_posttypes('object');
2539
-                        $cat_display = 'checkbox';
2540
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
2541
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
2542
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
2543
-                        $count = 1;
2544
-                        ?>
2537
+						global $post_cat, $cat_display;
2538
+						$post_types = geodir_get_posttypes('object');
2539
+						$cat_display = 'checkbox';
2540
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
2541
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
2542
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
2543
+						$count = 1;
2544
+						?>
2545 2545
                         <table width="70%" class="widefat">
2546 2546
                             <thead>
2547 2547
                             <tr>
@@ -2550,18 +2550,18 @@  discard block
 block discarded – undo
2550 2550
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
2551 2551
                             </tr>
2552 2552
                             <?php
2553
-                            $gd_categs = $gd_cats;
2554
-                            foreach ($post_types as $key => $post_types_obj) :
2555
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
2556
-                                $gd_taxonomy = geodir_get_taxonomies($key);
2557
-                                if ($gd_cats_upgrade) {
2558
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
2559
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
2560
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
2561
-                                }
2562
-                                $post_cat = implode(',', $gd_cats);
2563
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
2564
-                                ?>
2553
+							$gd_categs = $gd_cats;
2554
+							foreach ($post_types as $key => $post_types_obj) :
2555
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
2556
+								$gd_taxonomy = geodir_get_taxonomies($key);
2557
+								if ($gd_cats_upgrade) {
2558
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
2559
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
2560
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
2561
+								}
2562
+								$post_cat = implode(',', $gd_cats);
2563
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
2564
+								?>
2565 2565
                                 <tr>
2566 2566
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
2567 2567
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -2582,19 +2582,19 @@  discard block
 block discarded – undo
2582 2582
                     </td>
2583 2583
                 </tr>
2584 2584
                 <?php
2585
-                break;
2585
+				break;
2586 2586
 
2587
-            case 'checkbox' :
2587
+			case 'checkbox' :
2588 2588
 
2589
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
2590
-                    ?>
2589
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
2590
+					?>
2591 2591
                     <tr valign="top">
2592 2592
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2593 2593
                     <td class="forminp">
2594 2594
                 <?php
2595
-                endif;
2595
+				endif;
2596 2596
 
2597
-                ?>
2597
+				?>
2598 2598
                 <fieldset>
2599 2599
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
2600 2600
                     <label for="<?php echo $value['id'] ?>">
@@ -2604,49 +2604,49 @@  discard block
 block discarded – undo
2604 2604
                 </fieldset>
2605 2605
                 <?php
2606 2606
 
2607
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
2608
-                    ?>
2607
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
2608
+					?>
2609 2609
                     </td>
2610 2610
                     </tr>
2611 2611
                 <?php
2612
-                endif;
2612
+				endif;
2613 2613
 
2614
-                break;
2614
+				break;
2615 2615
 
2616
-            case 'radio' :
2616
+			case 'radio' :
2617 2617
 
2618
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
2619
-                    ?>
2618
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
2619
+					?>
2620 2620
                     <tr valign="top">
2621 2621
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2622 2622
                     <td class="forminp">
2623 2623
                 <?php
2624
-                endif;
2624
+				endif;
2625 2625
 
2626
-                ?>
2626
+				?>
2627 2627
                 <fieldset>
2628 2628
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
2629 2629
                     <label for="<?php echo $value['id'];?>">
2630 2630
                         <input name="<?php echo esc_attr($value['id']); ?>"
2631 2631
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
2632 2632
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
2633
-                            echo 'checked="checked"';
2634
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
2633
+							echo 'checked="checked"';
2634
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
2635 2635
                         <?php echo $value['desc']; ?></label><br>
2636 2636
                 </fieldset>
2637 2637
                 <?php
2638 2638
 
2639
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
2640
-                    ?>
2639
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
2640
+					?>
2641 2641
                     </td>
2642 2642
                     </tr>
2643 2643
                 <?php
2644
-                endif;
2644
+				endif;
2645 2645
 
2646
-                break;
2646
+				break;
2647 2647
 
2648
-            case 'textarea':
2649
-                ?>
2648
+			case 'textarea':
2649
+				?>
2650 2650
                 <tr valign="top">
2651 2651
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2652 2652
                 <td class="forminp">
@@ -2659,32 +2659,32 @@  discard block
 block discarded – undo
2659 2659
 
2660 2660
                 </td>
2661 2661
                 </tr><?php
2662
-                break;
2662
+				break;
2663 2663
 
2664
-            case 'editor':
2665
-                ?>
2664
+			case 'editor':
2665
+				?>
2666 2666
                 <tr valign="top">
2667 2667
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2668 2668
                 <td class="forminp"><?php
2669 2669
 
2670
-                    $content = '';
2671
-                    if (get_option($value['id']))
2672
-                        $content = stripslashes(get_option($value['id']));
2673
-                    else
2674
-                        $content = $value['std'];
2670
+					$content = '';
2671
+					if (get_option($value['id']))
2672
+						$content = stripslashes(get_option($value['id']));
2673
+					else
2674
+						$content = $value['std'];
2675 2675
 
2676
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
2676
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
2677 2677
 
2678
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
2678
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
2679 2679
 
2680
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
2680
+					?> <span class="description"><?php echo $value['desc'] ?></span>
2681 2681
 
2682 2682
                 </td>
2683 2683
                 </tr><?php
2684
-                break;
2684
+				break;
2685 2685
 
2686
-            case 'single_select_page' :
2687
-                // WPML
2686
+			case 'single_select_page' :
2687
+				// WPML
2688 2688
 				$switch_lang = false;
2689 2689
 				$disabled = '';
2690 2690
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -2702,18 +2702,18 @@  discard block
 block discarded – undo
2702 2702
 				//
2703 2703
 				$page_setting = (int)get_option($value['id']);
2704 2704
 
2705
-                $args = array('name' => $value['id'],
2706
-                    'id' => $value['id'],
2707
-                    'sort_column' => 'menu_order',
2708
-                    'sort_order' => 'ASC',
2709
-                    'show_option_none' => ' ',
2710
-                    'class' => $value['class'],
2711
-                    'echo' => false,
2712
-                    'selected' => $page_setting);
2705
+				$args = array('name' => $value['id'],
2706
+					'id' => $value['id'],
2707
+					'sort_column' => 'menu_order',
2708
+					'sort_order' => 'ASC',
2709
+					'show_option_none' => ' ',
2710
+					'class' => $value['class'],
2711
+					'echo' => false,
2712
+					'selected' => $page_setting);
2713 2713
 
2714
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
2714
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
2715 2715
 
2716
-                ?>
2716
+				?>
2717 2717
                 <tr valign="top" class="single_select_page">
2718 2718
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2719 2719
                 <td class="forminp">
@@ -2724,18 +2724,18 @@  discard block
 block discarded – undo
2724 2724
 				if ($switch_lang) {
2725 2725
 					$sitepress->switch_lang($switch_lang, true);
2726 2726
 				}
2727
-                break;
2728
-            case 'single_select_country' :
2729
-                $countries = $geodirectory->countries->countries;
2730
-                $country_setting = (string)get_option($value['id']);
2731
-                if (strstr($country_setting, ':')) :
2732
-                    $country = current(explode(':', $country_setting));
2733
-                    $state = end(explode(':', $country_setting));
2734
-                else :
2735
-                    $country = $country_setting;
2736
-                    $state = '*';
2737
-                endif;
2738
-                ?>
2727
+				break;
2728
+			case 'single_select_country' :
2729
+				$countries = $geodirectory->countries->countries;
2730
+				$country_setting = (string)get_option($value['id']);
2731
+				if (strstr($country_setting, ':')) :
2732
+					$country = current(explode(':', $country_setting));
2733
+					$state = end(explode(':', $country_setting));
2734
+				else :
2735
+					$country = $country_setting;
2736
+					$state = '*';
2737
+				endif;
2738
+				?>
2739 2739
                 <tr valign="top">
2740 2740
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
2741 2741
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -2746,12 +2746,12 @@  discard block
 block discarded – undo
2746 2746
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
2747 2747
                 </td>
2748 2748
                 </tr><?php
2749
-                break;
2750
-            case 'multi_select_countries' :
2751
-                $countries = $geodirectory->countries->countries;
2752
-                asort($countries);
2753
-                $selections = (array)get_option($value['id']);
2754
-                ?>
2749
+				break;
2750
+			case 'multi_select_countries' :
2751
+				$countries = $geodirectory->countries->countries;
2752
+				asort($countries);
2753
+				$selections = (array)get_option($value['id']);
2754
+				?>
2755 2755
                 <tr valign="top">
2756 2756
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2757 2757
                 <td class="forminp">
@@ -2759,22 +2759,22 @@  discard block
 block discarded – undo
2759 2759
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
2760 2760
                             title="Country" class="chosen_select">
2761 2761
                         <?php
2762
-                        if ($countries) foreach ($countries as $key => $val) :
2763
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
2764
-                        endforeach;
2765
-                        ?>
2762
+						if ($countries) foreach ($countries as $key => $val) :
2763
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
2764
+						endforeach;
2765
+						?>
2766 2766
                     </select>
2767 2767
                 </td>
2768 2768
                 </tr>
2769 2769
 
2770 2770
                 <?php
2771 2771
 
2772
-                break;
2772
+				break;
2773 2773
 
2774
-            case 'google_analytics' :
2775
-                $selections = (array)get_option($value['id']);
2776
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
2777
-                    ?>
2774
+			case 'google_analytics' :
2775
+				$selections = (array)get_option($value['id']);
2776
+				if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
2777
+					?>
2778 2778
                     <tr valign="top">
2779 2779
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
2780 2780
                         <td class="forminp">
@@ -2782,19 +2782,19 @@  discard block
 block discarded – undo
2782 2782
 
2783 2783
                             <?php
2784 2784
 
2785
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
2786
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
2787
-                            $state = "&state=123";//any string
2788
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2789
-                            $response_type = "&response_type=code";
2790
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
2791
-                            $access_type = "&access_type=offline";
2792
-                            $approval_prompt = "&approval_prompt=force";
2785
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
2786
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
2787
+							$state = "&state=123";//any string
2788
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2789
+							$response_type = "&response_type=code";
2790
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
2791
+							$access_type = "&access_type=offline";
2792
+							$approval_prompt = "&approval_prompt=force";
2793 2793
 
2794
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
2794
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
2795 2795
 
2796 2796
 
2797
-                            ?>
2797
+							?>
2798 2798
                             <script>
2799 2799
                                 function gd_ga_popup() {
2800 2800
                                     var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
@@ -2809,47 +2809,47 @@  discard block
 block discarded – undo
2809 2809
                             </script>
2810 2810
 
2811 2811
                             <?php
2812
-                            if (get_option('gd_ga_refresh_token')) {
2813
-                                ?>
2812
+							if (get_option('gd_ga_refresh_token')) {
2813
+								?>
2814 2814
                                 <span class="button-primary"
2815 2815
                                       onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
2816 2816
                                 <span
2817 2817
                                     style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
2818 2818
                             <?php
2819
-                            } else {
2820
-                                ?>
2819
+							} else {
2820
+								?>
2821 2821
                                 <span class="button-primary"
2822 2822
                                       onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
2823 2823
                             <?php
2824
-                            }
2825
-                            ?>
2824
+							}
2825
+							?>
2826 2826
                         </td>
2827 2827
                     </tr>
2828 2828
 
2829 2829
                 <?php
2830
-                }
2830
+				}
2831 2831
 
2832
-                break;
2832
+				break;
2833 2833
 
2834
-            case 'field_seperator' :
2834
+			case 'field_seperator' :
2835 2835
 
2836
-                ?>
2836
+				?>
2837 2837
                 <tr valign="top">
2838 2838
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
2839 2839
                 </tr>
2840 2840
                 <?php
2841 2841
 
2842
-                break;
2842
+				break;
2843 2843
 
2844
-        endswitch;
2844
+		endswitch;
2845 2845
 
2846
-    endforeach;
2846
+	endforeach;
2847 2847
 
2848
-    if ($first_title === false) {
2849
-        echo "</div>";
2850
-    }
2848
+	if ($first_title === false) {
2849
+		echo "</div>";
2850
+	}
2851 2851
 
2852
-    ?>
2852
+	?>
2853 2853
 
2854 2854
     <script type="text/javascript">
2855 2855
 
@@ -2909,33 +2909,33 @@  discard block
 block discarded – undo
2909 2909
  */
2910 2910
 function geodir_post_info_setting()
2911 2911
 {
2912
-    global $post, $post_id;
2913
-
2914
-    $post_type = get_post_type();
2915
-
2916
-    $package_info = array();
2917
-
2918
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2919
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
2920
-    echo '<div id="geodir_wrapper">';
2921
-    /**
2922
-     * Called before the GD custom fields are output in the wp-admin area.
2923
-     *
2924
-     * @since 1.0.0
2925
-     * @see 'geodir_after_default_field_in_meta_box'
2926
-     */
2927
-    do_action('geodir_before_default_field_in_meta_box');
2928
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2929
-    // to display all fields in one information box
2930
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2931
-    /**
2932
-     * Called after the GD custom fields are output in the wp-admin area.
2933
-     *
2934
-     * @since 1.0.0
2935
-     * @see 'geodir_before_default_field_in_meta_box'
2936
-     */
2937
-    do_action('geodir_after_default_field_in_meta_box');
2938
-    echo '</div>';
2912
+	global $post, $post_id;
2913
+
2914
+	$post_type = get_post_type();
2915
+
2916
+	$package_info = array();
2917
+
2918
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2919
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
2920
+	echo '<div id="geodir_wrapper">';
2921
+	/**
2922
+	 * Called before the GD custom fields are output in the wp-admin area.
2923
+	 *
2924
+	 * @since 1.0.0
2925
+	 * @see 'geodir_after_default_field_in_meta_box'
2926
+	 */
2927
+	do_action('geodir_before_default_field_in_meta_box');
2928
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2929
+	// to display all fields in one information box
2930
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2931
+	/**
2932
+	 * Called after the GD custom fields are output in the wp-admin area.
2933
+	 *
2934
+	 * @since 1.0.0
2935
+	 * @see 'geodir_before_default_field_in_meta_box'
2936
+	 */
2937
+	do_action('geodir_after_default_field_in_meta_box');
2938
+	echo '</div>';
2939 2939
 }
2940 2940
 
2941 2941
 /**
@@ -2948,18 +2948,18 @@  discard block
 block discarded – undo
2948 2948
  */
2949 2949
 function geodir_post_addinfo_setting()
2950 2950
 {
2951
-    global $post, $post_id;
2951
+	global $post, $post_id;
2952 2952
 
2953
-    $post_type = get_post_type();
2953
+	$post_type = get_post_type();
2954 2954
 
2955
-    $package_info = array();
2955
+	$package_info = array();
2956 2956
 
2957
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2957
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2958 2958
 
2959
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2960
-    echo '<div id="geodir_wrapper">';
2961
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2962
-    echo '</div>';
2959
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2960
+	echo '<div id="geodir_wrapper">';
2961
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2962
+	echo '</div>';
2963 2963
 
2964 2964
 }
2965 2965
 
@@ -2973,60 +2973,60 @@  discard block
 block discarded – undo
2973 2973
  */
2974 2974
 function geodir_post_attachments()
2975 2975
 {
2976
-    global $post, $post_id;
2976
+	global $post, $post_id;
2977 2977
 
2978
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2978
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2979 2979
 
2980
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
2981
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2982
-        geodir_show_featured_image($post_id, 'thumbnail');
2983
-    }
2980
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
2981
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2982
+		geodir_show_featured_image($post_id, 'thumbnail');
2983
+	}
2984 2984
 
2985
-    $image_limit = 0;
2985
+	$image_limit = 0;
2986 2986
 
2987
-    ?>
2987
+	?>
2988 2988
 
2989 2989
 
2990 2990
     <h5 class="form_title">
2991 2991
         <?php if ($image_limit != 0 && $image_limit == 1) {
2992
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2993
-        } ?>
2992
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2993
+		} ?>
2994 2994
         <?php if ($image_limit != 0 && $image_limit > 1) {
2995
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2996
-        } ?>
2995
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2996
+		} ?>
2997 2997
         <?php if ($image_limit == 0) {
2998
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2999
-        } ?>
2998
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2999
+		} ?>
3000 3000
     </h5>
3001 3001
 
3002 3002
 
3003 3003
     <?php
3004 3004
 
3005
-    $curImages = geodir_get_images($post_id);
3006
-    $place_img_array = array();
3005
+	$curImages = geodir_get_images($post_id);
3006
+	$place_img_array = array();
3007 3007
 
3008
-    if (!empty($curImages)):
3009
-        foreach ($curImages as $p_img):
3010
-            $place_img_array[] = $p_img->src;
3011
-        endforeach;
3012
-    endif;
3008
+	if (!empty($curImages)):
3009
+		foreach ($curImages as $p_img):
3010
+			$place_img_array[] = $p_img->src;
3011
+		endforeach;
3012
+	endif;
3013 3013
 
3014
-    if (!empty($place_img_array))
3015
-        $curImages = implode(',', $place_img_array);
3014
+	if (!empty($place_img_array))
3015
+		$curImages = implode(',', $place_img_array);
3016 3016
 
3017 3017
 
3018
-    // adjust values here
3019
-    $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
3018
+	// adjust values here
3019
+	$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
3020 3020
 
3021
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
3021
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
3022 3022
 
3023
-    $multiple = true; // allow multiple files upload
3023
+	$multiple = true; // allow multiple files upload
3024 3024
 
3025
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
3025
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
3026 3026
 
3027
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
3027
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
3028 3028
 
3029
-    ?>
3029
+	?>
3030 3030
 
3031 3031
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
3032 3032
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -3068,13 +3068,13 @@  discard block
 block discarded – undo
3068 3068
  */
3069 3069
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
3070 3070
 {
3071
-    $post_type = get_post_type($post_ID);
3071
+	$post_type = get_post_type($post_ID);
3072 3072
 
3073
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
3074
-        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) {
3075
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
3076
-        }
3077
-    }
3073
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
3074
+		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) {
3075
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
3076
+		}
3077
+	}
3078 3078
 }
3079 3079
 
3080 3080
 /**
@@ -3089,39 +3089,39 @@  discard block
 block discarded – undo
3089 3089
  */
3090 3090
 function geodir_notification_add_bcc_option($settings)
3091 3091
 {
3092
-    if (!empty($settings)) {
3093
-        $new_settings = array();
3094
-        foreach ($settings as $setting) {
3095
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
3096
-                $geodir_bcc_listing_published_yes = array(
3097
-                    'name' => __('Listing published', 'geodirectory'),
3098
-                    'desc' => __('Yes', 'geodirectory'),
3099
-                    'id' => 'geodir_bcc_listing_published',
3100
-                    'std' => 'yes',
3101
-                    'type' => 'radio',
3102
-                    'value' => '1',
3103
-                    'radiogroup' => 'start'
3104
-                );
3105
-
3106
-                $geodir_bcc_listing_published_no = array(
3107
-                    'name' => __('Listing published', 'geodirectory'),
3108
-                    'desc' => __('No', 'geodirectory'),
3109
-                    'id' => 'geodir_bcc_listing_published',
3110
-                    'std' => 'yes',
3111
-                    'type' => 'radio',
3112
-                    'value' => '0',
3113
-                    'radiogroup' => 'end'
3114
-                );
3115
-
3116
-                $new_settings[] = $geodir_bcc_listing_published_yes;
3117
-                $new_settings[] = $geodir_bcc_listing_published_no;
3118
-            }
3119
-            $new_settings[] = $setting;
3120
-        }
3121
-        $settings = $new_settings;
3122
-    }
3092
+	if (!empty($settings)) {
3093
+		$new_settings = array();
3094
+		foreach ($settings as $setting) {
3095
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
3096
+				$geodir_bcc_listing_published_yes = array(
3097
+					'name' => __('Listing published', 'geodirectory'),
3098
+					'desc' => __('Yes', 'geodirectory'),
3099
+					'id' => 'geodir_bcc_listing_published',
3100
+					'std' => 'yes',
3101
+					'type' => 'radio',
3102
+					'value' => '1',
3103
+					'radiogroup' => 'start'
3104
+				);
3105
+
3106
+				$geodir_bcc_listing_published_no = array(
3107
+					'name' => __('Listing published', 'geodirectory'),
3108
+					'desc' => __('No', 'geodirectory'),
3109
+					'id' => 'geodir_bcc_listing_published',
3110
+					'std' => 'yes',
3111
+					'type' => 'radio',
3112
+					'value' => '0',
3113
+					'radiogroup' => 'end'
3114
+				);
3115
+
3116
+				$new_settings[] = $geodir_bcc_listing_published_yes;
3117
+				$new_settings[] = $geodir_bcc_listing_published_no;
3118
+			}
3119
+			$new_settings[] = $setting;
3120
+		}
3121
+		$settings = $new_settings;
3122
+	}
3123 3123
 
3124
-    return $settings;
3124
+	return $settings;
3125 3125
 }
3126 3126
 
3127 3127
 
@@ -3136,19 +3136,19 @@  discard block
 block discarded – undo
3136 3136
  */
3137 3137
 function get_gd_theme_compat_callback()
3138 3138
 {
3139
-    global $wpdb;
3140
-    $themes = get_option('gd_theme_compats');
3141
-
3142
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
3143
-        if (isset($_POST['export'])) {
3144
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
3145
-        } else {
3146
-            echo json_encode($themes[$_POST['theme']]);
3147
-        }
3139
+	global $wpdb;
3140
+	$themes = get_option('gd_theme_compats');
3148 3141
 
3149
-    }
3142
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
3143
+		if (isset($_POST['export'])) {
3144
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
3145
+		} else {
3146
+			echo json_encode($themes[$_POST['theme']]);
3147
+		}
3148
+
3149
+	}
3150 3150
 
3151
-    die();
3151
+	die();
3152 3152
 }
3153 3153
 
3154 3154
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -3162,20 +3162,20 @@  discard block
 block discarded – undo
3162 3162
  */
3163 3163
 function get_gd_theme_compat_import_callback()
3164 3164
 {
3165
-    global $wpdb;
3166
-    $themes = get_option('gd_theme_compats');
3167
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
3168
-        $json = json_decode(stripslashes($_POST['theme']), true);
3169
-        if (!empty($json) && is_array($json)) {
3170
-            $key = sanitize_text_field(key($json));
3171
-            $themes[$key] = $json[$key];
3172
-            update_option('gd_theme_compats', $themes);
3173
-            echo $key;
3174
-            die();
3175
-        }
3176
-    }
3177
-    echo '0';
3178
-    die();
3165
+	global $wpdb;
3166
+	$themes = get_option('gd_theme_compats');
3167
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
3168
+		$json = json_decode(stripslashes($_POST['theme']), true);
3169
+		if (!empty($json) && is_array($json)) {
3170
+			$key = sanitize_text_field(key($json));
3171
+			$themes[$key] = $json[$key];
3172
+			update_option('gd_theme_compats', $themes);
3173
+			echo $key;
3174
+			die();
3175
+		}
3176
+	}
3177
+	echo '0';
3178
+	die();
3179 3179
 }
3180 3180
 
3181 3181
 
@@ -3188,39 +3188,39 @@  discard block
 block discarded – undo
3188 3188
  */
3189 3189
 function gd_set_theme_compat()
3190 3190
 {
3191
-    global $wpdb;
3192
-    $theme = wp_get_theme();
3191
+	global $wpdb;
3192
+	$theme = wp_get_theme();
3193 3193
 
3194
-    if ($theme->parent()) {
3195
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
3196
-    } else {
3197
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
3198
-    }
3194
+	if ($theme->parent()) {
3195
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
3196
+	} else {
3197
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
3198
+	}
3199 3199
 
3200
-    $theme_compats = get_option('gd_theme_compats');
3201
-    $current_compat = get_option('gd_theme_compat');
3202
-    $current_compat = str_replace("_custom", "", $current_compat);
3200
+	$theme_compats = get_option('gd_theme_compats');
3201
+	$current_compat = get_option('gd_theme_compat');
3202
+	$current_compat = str_replace("_custom", "", $current_compat);
3203 3203
 
3204
-    if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
3205
-        return;
3206
-    }// if already running corect compat then bail
3204
+	if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
3205
+		return;
3206
+	}// if already running corect compat then bail
3207 3207
 
3208
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
3209
-        update_option('gd_theme_compat', $theme_name);
3210
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
3208
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
3209
+		update_option('gd_theme_compat', $theme_name);
3210
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
3211 3211
 
3212
-        // if there are default options to set then set them
3213
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
3212
+		// if there are default options to set then set them
3213
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
3214 3214
 
3215
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
3216
-                update_option($key, $val);
3217
-            }
3218
-        }
3215
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
3216
+				update_option($key, $val);
3217
+			}
3218
+		}
3219 3219
 
3220
-    } else {
3221
-        update_option('gd_theme_compat', '');
3222
-        update_option('theme_compatibility_setting', '');
3223
-    }
3220
+	} else {
3221
+		update_option('gd_theme_compat', '');
3222
+		update_option('theme_compatibility_setting', '');
3223
+	}
3224 3224
 
3225 3225
 
3226 3226
 }
@@ -3235,9 +3235,9 @@  discard block
 block discarded – undo
3235 3235
  */
3236 3236
 function gd_check_avada_compat()
3237 3237
 {
3238
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
3239
-        add_action('admin_notices', 'gd_avada_compat_warning');
3240
-    }
3238
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
3239
+		add_action('admin_notices', 'gd_avada_compat_warning');
3240
+	}
3241 3241
 }
3242 3242
 
3243 3243
 
@@ -3250,22 +3250,22 @@  discard block
 block discarded – undo
3250 3250
 function gd_avada_compat_warning()
3251 3251
 {
3252 3252
 
3253
-    /*
3253
+	/*
3254 3254
     $msg_type = error
3255 3255
     $msg_type = updated fade
3256 3256
     $msg_type = update-nag
3257 3257
     */
3258 3258
 
3259
-    $plugin = 'avada-nag';
3260
-    $timestamp = 'avada-nag1234';
3261
-    $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');
3262
-    echo '<div id="' . $timestamp . '"  class="error">';
3263
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
3264
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
3265
-    echo "<p>$message</p>";
3266
-    echo "</div>";
3259
+	$plugin = 'avada-nag';
3260
+	$timestamp = 'avada-nag1234';
3261
+	$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');
3262
+	echo '<div id="' . $timestamp . '"  class="error">';
3263
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
3264
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
3265
+	echo "<p>$message</p>";
3266
+	echo "</div>";
3267 3267
 
3268
-    ?>
3268
+	?>
3269 3269
     <script>
3270 3270
         function gdRemoveANotification($plugin, $timestamp) {
3271 3271
 
@@ -3333,10 +3333,10 @@  discard block
 block discarded – undo
3333 3333
  */
3334 3334
 function geodir_avada_remove_notification()
3335 3335
 {
3336
-    update_option('avada_nag', TRUE);
3336
+	update_option('avada_nag', TRUE);
3337 3337
 
3338
-    // Always die in functions echoing ajax content
3339
-    die();
3338
+	// Always die in functions echoing ajax content
3339
+	die();
3340 3340
 }
3341 3341
 
3342 3342
 
@@ -3395,7 +3395,7 @@  discard block
 block discarded – undo
3395 3395
 		// Don't allow same slug url for listing and location
3396 3396
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
3397 3397
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
3398
-        	wp_redirect($redirect_url);
3398
+			wp_redirect($redirect_url);
3399 3399
 			exit;
3400 3400
 		}
3401 3401
 		
@@ -3425,10 +3425,10 @@  discard block
 block discarded – undo
3425 3425
  * @package GeoDirectory
3426 3426
  */
3427 3427
 function geodir_hide_admin_preview_button() {
3428
-    global $post_type;
3429
-    $post_types = geodir_get_posttypes();
3430
-    if(in_array($post_type, $post_types))
3431
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
3428
+	global $post_type;
3429
+	$post_types = geodir_get_posttypes();
3430
+	if(in_array($post_type, $post_types))
3431
+		echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
3432 3432
 }
3433 3433
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
3434 3434
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -3443,7 +3443,7 @@  discard block
 block discarded – undo
3443 3443
  */
3444 3444
 function geodir_import_export_tab( $tabs ) {
3445 3445
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
3446
-    return $tabs;
3446
+	return $tabs;
3447 3447
 }
3448 3448
 
3449 3449
 /**
@@ -3458,26 +3458,26 @@  discard block
 block discarded – undo
3458 3458
 function geodir_import_export_page() {
3459 3459
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
3460 3460
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
3461
-    /**
3462
-     * Filter sample category data csv file url.
3463
-     *
3464
-     * @since 1.0.0
3465
-     * @package GeoDirectory
3466
-     *
3467
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
3468
-     */
3461
+	/**
3462
+	 * Filter sample category data csv file url.
3463
+	 *
3464
+	 * @since 1.0.0
3465
+	 * @package GeoDirectory
3466
+	 *
3467
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
3468
+	 */
3469 3469
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
3470 3470
 	
3471 3471
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
3472
-    /**
3473
-     * Filter sample post data csv file url.
3474
-     *
3475
-     * @since 1.0.0
3476
-     * @package GeoDirectory
3477
-     *
3478
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
3479
-     */
3480
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
3472
+	/**
3473
+	 * Filter sample post data csv file url.
3474
+	 *
3475
+	 * @since 1.0.0
3476
+	 * @package GeoDirectory
3477
+	 *
3478
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
3479
+	 */
3480
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
3481 3481
 	
3482 3482
 	$gd_posttypes = geodir_get_posttypes( 'array' );
3483 3483
 	
@@ -3500,14 +3500,14 @@  discard block
 block discarded – undo
3500 3500
 	$gd_chunksize_options[100000] = 100000;
3501 3501
 	 
3502 3502
 	 /**
3503
-     * Filter max entries per export csv file.
3504
-     *
3505
-     * @since 1.5.6
3506
-     * @package GeoDirectory
3507
-     *
3508
-     * @param string $gd_chunksize_options Entries options.
3509
-     */
3510
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
3503
+	  * Filter max entries per export csv file.
3504
+	  *
3505
+	  * @since 1.5.6
3506
+	  * @package GeoDirectory
3507
+	  *
3508
+	  * @param string $gd_chunksize_options Entries options.
3509
+	  */
3510
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
3511 3511
 	
3512 3512
 	$gd_chunksize_option = '';
3513 3513
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -3523,12 +3523,12 @@  discard block
 block discarded – undo
3523 3523
   <div class="gd-content-heading">
3524 3524
 
3525 3525
   <?php
3526
-    ini_set('max_execution_time', 999999);
3527
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
3528
-    ini_restore('max_execution_time');
3526
+	ini_set('max_execution_time', 999999);
3527
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
3528
+	ini_restore('max_execution_time');
3529 3529
 
3530
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
3531
-        ?>
3530
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
3531
+		?>
3532 3532
 	<div id="gd_ie_reqs" class="metabox-holder">
3533 3533
       <div class="meta-box-sortables ui-sortable">
3534 3534
         <div class="postbox">
@@ -3694,7 +3694,7 @@  discard block
 block discarded – undo
3694 3694
 						 * Called just after the sample CSV download link.
3695 3695
 						 *
3696 3696
 						 * @since 1.0.0
3697
-                         * @package GeoDirectory
3697
+						 * @package GeoDirectory
3698 3698
 						 */
3699 3699
 						do_action('geodir_sample_cats_csv_download_link');
3700 3700
 						?>
@@ -3778,11 +3778,11 @@  discard block
 block discarded – undo
3778 3778
 	 *
3779 3779
 	 * Called after the last setting on the GD > Import & Export page.
3780 3780
 	 * @since 1.4.6
3781
-     * @package GeoDirectory
3781
+	 * @package GeoDirectory
3782 3782
 	 *
3783 3783
 	 * @param array $gd_posttypes GD post types.
3784
-     * @param array $gd_chunksize_options File chunk size options.
3785
-     * @param string $nonce Wordpress security token for GD import & export.
3784
+	 * @param array $gd_chunksize_options File chunk size options.
3785
+	 * @param string $nonce Wordpress security token for GD import & export.
3786 3786
 	 */
3787 3787
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
3788 3788
 	?>
@@ -4422,44 +4422,44 @@  discard block
 block discarded – undo
4422 4422
 function geodir_init_filesystem()
4423 4423
 {
4424 4424
 
4425
-    if(!function_exists('get_filesystem_method')){
4426
-        require_once(ABSPATH."/wp-admin/includes/file.php");
4427
-    }
4428
-    $access_type = get_filesystem_method();
4429
-    if ($access_type === 'direct') {
4430
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
4431
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
4432
-
4433
-        /* initialize the API */
4434
-        if (!WP_Filesystem($creds)) {
4435
-            /* any problems and we exit */
4436
-            //return '@@@3';
4437
-            return false;
4438
-        }
4425
+	if(!function_exists('get_filesystem_method')){
4426
+		require_once(ABSPATH."/wp-admin/includes/file.php");
4427
+	}
4428
+	$access_type = get_filesystem_method();
4429
+	if ($access_type === 'direct') {
4430
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
4431
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
4432
+
4433
+		/* initialize the API */
4434
+		if (!WP_Filesystem($creds)) {
4435
+			/* any problems and we exit */
4436
+			//return '@@@3';
4437
+			return false;
4438
+		}
4439 4439
 
4440
-        global $wp_filesystem;
4441
-        return $wp_filesystem;
4442
-        /* do our file manipulations below */
4443
-    } elseif (defined('FTP_USER')) {
4444
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
4445
-
4446
-        /* initialize the API */
4447
-        if (!WP_Filesystem($creds)) {
4448
-            /* any problems and we exit */
4449
-            //return '@@@33';
4450
-            return false;
4451
-        }
4440
+		global $wp_filesystem;
4441
+		return $wp_filesystem;
4442
+		/* do our file manipulations below */
4443
+	} elseif (defined('FTP_USER')) {
4444
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
4452 4445
 
4453
-        global $wp_filesystem;
4454
-        //return '@@@1';
4455
-        return $wp_filesystem;
4446
+		/* initialize the API */
4447
+		if (!WP_Filesystem($creds)) {
4448
+			/* any problems and we exit */
4449
+			//return '@@@33';
4450
+			return false;
4451
+		}
4456 4452
 
4457
-    } else {
4458
-        //return '@@@2';
4459
-        /* don't have direct write access. Prompt user with our notice */
4460
-        add_action('admin_notice', 'geodir_filesystem_notice');
4461
-        return false;
4462
-    }
4453
+		global $wp_filesystem;
4454
+		//return '@@@1';
4455
+		return $wp_filesystem;
4456
+
4457
+	} else {
4458
+		//return '@@@2';
4459
+		/* don't have direct write access. Prompt user with our notice */
4460
+		add_action('admin_notice', 'geodir_filesystem_notice');
4461
+		return false;
4462
+	}
4463 4463
 
4464 4464
 }
4465 4465
 
@@ -4477,10 +4477,10 @@  discard block
 block discarded – undo
4477 4477
  */
4478 4478
 function geodir_filesystem_notice()
4479 4479
 {   if ( defined( 'DOING_AJAX' ) ){return;}
4480
-    $access_type = get_filesystem_method();
4481
-    if ($access_type === 'direct') {
4482
-    } elseif (!defined('FTP_USER')) {
4483
-        ?>
4480
+	$access_type = get_filesystem_method();
4481
+	if ($access_type === 'direct') {
4482
+	} elseif (!defined('FTP_USER')) {
4483
+		?>
4484 4484
         <div class="error">
4485 4485
             <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'); ?>
4486 4486
                 <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>
@@ -4506,1235 +4506,1235 @@  discard block
 block discarded – undo
4506 4506
  * @return string Json data.
4507 4507
  */
4508 4508
 function geodir_ajax_import_export() {
4509
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
4509
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
4510 4510
     
4511
-    error_reporting(0);
4511
+	error_reporting(0);
4512 4512
 
4513
-    // try to set higher limits for import
4514
-    $max_input_time = ini_get('max_input_time');
4515
-    $max_execution_time = ini_get('max_execution_time');
4516
-    $memory_limit= ini_get('memory_limit');
4513
+	// try to set higher limits for import
4514
+	$max_input_time = ini_get('max_input_time');
4515
+	$max_execution_time = ini_get('max_execution_time');
4516
+	$memory_limit= ini_get('memory_limit');
4517 4517
 
4518
-    if(!$max_input_time || $max_input_time<3000){
4519
-        ini_set('max_input_time', 3000);
4520
-    }
4518
+	if(!$max_input_time || $max_input_time<3000){
4519
+		ini_set('max_input_time', 3000);
4520
+	}
4521 4521
 
4522
-    if(!$max_execution_time || $max_execution_time<3000){
4523
-        ini_set('max_execution_time', 3000);
4524
-    }
4522
+	if(!$max_execution_time || $max_execution_time<3000){
4523
+		ini_set('max_execution_time', 3000);
4524
+	}
4525 4525
 
4526
-    if($memory_limit && str_replace('M','',$memory_limit)){
4527
-        if(str_replace('M','',$memory_limit)<256){
4528
-            ini_set('memory_limit', '256M');
4529
-        }
4530
-    }
4526
+	if($memory_limit && str_replace('M','',$memory_limit)){
4527
+		if(str_replace('M','',$memory_limit)<256){
4528
+			ini_set('memory_limit', '256M');
4529
+		}
4530
+	}
4531 4531
 
4532
-    $json = array();
4532
+	$json = array();
4533 4533
 
4534
-    if ( !current_user_can( 'manage_options' ) ) {
4535
-        wp_send_json( $json );
4536
-    }
4534
+	if ( !current_user_can( 'manage_options' ) ) {
4535
+		wp_send_json( $json );
4536
+	}
4537 4537
 
4538
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
4539
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
4540
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
4538
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
4539
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
4540
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
4541 4541
 
4542
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
4543
-        wp_send_json( $json );
4544
-    }
4542
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
4543
+		wp_send_json( $json );
4544
+	}
4545 4545
 
4546
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
4547
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
4548
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
4549
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
4546
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
4547
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
4548
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
4549
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
4550 4550
 
4551
-    $wp_filesystem = geodir_init_filesystem();
4552
-    if (!$wp_filesystem) {
4553
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
4554
-        wp_send_json( $json );
4555
-    }
4551
+	$wp_filesystem = geodir_init_filesystem();
4552
+	if (!$wp_filesystem) {
4553
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
4554
+		wp_send_json( $json );
4555
+	}
4556 4556
 
4557
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
4558
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
4559
-        wp_send_json( $json );
4560
-    }
4557
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
4558
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
4559
+		wp_send_json( $json );
4560
+	}
4561 4561
 
4562
-    $csv_file_dir = geodir_path_import_export( false );
4563
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
4564
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
4565
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
4566
-            wp_send_json( $json );
4567
-        }
4568
-    }
4562
+	$csv_file_dir = geodir_path_import_export( false );
4563
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
4564
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
4565
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
4566
+			wp_send_json( $json );
4567
+		}
4568
+	}
4569 4569
 
4570
-    switch ( $task ) {
4571
-        case 'export_posts': {
4572
-            // WPML
4573
-            $is_wpml = geodir_is_wpml();
4574
-            if ($is_wpml) {
4575
-                global $sitepress;
4576
-                $active_lang = ICL_LANGUAGE_CODE;
4570
+	switch ( $task ) {
4571
+		case 'export_posts': {
4572
+			// WPML
4573
+			$is_wpml = geodir_is_wpml();
4574
+			if ($is_wpml) {
4575
+				global $sitepress;
4576
+				$active_lang = ICL_LANGUAGE_CODE;
4577 4577
                 
4578
-                $sitepress->switch_lang('all', true);
4579
-            }
4580
-            // WPML
4581
-            if ( $post_type == 'gd_event' ) {
4582
-                //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 );
4583
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
4584
-            }
4585
-            $file_name = $post_type . '_' . date( 'dmyHi' );
4586
-            $posts_count = geodir_get_posts_count( $post_type );
4587
-            $file_url_base = geodir_path_import_export() . '/';
4588
-            $file_url = $file_url_base . $file_name . '.csv';
4589
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
4590
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
4578
+				$sitepress->switch_lang('all', true);
4579
+			}
4580
+			// WPML
4581
+			if ( $post_type == 'gd_event' ) {
4582
+				//add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 );
4583
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
4584
+			}
4585
+			$file_name = $post_type . '_' . date( 'dmyHi' );
4586
+			$posts_count = geodir_get_posts_count( $post_type );
4587
+			$file_url_base = geodir_path_import_export() . '/';
4588
+			$file_url = $file_url_base . $file_name . '.csv';
4589
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
4590
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
4591 4591
             
4592
-            $chunk_file_paths = array();
4592
+			$chunk_file_paths = array();
4593 4593
 
4594
-            if ( isset( $_REQUEST['_st'] ) ) {
4595
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
4596
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
4597
-                $percentage = min( $percentage, 100 );
4594
+			if ( isset( $_REQUEST['_st'] ) ) {
4595
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
4596
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
4597
+				$percentage = min( $percentage, 100 );
4598 4598
                 
4599
-                $json['percentage'] = $percentage;
4600
-                // WPML
4601
-                if ($is_wpml) {
4602
-                    $sitepress->switch_lang($active_lang, true);
4603
-                }
4604
-                // WPML
4605
-                wp_send_json( $json );
4606
-                exit;
4607
-            } else {				
4608
-                if ( !$posts_count > 0 ) {
4609
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
4610
-                } else {
4611
-                    $total_posts = $posts_count;
4612
-                    if ($chunk_per_page > $total_posts) {
4613
-                        $chunk_per_page = $total_posts;
4614
-                    }
4615
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
4599
+				$json['percentage'] = $percentage;
4600
+				// WPML
4601
+				if ($is_wpml) {
4602
+					$sitepress->switch_lang($active_lang, true);
4603
+				}
4604
+				// WPML
4605
+				wp_send_json( $json );
4606
+				exit;
4607
+			} else {				
4608
+				if ( !$posts_count > 0 ) {
4609
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
4610
+				} else {
4611
+					$total_posts = $posts_count;
4612
+					if ($chunk_per_page > $total_posts) {
4613
+						$chunk_per_page = $total_posts;
4614
+					}
4615
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
4616 4616
                     
4617
-                    $j = $chunk_page_no;
4618
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
4617
+					$j = $chunk_page_no;
4618
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
4619 4619
                     
4620
-                    $per_page = 500;
4621
-                    if ($per_page > $chunk_per_page) {
4622
-                        $per_page = $chunk_per_page;
4623
-                    }
4624
-                    $total_pages = ceil( $chunk_per_page / $per_page );
4620
+					$per_page = 500;
4621
+					if ($per_page > $chunk_per_page) {
4622
+						$per_page = $chunk_per_page;
4623
+					}
4624
+					$total_pages = ceil( $chunk_per_page / $per_page );
4625 4625
                     
4626
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4627
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
4626
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
4627
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
4628 4628
                         
4629
-                        $clear = $i == 0 ? true : false;
4630
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
4631
-                    }
4629
+						$clear = $i == 0 ? true : false;
4630
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
4631
+					}
4632 4632
                         
4633
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4634
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4635
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4636
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
4637
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4633
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
4634
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4635
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
4636
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
4637
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
4638 4638
                         
4639
-                        $file_url = $file_url_base . $chunk_file_name;
4640
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4641
-                    }
4639
+						$file_url = $file_url_base . $chunk_file_name;
4640
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4641
+					}
4642 4642
                     
4643
-                    if ( !empty($chunk_file_paths) ) {
4644
-                        $json['total'] = $posts_count;
4645
-                        $json['files'] = $chunk_file_paths;
4646
-                    } else {
4647
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
4648
-                    }
4649
-                }
4650
-                // WPML
4651
-                if ($is_wpml) {
4652
-                    $sitepress->switch_lang($active_lang, true);
4653
-                }
4654
-                // WPML
4655
-                wp_send_json( $json );
4656
-            }
4657
-        }
4658
-        break;
4659
-        case 'export_cats': {
4660
-            // WPML
4661
-            $is_wpml = geodir_is_wpml();
4662
-            if ($is_wpml) {
4663
-                global $sitepress;
4664
-                $active_lang = ICL_LANGUAGE_CODE;
4643
+					if ( !empty($chunk_file_paths) ) {
4644
+						$json['total'] = $posts_count;
4645
+						$json['files'] = $chunk_file_paths;
4646
+					} else {
4647
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
4648
+					}
4649
+				}
4650
+				// WPML
4651
+				if ($is_wpml) {
4652
+					$sitepress->switch_lang($active_lang, true);
4653
+				}
4654
+				// WPML
4655
+				wp_send_json( $json );
4656
+			}
4657
+		}
4658
+		break;
4659
+		case 'export_cats': {
4660
+			// WPML
4661
+			$is_wpml = geodir_is_wpml();
4662
+			if ($is_wpml) {
4663
+				global $sitepress;
4664
+				$active_lang = ICL_LANGUAGE_CODE;
4665 4665
                 
4666
-                $sitepress->switch_lang('all', true);
4667
-            }
4668
-            // WPML
4669
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
4666
+				$sitepress->switch_lang('all', true);
4667
+			}
4668
+			// WPML
4669
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
4670 4670
             
4671
-            $terms_count = geodir_get_terms_count( $post_type );
4672
-            $file_url_base = geodir_path_import_export() . '/';
4673
-            $file_url = $file_url_base . $file_name . '.csv';
4674
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
4675
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
4671
+			$terms_count = geodir_get_terms_count( $post_type );
4672
+			$file_url_base = geodir_path_import_export() . '/';
4673
+			$file_url = $file_url_base . $file_name . '.csv';
4674
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
4675
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
4676 4676
             
4677
-            $chunk_file_paths = array();
4677
+			$chunk_file_paths = array();
4678 4678
             
4679
-            if ( isset( $_REQUEST['_st'] ) ) {
4680
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
4681
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
4682
-                $percentage = min( $percentage, 100 );
4679
+			if ( isset( $_REQUEST['_st'] ) ) {
4680
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
4681
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
4682
+				$percentage = min( $percentage, 100 );
4683 4683
                 
4684
-                $json['percentage'] = $percentage;
4685
-                // WPML
4686
-                if ($is_wpml) {
4687
-                    $sitepress->switch_lang($active_lang, true);
4688
-                }
4689
-                // WPML
4690
-                wp_send_json( $json );
4691
-            } else {				
4692
-                if ( !$terms_count > 0 ) {
4693
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
4694
-                } else {
4695
-                    $total_terms = $terms_count;
4696
-                    if ($chunk_per_page > $terms_count) {
4697
-                        $chunk_per_page = $terms_count;
4698
-                    }
4699
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
4684
+				$json['percentage'] = $percentage;
4685
+				// WPML
4686
+				if ($is_wpml) {
4687
+					$sitepress->switch_lang($active_lang, true);
4688
+				}
4689
+				// WPML
4690
+				wp_send_json( $json );
4691
+			} else {				
4692
+				if ( !$terms_count > 0 ) {
4693
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
4694
+				} else {
4695
+					$total_terms = $terms_count;
4696
+					if ($chunk_per_page > $terms_count) {
4697
+						$chunk_per_page = $terms_count;
4698
+					}
4699
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
4700 4700
                     
4701
-                    $j = $chunk_page_no;					
4702
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
4701
+					$j = $chunk_page_no;					
4702
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
4703 4703
                     
4704
-                    $per_page = 500;
4705
-                    if ($per_page > $chunk_per_page) {
4706
-                        $per_page = $chunk_per_page;
4707
-                    }
4708
-                    $total_pages = ceil( $chunk_per_page / $per_page );
4704
+					$per_page = 500;
4705
+					if ($per_page > $chunk_per_page) {
4706
+						$per_page = $chunk_per_page;
4707
+					}
4708
+					$total_pages = ceil( $chunk_per_page / $per_page );
4709 4709
                     
4710
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4711
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
4710
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
4711
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
4712 4712
                         
4713
-                        $clear = $i == 0 ? true : false;
4714
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
4715
-                    }
4713
+						$clear = $i == 0 ? true : false;
4714
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
4715
+					}
4716 4716
                     
4717
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4718
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4719
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4720
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
4721
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4717
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
4718
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4719
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
4720
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
4721
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
4722 4722
                         
4723
-                        $file_url = $file_url_base . $chunk_file_name;
4724
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4725
-                    }
4723
+						$file_url = $file_url_base . $chunk_file_name;
4724
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4725
+					}
4726 4726
                     
4727
-                    if ( !empty($chunk_file_paths) ) {
4728
-                        $json['total'] = $terms_count;
4729
-                        $json['files'] = $chunk_file_paths;
4730
-                    } else {
4731
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
4732
-                    }
4733
-                }
4734
-                // WPML
4735
-                if ($is_wpml) {
4736
-                    $sitepress->switch_lang($active_lang, true);
4737
-                }
4738
-                // WPML
4739
-                wp_send_json( $json );
4740
-            }
4741
-        }
4742
-        break;
4743
-        case 'export_locations': {
4744
-            $file_url_base = geodir_path_import_export() . '/';
4745
-            $file_name = 'gd_locations_' . date( 'dmyHi' );			
4746
-            $file_url = $file_url_base . $file_name . '.csv';
4747
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
4748
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
4727
+					if ( !empty($chunk_file_paths) ) {
4728
+						$json['total'] = $terms_count;
4729
+						$json['files'] = $chunk_file_paths;
4730
+					} else {
4731
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
4732
+					}
4733
+				}
4734
+				// WPML
4735
+				if ($is_wpml) {
4736
+					$sitepress->switch_lang($active_lang, true);
4737
+				}
4738
+				// WPML
4739
+				wp_send_json( $json );
4740
+			}
4741
+		}
4742
+		break;
4743
+		case 'export_locations': {
4744
+			$file_url_base = geodir_path_import_export() . '/';
4745
+			$file_name = 'gd_locations_' . date( 'dmyHi' );			
4746
+			$file_url = $file_url_base . $file_name . '.csv';
4747
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
4748
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
4749 4749
             
4750
-            $items_count = (int)geodir_location_imex_count_locations();
4750
+			$items_count = (int)geodir_location_imex_count_locations();
4751 4751
             
4752
-            if ( isset( $_REQUEST['_st'] ) ) {
4753
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
4754
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
4755
-                $percentage = min( $percentage, 100 );
4752
+			if ( isset( $_REQUEST['_st'] ) ) {
4753
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
4754
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
4755
+				$percentage = min( $percentage, 100 );
4756 4756
                 
4757
-                $json['percentage'] = $percentage;
4758
-                wp_send_json( $json );
4759
-            } else {
4760
-                $chunk_file_paths = array();
4757
+				$json['percentage'] = $percentage;
4758
+				wp_send_json( $json );
4759
+			} else {
4760
+				$chunk_file_paths = array();
4761 4761
                 
4762
-                if ( !$items_count > 0 ) {
4763
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
4764
-                } else {
4765
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
4766
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
4762
+				if ( !$items_count > 0 ) {
4763
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
4764
+				} else {
4765
+					$chunk_per_page = min( $chunk_per_page, $items_count );
4766
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
4767 4767
                     
4768
-                    $j = $chunk_page_no;					
4769
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
4768
+					$j = $chunk_page_no;					
4769
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
4770 4770
                     
4771
-                    $per_page = 500;
4772
-                    $per_page = min( $per_page, $chunk_per_page );
4773
-                    $total_pages = ceil( $chunk_per_page / $per_page );
4771
+					$per_page = 500;
4772
+					$per_page = min( $per_page, $chunk_per_page );
4773
+					$total_pages = ceil( $chunk_per_page / $per_page );
4774 4774
                     
4775
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4776
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
4775
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
4776
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
4777 4777
                         
4778
-                        $clear = $i == 0 ? true : false;
4779
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
4780
-                    }
4778
+						$clear = $i == 0 ? true : false;
4779
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
4780
+					}
4781 4781
                     
4782
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4783
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4784
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4785
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
4786
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4782
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
4783
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4784
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
4785
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
4786
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
4787 4787
                         
4788
-                        $file_url = $file_url_base . $chunk_file_name;
4789
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4790
-                    }
4788
+						$file_url = $file_url_base . $chunk_file_name;
4789
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4790
+					}
4791 4791
                     
4792
-                    if ( !empty($chunk_file_paths) ) {
4793
-                        $json['total'] = $items_count;
4794
-                        $json['files'] = $chunk_file_paths;
4795
-                    } else {
4796
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
4797
-                    }
4798
-                }
4799
-                wp_send_json( $json );
4800
-            }
4801
-        }
4802
-        break;
4803
-        case 'prepare_import':
4804
-        case 'import_cat':
4805
-        case 'import_post':
4806
-        case 'import_loc': {
4807
-            // WPML
4808
-            $is_wpml = geodir_is_wpml();
4809
-            if ($is_wpml) {
4810
-                global $sitepress;
4811
-                $active_lang = ICL_LANGUAGE_CODE;
4812
-            }
4813
-            // WPML
4792
+					if ( !empty($chunk_file_paths) ) {
4793
+						$json['total'] = $items_count;
4794
+						$json['files'] = $chunk_file_paths;
4795
+					} else {
4796
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
4797
+					}
4798
+				}
4799
+				wp_send_json( $json );
4800
+			}
4801
+		}
4802
+		break;
4803
+		case 'prepare_import':
4804
+		case 'import_cat':
4805
+		case 'import_post':
4806
+		case 'import_loc': {
4807
+			// WPML
4808
+			$is_wpml = geodir_is_wpml();
4809
+			if ($is_wpml) {
4810
+				global $sitepress;
4811
+				$active_lang = ICL_LANGUAGE_CODE;
4812
+			}
4813
+			// WPML
4814 4814
             
4815
-            ini_set( 'auto_detect_line_endings', true );
4815
+			ini_set( 'auto_detect_line_endings', true );
4816 4816
             
4817
-            $uploads = wp_upload_dir();
4818
-            $uploads_dir = $uploads['path'];
4819
-            $uploads_subdir = $uploads['subdir'];
4817
+			$uploads = wp_upload_dir();
4818
+			$uploads_dir = $uploads['path'];
4819
+			$uploads_subdir = $uploads['subdir'];
4820 4820
             
4821
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
4822
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
4821
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
4822
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
4823 4823
             
4824
-            $csv_file_arr = explode( '/', $csv_file );
4825
-            $csv_filename = end( $csv_file_arr );
4826
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
4824
+			$csv_file_arr = explode( '/', $csv_file );
4825
+			$csv_filename = end( $csv_file_arr );
4826
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
4827 4827
             
4828
-            $json['file'] = $csv_file;
4829
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4828
+			$json['file'] = $csv_file;
4829
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4830 4830
 
4831
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4832
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4831
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4832
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4833 4833
                 
4834
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4835
-                    $json['error'] = NULL;
4836
-                    $json['rows'] = 0;
4834
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4835
+					$json['error'] = NULL;
4836
+					$json['rows'] = 0;
4837 4837
                     
4838
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4839
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4840
-                            if ( !empty( $data ) ) {
4841
-                                $file[] = $data;
4842
-                            }
4843
-                        }
4844
-                        fclose($handle);
4845
-                    }
4838
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4839
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4840
+							if ( !empty( $data ) ) {
4841
+								$file[] = $data;
4842
+							}
4843
+						}
4844
+						fclose($handle);
4845
+					}
4846 4846
 
4847
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4847
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4848 4848
                     
4849
-                    if (!$json['rows'] > 0) {
4850
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
4851
-                    }
4852
-                } else {
4853
-                    wp_send_json( $json );
4854
-                }
4855
-            } else {
4856
-                wp_send_json( $json );
4857
-            }
4849
+					if (!$json['rows'] > 0) {
4850
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
4851
+					}
4852
+				} else {
4853
+					wp_send_json( $json );
4854
+				}
4855
+			} else {
4856
+				wp_send_json( $json );
4857
+			}
4858 4858
             
4859
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4860
-                wp_send_json( $json );
4861
-            }
4859
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4860
+				wp_send_json( $json );
4861
+			}
4862 4862
             
4863
-            $total = $json['rows'];
4864
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4865
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4863
+			$total = $json['rows'];
4864
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4865
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4866 4866
             
4867
-            $count = $limit;
4868
-            $requested_limit = $limit;
4867
+			$count = $limit;
4868
+			$requested_limit = $limit;
4869 4869
             
4870
-            if ($count < $total) {
4871
-                $count = $processed + $count;
4872
-                if ($count > $total) {
4873
-                    $count = $total;
4874
-                }
4875
-            } else {
4876
-                $count = $total;
4877
-            }
4870
+			if ($count < $total) {
4871
+				$count = $processed + $count;
4872
+				if ($count > $total) {
4873
+					$count = $total;
4874
+				}
4875
+			} else {
4876
+				$count = $total;
4877
+			}
4878 4878
             
4879
-            $created = 0;
4880
-            $updated = 0;
4881
-            $skipped = 0;
4882
-            $invalid = 0;
4883
-            $invalid_addr = 0;
4884
-            $images = 0;
4879
+			$created = 0;
4880
+			$updated = 0;
4881
+			$skipped = 0;
4882
+			$invalid = 0;
4883
+			$invalid_addr = 0;
4884
+			$images = 0;
4885 4885
             
4886
-            $invalid_title = 0;
4887
-            $customKeyarray = array();
4888
-            $gd_post_info = array();
4889
-            $post_location = array();
4890
-            $countpost = 0;
4886
+			$invalid_title = 0;
4887
+			$customKeyarray = array();
4888
+			$gd_post_info = array();
4889
+			$post_location = array();
4890
+			$countpost = 0;
4891 4891
             
4892
-            $post_types = geodir_get_posttypes();
4892
+			$post_types = geodir_get_posttypes();
4893 4893
 
4894
-            if ( $task == 'import_cat' ) {				
4895
-                if (!empty($file)) {
4896
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4894
+			if ( $task == 'import_cat' ) {				
4895
+				if (!empty($file)) {
4896
+					$columns = isset($file[0]) ? $file[0] : NULL;
4897 4897
                     
4898
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4899
-                        $json['error'] = CSV_INVAILD_FILE;
4900
-                        wp_send_json( $json );
4901
-                        exit;
4902
-                    }
4898
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4899
+						$json['error'] = CSV_INVAILD_FILE;
4900
+						wp_send_json( $json );
4901
+						exit;
4902
+					}
4903 4903
                     
4904
-                    for ($i = 1; $i <= $limit; $i++) {
4905
-                        $index = $processed + $i;
4904
+					for ($i = 1; $i <= $limit; $i++) {
4905
+						$index = $processed + $i;
4906 4906
                         
4907
-                        if (isset($file[$index])) {
4908
-                            $row = $file[$index];
4909
-                            $row = array_map( 'trim', $row );
4910
-                            //$row = array_map( 'utf8_encode', $row );
4907
+						if (isset($file[$index])) {
4908
+							$row = $file[$index];
4909
+							$row = array_map( 'trim', $row );
4910
+							//$row = array_map( 'utf8_encode', $row );
4911 4911
                             
4912
-                            $cat_id = '';
4913
-                            $cat_name = '';
4914
-                            $cat_slug = '';
4915
-                            $cat_posttype = '';
4916
-                            $cat_parent = '';
4917
-                            $cat_description = '';
4918
-                            $cat_schema = '';
4919
-                            $cat_top_description = '';
4920
-                            $cat_image = '';
4921
-                            $cat_icon = '';
4922
-                            $cat_language = '';
4912
+							$cat_id = '';
4913
+							$cat_name = '';
4914
+							$cat_slug = '';
4915
+							$cat_posttype = '';
4916
+							$cat_parent = '';
4917
+							$cat_description = '';
4918
+							$cat_schema = '';
4919
+							$cat_top_description = '';
4920
+							$cat_image = '';
4921
+							$cat_icon = '';
4922
+							$cat_language = '';
4923 4923
                             
4924
-                            $c = 0;
4925
-                            foreach ($columns as $column ) {
4926
-                                if ( $column == 'cat_id' ) {
4927
-                                    $cat_id = (int)$row[$c];
4928
-                                } else if ( $column == 'cat_name' ) {
4929
-                                    $cat_name = $row[$c];
4930
-                                } else if ( $column == 'cat_slug' ) {
4931
-                                    $cat_slug = $row[$c];
4932
-                                } else if ( $column == 'cat_posttype' ) {
4933
-                                    $cat_posttype = $row[$c];
4934
-                                } else if ( $column == 'cat_parent' ) {
4935
-                                    $cat_parent = trim($row[$c]);
4936
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4937
-                                    $cat_schema = $row[$c];
4938
-                                } else if ( $column == 'cat_description' ) {
4939
-                                    $cat_description = $row[$c];
4940
-                                } else if ( $column == 'cat_top_description' ) {
4941
-                                    $cat_top_description = $row[$c];
4942
-                                } else if ( $column == 'cat_image' ) {
4943
-                                    $cat_image = $row[$c];
4944
-                                } else if ( $column == 'cat_icon' ) {
4945
-                                    $cat_icon = $row[$c];
4946
-                                }
4947
-                                // WPML
4948
-                                if ($is_wpml && $column == 'cat_language') {
4949
-                                    $cat_language = geodir_strtolower(trim($row[$c]));
4950
-                                }
4951
-                                // WPML
4952
-                                $c++;
4953
-                            }
4924
+							$c = 0;
4925
+							foreach ($columns as $column ) {
4926
+								if ( $column == 'cat_id' ) {
4927
+									$cat_id = (int)$row[$c];
4928
+								} else if ( $column == 'cat_name' ) {
4929
+									$cat_name = $row[$c];
4930
+								} else if ( $column == 'cat_slug' ) {
4931
+									$cat_slug = $row[$c];
4932
+								} else if ( $column == 'cat_posttype' ) {
4933
+									$cat_posttype = $row[$c];
4934
+								} else if ( $column == 'cat_parent' ) {
4935
+									$cat_parent = trim($row[$c]);
4936
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4937
+									$cat_schema = $row[$c];
4938
+								} else if ( $column == 'cat_description' ) {
4939
+									$cat_description = $row[$c];
4940
+								} else if ( $column == 'cat_top_description' ) {
4941
+									$cat_top_description = $row[$c];
4942
+								} else if ( $column == 'cat_image' ) {
4943
+									$cat_image = $row[$c];
4944
+								} else if ( $column == 'cat_icon' ) {
4945
+									$cat_icon = $row[$c];
4946
+								}
4947
+								// WPML
4948
+								if ($is_wpml && $column == 'cat_language') {
4949
+									$cat_language = geodir_strtolower(trim($row[$c]));
4950
+								}
4951
+								// WPML
4952
+								$c++;
4953
+							}
4954 4954
                             
4955
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4956
-                                $invalid++;
4957
-                                continue;
4958
-                            }
4955
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4956
+								$invalid++;
4957
+								continue;
4958
+							}
4959 4959
                             
4960
-                            // WPML
4961
-                            if ($is_wpml && $cat_language != '') {
4962
-                                $sitepress->switch_lang($cat_language, true);
4963
-                            }
4964
-                            // WPML
4960
+							// WPML
4961
+							if ($is_wpml && $cat_language != '') {
4962
+								$sitepress->switch_lang($cat_language, true);
4963
+							}
4964
+							// WPML
4965 4965
                                                         
4966
-                            $term_data = array();
4967
-                            $term_data['name'] = $cat_name;
4968
-                            $term_data['slug'] = $cat_slug;
4969
-                            $term_data['description'] = $cat_description;
4970
-                            $term_data['cat_schema'] = $cat_schema;
4971
-                            $term_data['top_description'] = $cat_top_description;
4972
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4973
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4966
+							$term_data = array();
4967
+							$term_data['name'] = $cat_name;
4968
+							$term_data['slug'] = $cat_slug;
4969
+							$term_data['description'] = $cat_description;
4970
+							$term_data['cat_schema'] = $cat_schema;
4971
+							$term_data['top_description'] = $cat_top_description;
4972
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4973
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4974 4974
                             
4975
-                            //$term_data = array_map( 'utf8_encode', $term_data );
4975
+							//$term_data = array_map( 'utf8_encode', $term_data );
4976 4976
                             
4977
-                            $taxonomy = $cat_posttype . 'category';
4977
+							$taxonomy = $cat_posttype . 'category';
4978 4978
                             
4979
-                            $term_data['taxonomy'] = $taxonomy;
4979
+							$term_data['taxonomy'] = $taxonomy;
4980 4980
 
4981
-                            $term_parent_id = 0;
4982
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4983
-                                $term_parent = '';
4981
+							$term_parent_id = 0;
4982
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
4983
+								$term_parent = '';
4984 4984
                                 
4985
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4986
-                                    $term_parent = $term_parent;
4987
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4988
-                                    $term_parent = $term_parent;
4989
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4990
-                                    $term_parent = $term_parent;
4991
-                                } else {
4992
-                                    $term_parent_data = array();
4993
-                                    $term_parent_data['name'] = $cat_parent;											
4994
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );										
4995
-                                    $term_parent_data['taxonomy'] = $taxonomy;
4985
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4986
+									$term_parent = $term_parent;
4987
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4988
+									$term_parent = $term_parent;
4989
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4990
+									$term_parent = $term_parent;
4991
+								} else {
4992
+									$term_parent_data = array();
4993
+									$term_parent_data['name'] = $cat_parent;											
4994
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );										
4995
+									$term_parent_data['taxonomy'] = $taxonomy;
4996 4996
                                     
4997
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4998
-                                }
4997
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4998
+								}
4999 4999
                                 
5000
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
5001
-                                    $term_parent_id = (int)$term_parent->term_id;
5002
-                                }
5003
-                            }
5004
-                            $term_data['parent'] = (int)$term_parent_id;
5000
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
5001
+									$term_parent_id = (int)$term_parent->term_id;
5002
+								}
5003
+							}
5004
+							$term_data['parent'] = (int)$term_parent_id;
5005 5005
 
5006
-                            $term_id = NULL;
5007
-                            if ( $import_choice == 'update' ) {
5008
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
5009
-                                    $term_data['term_id'] = $term['term_id'];
5006
+							$term_id = NULL;
5007
+							if ( $import_choice == 'update' ) {
5008
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
5009
+									$term_data['term_id'] = $term['term_id'];
5010 5010
                                     
5011
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
5012
-                                        $updated++;
5013
-                                    } else {
5014
-                                        $invalid++;
5015
-                                    }
5016
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5017
-                                    $term_data['term_id'] = $term['term_id'];
5011
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
5012
+										$updated++;
5013
+									} else {
5014
+										$invalid++;
5015
+									}
5016
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5017
+									$term_data['term_id'] = $term['term_id'];
5018 5018
                                     
5019
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
5020
-                                        $updated++;
5021
-                                    } else {
5022
-                                        $invalid++;
5023
-                                    }
5024
-                                } else {
5025
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
5026
-                                        $created++;
5027
-                                    } else {
5028
-                                        $invalid++;
5029
-                                    }
5030
-                                }
5031
-                            } else if ( $import_choice == 'skip' ) {
5032
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
5033
-                                    $skipped++;
5034
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5035
-                                    $skipped++;
5036
-                                } else {
5037
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {										
5038
-                                        $created++;
5039
-                                    } else {
5040
-                                        $invalid++;
5041
-                                    }
5042
-                                }
5043
-                            } else {
5044
-                                $invalid++;
5045
-                            }
5019
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
5020
+										$updated++;
5021
+									} else {
5022
+										$invalid++;
5023
+									}
5024
+								} else {
5025
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
5026
+										$created++;
5027
+									} else {
5028
+										$invalid++;
5029
+									}
5030
+								}
5031
+							} else if ( $import_choice == 'skip' ) {
5032
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
5033
+									$skipped++;
5034
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5035
+									$skipped++;
5036
+								} else {
5037
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {										
5038
+										$created++;
5039
+									} else {
5040
+										$invalid++;
5041
+									}
5042
+								}
5043
+							} else {
5044
+								$invalid++;
5045
+							}
5046 5046
                             
5047
-                            if ( $term_id ) {
5048
-                                if ( isset( $term_data['top_description'] ) ) {
5049
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
5050
-                                }
5047
+							if ( $term_id ) {
5048
+								if ( isset( $term_data['top_description'] ) ) {
5049
+									update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
5050
+								}
5051 5051
                                 
5052
-                                if ( isset( $term_data['cat_schema'] ) ) {
5053
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
5054
-                                }
5052
+								if ( isset( $term_data['cat_schema'] ) ) {
5053
+									update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
5054
+								}
5055 5055
             
5056
-                                $attachment = false;
5057
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
5058
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
5059
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
5056
+								$attachment = false;
5057
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
5058
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
5059
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
5060 5060
                                     
5061
-                                    if ( basename($cat_image) != $term_data['image'] ) {
5062
-                                        $attachment = true;
5063
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
5064
-                                    }
5065
-                                }
5061
+									if ( basename($cat_image) != $term_data['image'] ) {
5062
+										$attachment = true;
5063
+										update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
5064
+									}
5065
+								}
5066 5066
                                 
5067
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
5068
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
5069
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5067
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
5068
+									$cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
5069
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5070 5070
                                         
5071
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
5072
-                                        $attachment = true;
5073
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
5074
-                                    }
5075
-                                }
5071
+									if ( basename($cat_icon) != $term_data['icon'] ) {
5072
+										$attachment = true;
5073
+										update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
5074
+									}
5075
+								}
5076 5076
                                 
5077
-                                if ( $attachment ) {
5078
-                                    $images++;
5079
-                                }
5080
-                            }
5077
+								if ( $attachment ) {
5078
+									$images++;
5079
+								}
5080
+							}
5081 5081
                             
5082
-                            // WPML
5083
-                            if ($is_wpml && $cat_language != '') {
5084
-                                $sitepress->switch_lang($active_lang, true);
5085
-                            }
5086
-                            // WPML
5087
-                        }
5088
-                    }
5089
-                }
5082
+							// WPML
5083
+							if ($is_wpml && $cat_language != '') {
5084
+								$sitepress->switch_lang($active_lang, true);
5085
+							}
5086
+							// WPML
5087
+						}
5088
+					}
5089
+				}
5090 5090
                 
5091
-                $json = array();
5092
-                $json['processed'] = $limit;
5093
-                $json['created'] = $created;
5094
-                $json['updated'] = $updated;
5095
-                $json['skipped'] = $skipped;
5096
-                $json['invalid'] = $invalid;
5097
-                $json['images'] = $images;
5091
+				$json = array();
5092
+				$json['processed'] = $limit;
5093
+				$json['created'] = $created;
5094
+				$json['updated'] = $updated;
5095
+				$json['skipped'] = $skipped;
5096
+				$json['invalid'] = $invalid;
5097
+				$json['images'] = $images;
5098 5098
                 
5099
-                wp_send_json( $json );
5100
-                exit;
5101
-            } else if ( $task == 'import_post' ) {
5099
+				wp_send_json( $json );
5100
+				exit;
5101
+			} else if ( $task == 'import_post' ) {
5102 5102
 
5103
-                //run some stuff to make the import quicker
5104
-                wp_defer_term_counting( true );
5105
-                wp_defer_comment_counting( true );
5106
-                $wpdb->query( 'SET autocommit = 0;' );
5103
+				//run some stuff to make the import quicker
5104
+				wp_defer_term_counting( true );
5105
+				wp_defer_comment_counting( true );
5106
+				$wpdb->query( 'SET autocommit = 0;' );
5107 5107
 
5108
-                //remove_all_actions('publish_post');
5109
-                //remove_all_actions('transition_post_status');
5110
-                //remove_all_actions('publish_future_post');
5108
+				//remove_all_actions('publish_post');
5109
+				//remove_all_actions('transition_post_status');
5110
+				//remove_all_actions('publish_future_post');
5111 5111
 
5112 5112
 
5113
-                if (!empty($file)) {
5114
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
5115
-                    $default_status = 'publish';
5116
-                    $current_date = date_i18n( 'Y-m-d', time() );
5113
+				if (!empty($file)) {
5114
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
5115
+					$default_status = 'publish';
5116
+					$current_date = date_i18n( 'Y-m-d', time() );
5117 5117
                     
5118
-                    $columns = isset($file[0]) ? $file[0] : NULL;
5118
+					$columns = isset($file[0]) ? $file[0] : NULL;
5119 5119
                     
5120
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5121
-                        $json['error'] = CSV_INVAILD_FILE;
5122
-                        wp_send_json( $json );
5123
-                        exit;
5124
-                    }
5120
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5121
+						$json['error'] = CSV_INVAILD_FILE;
5122
+						wp_send_json( $json );
5123
+						exit;
5124
+					}
5125 5125
 
5126
-                    $processed_actual=0;
5127
-                    for ($i = 1; $i <= $limit; $i++) {
5128
-                        $index = $processed + $i;
5129
-                        $gd_post = array();
5126
+					$processed_actual=0;
5127
+					for ($i = 1; $i <= $limit; $i++) {
5128
+						$index = $processed + $i;
5129
+						$gd_post = array();
5130 5130
                         
5131
-                        if (isset($file[$index])) {$processed_actual++;
5132
-                            $row = $file[$index];
5133
-                            $row = array_map( 'trim', $row );
5134
-                            //$row = array_map( 'utf8_encode', $row );
5135
-                            $row = array_map( 'addslashes_gpc', $row );
5131
+						if (isset($file[$index])) {$processed_actual++;
5132
+							$row = $file[$index];
5133
+							$row = array_map( 'trim', $row );
5134
+							//$row = array_map( 'utf8_encode', $row );
5135
+							$row = array_map( 'addslashes_gpc', $row );
5136 5136
                             
5137
-                            $post_id = '';
5138
-                            $post_title = '';
5139
-                            $post_author = '';
5140
-                            $post_content = '';
5141
-                            $post_category_arr = array();
5142
-                            $default_category = '';
5143
-                            $post_tags = array();
5144
-                            $post_type = '';
5145
-                            $post_status = '';
5146
-                            $geodir_video = '';
5147
-                            $post_address = '';
5148
-                            $post_city = '';
5149
-                            $post_region = '';
5150
-                            $post_country = '';
5151
-                            $post_zip = '';
5152
-                            $post_latitude = '';
5153
-                            $post_longitude = '';
5154
-                            $geodir_timing = '';
5155
-                            $geodir_contact = '';
5156
-                            $geodir_email = '';
5157
-                            $geodir_website = '';
5158
-                            $geodir_twitter = '';
5159
-                            $geodir_facebook = '';
5160
-                            $geodir_twitter = '';
5161
-                            $post_images = array();
5137
+							$post_id = '';
5138
+							$post_title = '';
5139
+							$post_author = '';
5140
+							$post_content = '';
5141
+							$post_category_arr = array();
5142
+							$default_category = '';
5143
+							$post_tags = array();
5144
+							$post_type = '';
5145
+							$post_status = '';
5146
+							$geodir_video = '';
5147
+							$post_address = '';
5148
+							$post_city = '';
5149
+							$post_region = '';
5150
+							$post_country = '';
5151
+							$post_zip = '';
5152
+							$post_latitude = '';
5153
+							$post_longitude = '';
5154
+							$geodir_timing = '';
5155
+							$geodir_contact = '';
5156
+							$geodir_email = '';
5157
+							$geodir_website = '';
5158
+							$geodir_twitter = '';
5159
+							$geodir_facebook = '';
5160
+							$geodir_twitter = '';
5161
+							$post_images = array();
5162 5162
                             
5163
-                            $expire_date = 'Never';
5163
+							$expire_date = 'Never';
5164 5164
                             
5165
-                            $language = '';
5166
-                            $original_post_id = '';
5165
+							$language = '';
5166
+							$original_post_id = '';
5167 5167
                                                         
5168
-                            $c = 0;
5169
-                            foreach ($columns as $column ) {
5170
-                                $gd_post[$column] = $row[$c];
5168
+							$c = 0;
5169
+							foreach ($columns as $column ) {
5170
+								$gd_post[$column] = $row[$c];
5171 5171
                                 
5172
-                                if ( $column == 'post_id' ) {
5173
-                                    $post_id = $row[$c];
5174
-                                } else if ( $column == 'post_title' ) {
5175
-                                    $post_title = $row[$c];
5176
-                                } else if ( $column == 'post_author' ) {
5177
-                                    $post_author = $row[$c];
5178
-                                } else if ( $column == 'post_content' ) {
5179
-                                    $post_content = $row[$c];
5180
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
5181
-                                    $post_category_arr = explode( ',', $row[$c] );
5182
-                                } else if ( $column == 'default_category' ) {
5183
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
5184
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
5185
-                                    $post_tags = explode( ',', $row[$c] );
5186
-                                } else if ( $column == 'post_type' ) {
5187
-                                    $post_type = $row[$c];
5188
-                                } else if ( $column == 'post_status' ) {
5189
-                                    $post_status = sanitize_key( $row[$c] );
5190
-                                } else if ( $column == 'is_featured' ) {
5191
-                                    $is_featured = (int)$row[$c];
5192
-                                } else if ( $column == 'geodir_video' ) {
5193
-                                    $geodir_video = $row[$c];
5194
-                                } else if ( $column == 'post_address' ) {
5195
-                                    $post_address = $row[$c];
5196
-                                } else if ( $column == 'post_city' ) {
5197
-                                    $post_city = $row[$c];
5198
-                                } else if ( $column == 'post_region' ) {
5199
-                                    $post_region = $row[$c];
5200
-                                } else if ( $column == 'post_country' ) {
5201
-                                    $post_country = $row[$c];
5202
-                                } else if ( $column == 'post_zip' ) {
5203
-                                    $post_zip = $row[$c];
5204
-                                } else if ( $column == 'post_latitude' ) {
5205
-                                    $post_latitude = $row[$c];
5206
-                                } else if ( $column == 'post_longitude' ) {
5207
-                                    $post_longitude = $row[$c];
5208
-                                } else if ( $column == 'geodir_timing' ) {
5209
-                                    $geodir_timing = $row[$c];
5210
-                                } else if ( $column == 'geodir_contact' ) {
5211
-                                    $geodir_contact = $row[$c];
5212
-                                } else if ( $column == 'geodir_email' ) {
5213
-                                    $geodir_email = $row[$c];
5214
-                                } else if ( $column == 'geodir_website' ) {
5215
-                                    $geodir_website = $row[$c];
5216
-                                } else if ( $column == 'geodir_twitter' ) {
5217
-                                    $geodir_twitter = $row[$c];
5218
-                                } else if ( $column == 'geodir_facebook' ) {
5219
-                                    $geodir_facebook = $row[$c];
5220
-                                } else if ( $column == 'geodir_twitter' ) {
5221
-                                    $geodir_twitter = $row[$c];
5222
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
5223
-                                    $post_images[] = $row[$c];
5224
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
5225
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
5226
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
5227
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
5228
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
5229
-                                }
5230
-                                // WPML
5231
-                                if ($is_wpml) {
5232
-                                    if ($column == 'language') {
5233
-                                        $language = geodir_strtolower(trim($row[$c]));
5234
-                                    } else if ($column == 'original_post_id') {
5235
-                                        $original_post_id = (int)$row[$c];
5236
-                                    }
5237
-                                }
5238
-                                // WPML
5239
-                                $c++;
5240
-                            }
5172
+								if ( $column == 'post_id' ) {
5173
+									$post_id = $row[$c];
5174
+								} else if ( $column == 'post_title' ) {
5175
+									$post_title = $row[$c];
5176
+								} else if ( $column == 'post_author' ) {
5177
+									$post_author = $row[$c];
5178
+								} else if ( $column == 'post_content' ) {
5179
+									$post_content = $row[$c];
5180
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
5181
+									$post_category_arr = explode( ',', $row[$c] );
5182
+								} else if ( $column == 'default_category' ) {
5183
+									$default_category = wp_kses_normalize_entities($row[$c]);
5184
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
5185
+									$post_tags = explode( ',', $row[$c] );
5186
+								} else if ( $column == 'post_type' ) {
5187
+									$post_type = $row[$c];
5188
+								} else if ( $column == 'post_status' ) {
5189
+									$post_status = sanitize_key( $row[$c] );
5190
+								} else if ( $column == 'is_featured' ) {
5191
+									$is_featured = (int)$row[$c];
5192
+								} else if ( $column == 'geodir_video' ) {
5193
+									$geodir_video = $row[$c];
5194
+								} else if ( $column == 'post_address' ) {
5195
+									$post_address = $row[$c];
5196
+								} else if ( $column == 'post_city' ) {
5197
+									$post_city = $row[$c];
5198
+								} else if ( $column == 'post_region' ) {
5199
+									$post_region = $row[$c];
5200
+								} else if ( $column == 'post_country' ) {
5201
+									$post_country = $row[$c];
5202
+								} else if ( $column == 'post_zip' ) {
5203
+									$post_zip = $row[$c];
5204
+								} else if ( $column == 'post_latitude' ) {
5205
+									$post_latitude = $row[$c];
5206
+								} else if ( $column == 'post_longitude' ) {
5207
+									$post_longitude = $row[$c];
5208
+								} else if ( $column == 'geodir_timing' ) {
5209
+									$geodir_timing = $row[$c];
5210
+								} else if ( $column == 'geodir_contact' ) {
5211
+									$geodir_contact = $row[$c];
5212
+								} else if ( $column == 'geodir_email' ) {
5213
+									$geodir_email = $row[$c];
5214
+								} else if ( $column == 'geodir_website' ) {
5215
+									$geodir_website = $row[$c];
5216
+								} else if ( $column == 'geodir_twitter' ) {
5217
+									$geodir_twitter = $row[$c];
5218
+								} else if ( $column == 'geodir_facebook' ) {
5219
+									$geodir_facebook = $row[$c];
5220
+								} else if ( $column == 'geodir_twitter' ) {
5221
+									$geodir_twitter = $row[$c];
5222
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
5223
+									$post_images[] = $row[$c];
5224
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
5225
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
5226
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
5227
+									$row[$c] = str_replace('/', '-', $row[$c]);
5228
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
5229
+								}
5230
+								// WPML
5231
+								if ($is_wpml) {
5232
+									if ($column == 'language') {
5233
+										$language = geodir_strtolower(trim($row[$c]));
5234
+									} else if ($column == 'original_post_id') {
5235
+										$original_post_id = (int)$row[$c];
5236
+									}
5237
+								}
5238
+								// WPML
5239
+								$c++;
5240
+							}
5241 5241
                             
5242
-                            // WPML
5243
-                            if ($is_wpml && $language != '') {
5244
-                                $sitepress->switch_lang($language, true);
5245
-                            }
5246
-                            // WPML
5242
+							// WPML
5243
+							if ($is_wpml && $language != '') {
5244
+								$sitepress->switch_lang($language, true);
5245
+							}
5246
+							// WPML
5247 5247
 
5248
-                            $gd_post['IMAGE'] = $post_images;
5248
+							$gd_post['IMAGE'] = $post_images;
5249 5249
                             
5250
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
5251
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
5250
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
5251
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
5252 5252
                                                                                                                 
5253
-                            $valid = true;
5253
+							$valid = true;
5254 5254
                             
5255
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
5256
-                                $invalid++;
5257
-                                $valid = false;
5258
-                            }
5255
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
5256
+								$invalid++;
5257
+								$valid = false;
5258
+							}
5259 5259
                             
5260
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5261
-                            if ( $location_allowed ) {
5262
-                                $location_result = geodir_get_default_location();
5263
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
5264
-                                    $invalid_addr++;
5265
-                                    $valid = false;
5266
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
5267
-                                    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 ) ) ) {
5268
-                                        $invalid_addr++;
5269
-                                        $valid = false;
5270
-                                    } else {
5271
-                                        if (!function_exists('geodir_location_plugin_activated')) {
5272
-                                            $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.
5273
-                                        }
5274
-                                    }
5275
-                                }
5276
-                            }
5260
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5261
+							if ( $location_allowed ) {
5262
+								$location_result = geodir_get_default_location();
5263
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
5264
+									$invalid_addr++;
5265
+									$valid = false;
5266
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
5267
+									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 ) ) ) {
5268
+										$invalid_addr++;
5269
+										$valid = false;
5270
+									} else {
5271
+										if (!function_exists('geodir_location_plugin_activated')) {
5272
+											$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.
5273
+										}
5274
+									}
5275
+								}
5276
+							}
5277 5277
                             
5278
-                            if ( !$valid ) {
5279
-                                continue;
5280
-                            }
5278
+							if ( !$valid ) {
5279
+								continue;
5280
+							}
5281 5281
 
5282
-                            $cat_taxonomy = $post_type . 'category';
5283
-                            $tags_taxonomy = $post_type . '_tags';
5282
+							$cat_taxonomy = $post_type . 'category';
5283
+							$tags_taxonomy = $post_type . '_tags';
5284 5284
                             
5285
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
5286
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
5287
-                            }
5285
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
5286
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
5287
+							}
5288 5288
 
5289
-                            $post_category = array();
5290
-                            $default_category_id = NULL;
5291
-                            if ( !empty( $post_category_arr ) ) {
5292
-                                foreach ( $post_category_arr as $value ) {
5293
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
5289
+							$post_category = array();
5290
+							$default_category_id = NULL;
5291
+							if ( !empty( $post_category_arr ) ) {
5292
+								foreach ( $post_category_arr as $value ) {
5293
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
5294 5294
                                     
5295
-                                    if ( $category_name != '' ) {
5296
-                                        $term_category = array();
5295
+									if ( $category_name != '' ) {
5296
+										$term_category = array();
5297 5297
                                         
5298
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
5299
-                                            $term_category = $term;
5300
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
5301
-                                            $term_category = $term;
5302
-                                        } else {
5303
-                                            $term_data = array();
5304
-                                            $term_data['name'] = $category_name;											
5305
-                                            //$term_data = array_map( 'utf8_encode', $term_data );										
5306
-                                            $term_data['taxonomy'] = $cat_taxonomy;
5298
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
5299
+											$term_category = $term;
5300
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
5301
+											$term_category = $term;
5302
+										} else {
5303
+											$term_data = array();
5304
+											$term_data['name'] = $category_name;											
5305
+											//$term_data = array_map( 'utf8_encode', $term_data );										
5306
+											$term_data['taxonomy'] = $cat_taxonomy;
5307 5307
                                             
5308
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
5309
-                                            if ( $term_id ) {
5310
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
5311
-                                            }
5312
-                                        }
5308
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
5309
+											if ( $term_id ) {
5310
+												$term_category = get_term( $term_id, $cat_taxonomy );
5311
+											}
5312
+										}
5313 5313
                                         
5314
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
5315
-                                            //$post_category[] = $term_category->slug;
5316
-                                            $post_category[] = intval($term_category->term_id);
5314
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
5315
+											//$post_category[] = $term_category->slug;
5316
+											$post_category[] = intval($term_category->term_id);
5317 5317
                                             
5318
-                                            if ($category_name == $default_category) {
5319
-                                                $default_category_id = intval($term_category->term_id);
5320
-                                            }
5321
-                                        }
5322
-                                    }
5323
-                                }
5324
-                            }
5318
+											if ($category_name == $default_category) {
5319
+												$default_category_id = intval($term_category->term_id);
5320
+											}
5321
+										}
5322
+									}
5323
+								}
5324
+							}
5325 5325
 
5326
-                            $save_post = array();
5327
-                            $save_post['post_title'] = $post_title;
5328
-                            $save_post['post_content'] = $post_content;
5329
-                            $save_post['post_type'] = $post_type;
5330
-                            $save_post['post_author'] = $post_author;
5331
-                            $save_post['post_status'] = $post_status;
5332
-                            $save_post['post_category'] = $post_category;
5333
-                            $save_post['post_tags'] = $post_tags;
5334
-
5335
-                            $saved_post_id = NULL;
5336
-                            if ( $import_choice == 'update' ) {
5337
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
5338
-                                    $save_post['ID'] = $post_id;
5326
+							$save_post = array();
5327
+							$save_post['post_title'] = $post_title;
5328
+							$save_post['post_content'] = $post_content;
5329
+							$save_post['post_type'] = $post_type;
5330
+							$save_post['post_author'] = $post_author;
5331
+							$save_post['post_status'] = $post_status;
5332
+							$save_post['post_category'] = $post_category;
5333
+							$save_post['post_tags'] = $post_tags;
5334
+
5335
+							$saved_post_id = NULL;
5336
+							if ( $import_choice == 'update' ) {
5337
+								if ( $post_id > 0 && get_post( $post_id ) ) {
5338
+									$save_post['ID'] = $post_id;
5339 5339
                                     
5340
-                                    if ( wp_update_post( $save_post ) ) {
5341
-                                        $saved_post_id = $post_id;
5342
-                                        $updated++;
5343
-                                    }
5344
-                                } else {
5345
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
5346
-                                        $created++;
5347
-                                    }
5348
-                                }
5340
+									if ( wp_update_post( $save_post ) ) {
5341
+										$saved_post_id = $post_id;
5342
+										$updated++;
5343
+									}
5344
+								} else {
5345
+									if ( $saved_post_id = wp_insert_post( $save_post ) ) {
5346
+										$created++;
5347
+									}
5348
+								}
5349 5349
                                 
5350
-                                if ( !$saved_post_id > 0 ) {
5351
-                                    $invalid++;
5352
-                                }
5353
-                            } else if ( $import_choice == 'skip' ) {
5354
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
5355
-                                    $skipped++;	
5356
-                                } else {
5357
-                                    if ( $saved_post_id = wp_insert_post( $save_post ) ) {
5358
-                                        $created++;	
5359
-                                    } else {
5360
-                                        $invalid++;
5361
-                                    }
5362
-                                }
5363
-                            } else {
5364
-                                $invalid++;
5365
-                            }
5350
+								if ( !$saved_post_id > 0 ) {
5351
+									$invalid++;
5352
+								}
5353
+							} else if ( $import_choice == 'skip' ) {
5354
+								if ( $post_id > 0 && get_post( $post_id ) ) {
5355
+									$skipped++;	
5356
+								} else {
5357
+									if ( $saved_post_id = wp_insert_post( $save_post ) ) {
5358
+										$created++;	
5359
+									} else {
5360
+										$invalid++;
5361
+									}
5362
+								}
5363
+							} else {
5364
+								$invalid++;
5365
+							}
5366 5366
 
5367
-                            if ( (int)$saved_post_id > 0 ) {
5368
-                                // WPML
5369
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
5370
-                                    $wpml_post_type = 'post_' . $post_type;
5371
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
5372
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
5367
+							if ( (int)$saved_post_id > 0 ) {
5368
+								// WPML
5369
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
5370
+									$wpml_post_type = 'post_' . $post_type;
5371
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
5372
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
5373 5373
 
5374
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
5374
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
5375 5375
                                     
5376
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
5377
-                                }
5378
-                                // WPML
5379
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
5376
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
5377
+								}
5378
+								// WPML
5379
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
5380 5380
                                 
5381
-                                $gd_post['post_id'] = $saved_post_id;
5382
-                                $gd_post['ID'] = $saved_post_id;
5383
-                                $gd_post['post_tags'] = $post_tags;
5384
-                                $gd_post['post_title'] = $post_title;
5385
-                                $gd_post['post_status'] = $post_status;
5386
-                                $gd_post['submit_time'] = time();
5387
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
5381
+								$gd_post['post_id'] = $saved_post_id;
5382
+								$gd_post['ID'] = $saved_post_id;
5383
+								$gd_post['post_tags'] = $post_tags;
5384
+								$gd_post['post_title'] = $post_title;
5385
+								$gd_post['post_status'] = $post_status;
5386
+								$gd_post['submit_time'] = time();
5387
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
5388 5388
                                                     
5389
-                                // post location
5390
-                                $post_location_id = 0;
5391
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
5392
-                                    $post_location_info = array(
5393
-                                                                'city' => $post_city,
5394
-                                                                'region' => $post_region,
5395
-                                                                'country' => $post_country,
5396
-                                                                'geo_lat' => $post_latitude,
5397
-                                                                'geo_lng' => $post_longitude
5398
-                                                            );
5399
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
5400
-                                        $post_location_id = $location_id;
5401
-                                    }
5402
-                                }
5403
-                                $gd_post['post_location_id'] = $post_location_id;
5389
+								// post location
5390
+								$post_location_id = 0;
5391
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
5392
+									$post_location_info = array(
5393
+																'city' => $post_city,
5394
+																'region' => $post_region,
5395
+																'country' => $post_country,
5396
+																'geo_lat' => $post_latitude,
5397
+																'geo_lng' => $post_longitude
5398
+															);
5399
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
5400
+										$post_location_id = $location_id;
5401
+									}
5402
+								}
5403
+								$gd_post['post_location_id'] = $post_location_id;
5404 5404
                                 
5405
-                                // post package info
5406
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
5407
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
5408
-                                    $package_id = $gd_post_info->package_id;
5409
-                                }
5405
+								// post package info
5406
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
5407
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
5408
+									$package_id = $gd_post_info->package_id;
5409
+								}
5410 5410
                                 
5411
-                                $package_info = array();
5412
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
5413
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
5411
+								$package_info = array();
5412
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
5413
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
5414 5414
                                     
5415
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
5416
-                                        $package_info = array();
5417
-                                    }
5418
-                                }
5415
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
5416
+										$package_info = array();
5417
+									}
5418
+								}
5419 5419
                                 
5420
-                                if (empty($package_info)) {
5421
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
5422
-                                }
5420
+								if (empty($package_info)) {
5421
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
5422
+								}
5423 5423
                                  
5424
-                                if (!empty($package_info))	 {
5425
-                                    $package_id = $package_info['pid'];
5424
+								if (!empty($package_info))	 {
5425
+									$package_id = $package_info['pid'];
5426 5426
                                     
5427
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
5428
-                                        $gd_post['expire_date'] = $expire_date;
5429
-                                    } else {
5430
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
5431
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
5432
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
5433
-                                        } else {
5434
-                                            $gd_post['expire_date'] = 'Never';
5435
-                                        }
5436
-                                    }
5427
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
5428
+										$gd_post['expire_date'] = $expire_date;
5429
+									} else {
5430
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
5431
+											$gd_post['alive_days'] = (int)$package_info['days'];
5432
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
5433
+										} else {
5434
+											$gd_post['expire_date'] = 'Never';
5435
+										}
5436
+									}
5437 5437
                                     
5438
-                                    $gd_post['package_id'] = $package_id;
5439
-                                }
5438
+									$gd_post['package_id'] = $package_id;
5439
+								}
5440 5440
 
5441
-                                $table = $plugin_prefix . $post_type . '_detail';
5441
+								$table = $plugin_prefix . $post_type . '_detail';
5442 5442
                                 
5443
-                                if ($post_type == 'gd_event') {
5444
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
5445
-                                }
5443
+								if ($post_type == 'gd_event') {
5444
+									$gd_post = geodir_imex_process_event_data($gd_post);
5445
+								}
5446 5446
                                 
5447
-                                if (isset($gd_post['post_id'])) {
5448
-                                    unset($gd_post['post_id']);
5449
-                                }
5447
+								if (isset($gd_post['post_id'])) {
5448
+									unset($gd_post['post_id']);
5449
+								}
5450 5450
 
5451
-                                // Export franchise fields
5452
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5453
-                                if ($is_franchise_active) {
5454
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
5455
-                                        $gd_franchise_lock = array();
5451
+								// Export franchise fields
5452
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5453
+								if ($is_franchise_active) {
5454
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
5455
+										$gd_franchise_lock = array();
5456 5456
                                         
5457
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
5458
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
5459
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
5460
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
5461
-                                        }
5457
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
5458
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
5459
+											$gd_franchise_lock = trim( $gd_franchise_lock );
5460
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
5461
+										}
5462 5462
                                         
5463
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
5464
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
5465
-                                    } else {
5466
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
5467
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
5468
-                                        }
5469
-                                    }
5470
-                                }
5463
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
5464
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
5465
+									} else {
5466
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
5467
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
5468
+										}
5469
+									}
5470
+								}
5471 5471
                                 
5472
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
5473
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
5474
-                                    if ($default_category_id) {
5475
-                                        $save_post['post_default_category'] = $default_category_id;
5476
-                                        $gd_post['default_category'] = $default_category_id;
5477
-                                    }
5478
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
5479
-                                }
5472
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
5473
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
5474
+									if ($default_category_id) {
5475
+										$save_post['post_default_category'] = $default_category_id;
5476
+										$gd_post['default_category'] = $default_category_id;
5477
+									}
5478
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
5479
+								}
5480 5480
                                 
5481
-                                // Save post info
5482
-                                geodir_save_post_info( $saved_post_id, $gd_post );
5483
-                                // post taxonomies
5484
-                                if ( !empty( $save_post['post_category'] ) ) {
5485
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
5481
+								// Save post info
5482
+								geodir_save_post_info( $saved_post_id, $gd_post );
5483
+								// post taxonomies
5484
+								if ( !empty( $save_post['post_category'] ) ) {
5485
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
5486 5486
                                     
5487
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
5488
-                                    if ($default_category_id) {
5489
-                                        $post_default_category = $default_category_id;
5490
-                                    }
5491
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
5492
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
5493
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
5487
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
5488
+									if ($default_category_id) {
5489
+										$post_default_category = $default_category_id;
5490
+									}
5491
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
5492
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
5493
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
5494 5494
                                     
5495
-                                    if ($post_category_str != '' && $post_default_category) {
5496
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
5497
-                                    }
5495
+									if ($post_category_str != '' && $post_default_category) {
5496
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
5497
+									}
5498 5498
                                     
5499
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
5499
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
5500 5500
                                     
5501
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
5502
-                                }
5501
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
5502
+								}
5503 5503
 
5504
-                                if ( !empty( $save_post['post_tags'] ) ) {
5505
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
5506
-                                }
5504
+								if ( !empty( $save_post['post_tags'] ) ) {
5505
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
5506
+								}
5507 5507
 
5508
-                                // Post images
5509
-                                if ( !empty( $post_images ) ) {
5510
-                                    $post_images = array_unique($post_images);
5508
+								// Post images
5509
+								if ( !empty( $post_images ) ) {
5510
+									$post_images = array_unique($post_images);
5511 5511
                                     
5512
-                                    $old_post_images_arr = array();
5513
-                                    $saved_post_images_arr = array();
5512
+									$old_post_images_arr = array();
5513
+									$saved_post_images_arr = array();
5514 5514
                                     
5515
-                                    $order = 1;
5515
+									$order = 1;
5516 5516
                                     
5517
-                                    $old_post_images = geodir_get_images( $saved_post_id );
5518
-                                    if (!empty($old_post_images)) {
5519
-                                        foreach( $old_post_images as $old_post_image ) {
5520
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
5521
-                                                $old_post_images_arr[] = $old_post_image->file;
5522
-                                            }
5523
-                                        }
5524
-                                    }
5517
+									$old_post_images = geodir_get_images( $saved_post_id );
5518
+									if (!empty($old_post_images)) {
5519
+										foreach( $old_post_images as $old_post_image ) {
5520
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
5521
+												$old_post_images_arr[] = $old_post_image->file;
5522
+											}
5523
+										}
5524
+									}
5525 5525
                                     
5526
-                                    foreach ( $post_images as $post_image ) {
5527
-                                        $image_name = basename( $post_image );
5528
-                                        $saved_post_images_arr[] = $image_name;
5526
+									foreach ( $post_images as $post_image ) {
5527
+										$image_name = basename( $post_image );
5528
+										$saved_post_images_arr[] = $image_name;
5529 5529
                                         
5530
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
5531
-                                            continue; // Skip if image already exists.
5532
-                                        }
5530
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
5531
+											continue; // Skip if image already exists.
5532
+										}
5533 5533
                                         
5534
-                                        $image_name_parts = explode( '.', $image_name );
5535
-                                        array_pop( $image_name_parts );
5536
-                                        $proper_image_name = implode( '.', $image_name_parts );
5534
+										$image_name_parts = explode( '.', $image_name );
5535
+										array_pop( $image_name_parts );
5536
+										$proper_image_name = implode( '.', $image_name_parts );
5537 5537
                                         
5538
-                                        $arr_file_type = wp_check_filetype( $image_name );
5538
+										$arr_file_type = wp_check_filetype( $image_name );
5539 5539
                                         
5540
-                                        if ( !empty( $arr_file_type ) ) {
5541
-                                            $uploaded_file_type = $arr_file_type['type'];
5540
+										if ( !empty( $arr_file_type ) ) {
5541
+											$uploaded_file_type = $arr_file_type['type'];
5542 5542
                                             
5543
-                                            $attachment = array();
5544
-                                            $attachment['post_id'] = $saved_post_id;
5545
-                                            $attachment['title'] = $proper_image_name;
5546
-                                            $attachment['content'] = '';
5547
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
5548
-                                            $attachment['mime_type'] = $uploaded_file_type;
5549
-                                            $attachment['menu_order'] = $order;
5550
-                                            $attachment['is_featured'] = 0;
5551
-
5552
-                                            $attachment_set = '';
5553
-                                            foreach ( $attachment as $key => $val ) {
5554
-                                                if ( $val != '' ) {
5555
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
5556
-                                                }
5557
-                                            }
5558
-                                            $attachment_set = trim( $attachment_set, ", " );
5543
+											$attachment = array();
5544
+											$attachment['post_id'] = $saved_post_id;
5545
+											$attachment['title'] = $proper_image_name;
5546
+											$attachment['content'] = '';
5547
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
5548
+											$attachment['mime_type'] = $uploaded_file_type;
5549
+											$attachment['menu_order'] = $order;
5550
+											$attachment['is_featured'] = 0;
5551
+
5552
+											$attachment_set = '';
5553
+											foreach ( $attachment as $key => $val ) {
5554
+												if ( $val != '' ) {
5555
+													$attachment_set .= $key . " = '" . $val . "', ";
5556
+												}
5557
+											}
5558
+											$attachment_set = trim( $attachment_set, ", " );
5559 5559
                                                                                         
5560
-                                            // Add new attachment
5561
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
5560
+											// Add new attachment
5561
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
5562 5562
                                                                                         
5563
-                                            $order++;
5564
-                                        }
5565
-                                    }
5563
+											$order++;
5564
+										}
5565
+									}
5566 5566
 
5567
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
5568
-                                    // Remove previous attachment
5569
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
5567
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
5568
+									// Remove previous attachment
5569
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
5570 5570
                                     
5571
-                                    if ( !empty( $saved_post_images_arr ) ) {
5572
-                                        $menu_order = 1;
5571
+									if ( !empty( $saved_post_images_arr ) ) {
5572
+										$menu_order = 1;
5573 5573
                                         
5574
-                                        foreach ( $saved_post_images_arr as $img_name ) {
5575
-                                            $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 ) ) );
5574
+										foreach ( $saved_post_images_arr as $img_name ) {
5575
+											$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 ) ) );
5576 5576
                                             
5577
-                                            if( $menu_order == 1 ) {
5578
-                                                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 ) ) ) ) {
5579
-                                                    $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
5580
-                                                }
5581
-                                            }
5582
-                                            $menu_order++;
5583
-                                        }
5584
-                                    }
5577
+											if( $menu_order == 1 ) {
5578
+												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 ) ) ) ) {
5579
+													$wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
5580
+												}
5581
+											}
5582
+											$menu_order++;
5583
+										}
5584
+									}
5585 5585
                                     
5586
-                                    if ( $order > 1 ) {
5587
-                                        $images++;
5588
-                                    }
5589
-                                }
5586
+									if ( $order > 1 ) {
5587
+										$images++;
5588
+									}
5589
+								}
5590 5590
 
5591
-                                /** This action is documented in geodirectory-functions/post-functions.php */
5592
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
5591
+								/** This action is documented in geodirectory-functions/post-functions.php */
5592
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
5593 5593
                                 
5594
-                                if (isset($is_featured)) {
5595
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
5596
-                                }
5597
-                                if (isset($gd_post['expire_date'])) {
5598
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
5599
-                                }
5600
-                            }
5594
+								if (isset($is_featured)) {
5595
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
5596
+								}
5597
+								if (isset($gd_post['expire_date'])) {
5598
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
5599
+								}
5600
+							}
5601 5601
                             
5602
-                            // WPML
5603
-                            if ($is_wpml && $language != '') {
5604
-                                $sitepress->switch_lang($active_lang, true);
5605
-                            }
5606
-                            // WPML
5607
-                        }
5608
-                    }
5609
-                }
5602
+							// WPML
5603
+							if ($is_wpml && $language != '') {
5604
+								$sitepress->switch_lang($active_lang, true);
5605
+							}
5606
+							// WPML
5607
+						}
5608
+					}
5609
+				}
5610 5610
 
5611
-                //undo some stuff to make the import quicker
5612
-                wp_defer_term_counting( false );
5613
-                wp_defer_comment_counting( false );
5614
-                $wpdb->query( 'COMMIT;' );
5615
-                $wpdb->query( 'SET autocommit = 1;' );
5616
-
5617
-                $json = array();
5618
-                $json['processed'] = $processed_actual;
5619
-                $json['created'] = $created;
5620
-                $json['updated'] = $updated;
5621
-                $json['skipped'] = $skipped;
5622
-                $json['invalid'] = $invalid;
5623
-                $json['invalid_addr'] = $invalid_addr;
5624
-                $json['images'] = $images;
5611
+				//undo some stuff to make the import quicker
5612
+				wp_defer_term_counting( false );
5613
+				wp_defer_comment_counting( false );
5614
+				$wpdb->query( 'COMMIT;' );
5615
+				$wpdb->query( 'SET autocommit = 1;' );
5616
+
5617
+				$json = array();
5618
+				$json['processed'] = $processed_actual;
5619
+				$json['created'] = $created;
5620
+				$json['updated'] = $updated;
5621
+				$json['skipped'] = $skipped;
5622
+				$json['invalid'] = $invalid;
5623
+				$json['invalid_addr'] = $invalid_addr;
5624
+				$json['images'] = $images;
5625 5625
                 
5626
-                wp_send_json( $json );
5627
-                exit;
5628
-            } else if ( $task == 'import_loc' ) {
5629
-                global $gd_post_types;
5630
-                $gd_post_types = $post_types;
5626
+				wp_send_json( $json );
5627
+				exit;
5628
+			} else if ( $task == 'import_loc' ) {
5629
+				global $gd_post_types;
5630
+				$gd_post_types = $post_types;
5631 5631
                 
5632
-                if (!empty($file)) {
5633
-                    $columns = isset($file[0]) ? $file[0] : NULL;
5632
+				if (!empty($file)) {
5633
+					$columns = isset($file[0]) ? $file[0] : NULL;
5634 5634
                     
5635
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5636
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
5637
-                        wp_send_json( $json );
5638
-                    }
5635
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5636
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
5637
+						wp_send_json( $json );
5638
+					}
5639 5639
                     
5640
-                    for ($i = 1; $i <= $limit; $i++) {
5641
-                        $index = $processed + $i;
5640
+					for ($i = 1; $i <= $limit; $i++) {
5641
+						$index = $processed + $i;
5642 5642
                         
5643
-                        if (isset($file[$index])) {
5644
-                            $row = $file[$index];
5645
-                            $row = array_map( 'trim', $row );
5646
-                            $data = array();
5643
+						if (isset($file[$index])) {
5644
+							$row = $file[$index];
5645
+							$row = array_map( 'trim', $row );
5646
+							$data = array();
5647 5647
                             
5648
-                            foreach ($columns as $c => $column ) {
5649
-                                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'))) {
5650
-                                    $data[$column] = $row[$c];
5651
-                                }
5652
-                            }
5648
+							foreach ($columns as $c => $column ) {
5649
+								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'))) {
5650
+									$data[$column] = $row[$c];
5651
+								}
5652
+							}
5653 5653
 
5654
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
5655
-                                $invalid++;
5656
-                                continue;
5657
-                            }
5654
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
5655
+								$invalid++;
5656
+								continue;
5657
+							}
5658 5658
                             
5659
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
5659
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
5660 5660
                             
5661
-                            if ( $import_choice == 'update' ) {
5662
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5663
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5664
-                                        $updated++;
5665
-                                    } else {
5666
-                                        $invalid++;
5667
-                                    }
5668
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5669
-                                    $data['location_id'] = (int)$location->location_id;
5661
+							if ( $import_choice == 'update' ) {
5662
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5663
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5664
+										$updated++;
5665
+									} else {
5666
+										$invalid++;
5667
+									}
5668
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5669
+									$data['location_id'] = (int)$location->location_id;
5670 5670
                                     
5671
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
5672
-                                        $data['location_id'] = (int)$location->location_id;
5673
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
5674
-                                        $data['location_id'] = (int)$location->location_id;
5675
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
5676
-                                        $data['location_id'] = (int)$location->location_id;
5677
-                                    }
5671
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
5672
+										$data['location_id'] = (int)$location->location_id;
5673
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
5674
+										$data['location_id'] = (int)$location->location_id;
5675
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
5676
+										$data['location_id'] = (int)$location->location_id;
5677
+									}
5678 5678
                                     
5679
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5680
-                                        $updated++;
5681
-                                    } else {
5682
-                                        $invalid++;
5683
-                                    }
5684
-                                } else {
5685
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5686
-                                        $created++;
5687
-                                    } else {
5688
-                                        $invalid++;
5689
-                                    }
5690
-                                }
5691
-                            } elseif ( $import_choice == 'skip' ) {
5692
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5693
-                                    $skipped++;
5694
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5695
-                                    $skipped++;
5696
-                                } else {
5697
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {										
5698
-                                        $created++;
5699
-                                    } else {
5700
-                                        $invalid++;
5701
-                                    }
5702
-                                }
5703
-                            } else {
5704
-                                $invalid++;
5705
-                            }
5706
-                        }
5707
-                    }
5708
-                }
5679
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5680
+										$updated++;
5681
+									} else {
5682
+										$invalid++;
5683
+									}
5684
+								} else {
5685
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5686
+										$created++;
5687
+									} else {
5688
+										$invalid++;
5689
+									}
5690
+								}
5691
+							} elseif ( $import_choice == 'skip' ) {
5692
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5693
+									$skipped++;
5694
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5695
+									$skipped++;
5696
+								} else {
5697
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {										
5698
+										$created++;
5699
+									} else {
5700
+										$invalid++;
5701
+									}
5702
+								}
5703
+							} else {
5704
+								$invalid++;
5705
+							}
5706
+						}
5707
+					}
5708
+				}
5709 5709
                 
5710
-                $json = array();
5711
-                $json['processed'] = $limit;
5712
-                $json['created'] = $created;
5713
-                $json['updated'] = $updated;
5714
-                $json['skipped'] = $skipped;
5715
-                $json['invalid'] = $invalid;
5716
-                $json['images'] = $images;
5710
+				$json = array();
5711
+				$json['processed'] = $limit;
5712
+				$json['created'] = $created;
5713
+				$json['updated'] = $updated;
5714
+				$json['skipped'] = $skipped;
5715
+				$json['invalid'] = $invalid;
5716
+				$json['images'] = $images;
5717 5717
                 
5718
-                wp_send_json( $json );
5719
-            }
5720
-        }
5721
-        break;
5722
-        case 'import_finish':{
5723
-            /**
5724
-             * Run an action when an import finishes.
5725
-             *
5726
-             * This action can be used to fire functions after an import ends.
5727
-             *
5728
-             * @since 1.5.3
5729
-             * @package GeoDirectory
5730
-             */
5731
-            do_action('geodir_import_finished');
5732
-        }
5733
-        break;
5718
+				wp_send_json( $json );
5719
+			}
5720
+		}
5721
+		break;
5722
+		case 'import_finish':{
5723
+			/**
5724
+			 * Run an action when an import finishes.
5725
+			 *
5726
+			 * This action can be used to fire functions after an import ends.
5727
+			 *
5728
+			 * @since 1.5.3
5729
+			 * @package GeoDirectory
5730
+			 */
5731
+			do_action('geodir_import_finished');
5732
+		}
5733
+		break;
5734 5734
 
5735
-    }
5736
-    echo '0';
5737
-    wp_die();
5735
+	}
5736
+	echo '0';
5737
+	wp_die();
5738 5738
 }
5739 5739
 
5740 5740
 /**
@@ -5778,12 +5778,12 @@  discard block
 block discarded – undo
5778 5778
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5779 5779
 	}
5780 5780
 	
5781
-    if( !empty( $term ) ) {
5781
+	if( !empty( $term ) ) {
5782 5782
 		$result = wp_insert_term( $term, $taxonomy, $args );
5783
-        if( !is_wp_error( $result ) ) {
5784
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5785
-        }
5786
-    }
5783
+		if( !is_wp_error( $result ) ) {
5784
+			return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5785
+		}
5786
+	}
5787 5787
 	
5788 5788
 	return false;
5789 5789
 }
@@ -5830,16 +5830,16 @@  discard block
 block discarded – undo
5830 5830
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5831 5831
 		
5832 5832
 		if( !is_wp_error( $result ) ) {
5833
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5834
-        }
5833
+			return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5834
+		}
5835 5835
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5836 5836
 		$term_data['term_id'] = $term_info['term_id'];
5837 5837
 		
5838 5838
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5839 5839
 		
5840 5840
 		if( !is_wp_error( $result ) ) {
5841
-            return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5842
-        }
5841
+			return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0;
5842
+		}
5843 5843
 	} else {
5844 5844
 		return geodir_imex_insert_term( $taxonomy, $term_data );
5845 5845
 	}
@@ -5864,7 +5864,7 @@  discard block
 block discarded – undo
5864 5864
 	 * Modify returned post counts for the current post type.
5865 5865
 	 *
5866 5866
 	 * @since 1.4.6
5867
-     * @package GeoDirectory
5867
+	 * @package GeoDirectory
5868 5868
 	 *
5869 5869
 	 * @param int $posts_count Post counts.
5870 5870
 	 * @param string $post_type Post type.
@@ -6004,7 +6004,7 @@  discard block
 block discarded – undo
6004 6004
 		$csv_rows[] = $csv_row;
6005 6005
 
6006 6006
 		$images_count = 5;
6007
-        $xx=0;
6007
+		$xx=0;
6008 6008
 		foreach ( $posts as $post ) {$xx++;
6009 6009
 			$post_id = $post['ID'];
6010 6010
 			
@@ -6244,7 +6244,7 @@  discard block
 block discarded – undo
6244 6244
 	 * Modify returned posts SQL query for the current post type.
6245 6245
 	 *
6246 6246
 	 * @since 1.4.6
6247
-     * @package GeoDirectory
6247
+	 * @package GeoDirectory
6248 6248
 	 *
6249 6249
 	 * @param int $query The SQL query.
6250 6250
 	 * @param string $post_type Post type.
@@ -6257,7 +6257,7 @@  discard block
 block discarded – undo
6257 6257
 	 * Modify returned post results for the current post type.
6258 6258
 	 *
6259 6259
 	 * @since 1.4.6
6260
-     * @package GeoDirectory
6260
+	 * @package GeoDirectory
6261 6261
 	 *
6262 6262
 	 * @param object $results An object containing all post ids.
6263 6263
 	 * @param string $post_type Post type.
@@ -6983,44 +6983,44 @@  discard block
 block discarded – undo
6983 6983
  */
6984 6984
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish')
6985 6985
 {
6986
-    global $wpdb, $current_user;
6987
-
6988
-    $option_value = get_option($option);
6989
-
6990
-    if ($option_value > 0) :
6991
-        if (get_post($option_value)) :
6992
-            // Page exists
6993
-            return;
6994
-        endif;
6995
-    endif;
6996
-
6997
-
6998
-    $page_found = $wpdb->get_var(
6999
-        $wpdb->prepare(
7000
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
7001
-            array($slug)
7002
-        )
7003
-    );
7004
-
7005
-    if ($page_found) :
7006
-        // Page exists
7007
-        if (!$option_value) update_option($option, $page_found);
7008
-        return;
7009
-    endif;
7010
-
7011
-    $page_data = array(
7012
-        'post_status' => $status,
7013
-        'post_type' => 'page',
7014
-        'post_author' => $current_user->ID,
7015
-        'post_name' => $slug,
7016
-        'post_title' => $page_title,
7017
-        'post_content' => $page_content,
7018
-        'post_parent' => $post_parent,
7019
-        'comment_status' => 'closed'
7020
-    );
7021
-    $page_id = wp_insert_post($page_data);
7022
-
7023
-    add_option($option, $page_id);
6986
+	global $wpdb, $current_user;
6987
+
6988
+	$option_value = get_option($option);
6989
+
6990
+	if ($option_value > 0) :
6991
+		if (get_post($option_value)) :
6992
+			// Page exists
6993
+			return;
6994
+		endif;
6995
+	endif;
6996
+
6997
+
6998
+	$page_found = $wpdb->get_var(
6999
+		$wpdb->prepare(
7000
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
7001
+			array($slug)
7002
+		)
7003
+	);
7004
+
7005
+	if ($page_found) :
7006
+		// Page exists
7007
+		if (!$option_value) update_option($option, $page_found);
7008
+		return;
7009
+	endif;
7010
+
7011
+	$page_data = array(
7012
+		'post_status' => $status,
7013
+		'post_type' => 'page',
7014
+		'post_author' => $current_user->ID,
7015
+		'post_name' => $slug,
7016
+		'post_title' => $page_title,
7017
+		'post_content' => $page_content,
7018
+		'post_parent' => $post_parent,
7019
+		'comment_status' => 'closed'
7020
+	);
7021
+	$page_id = wp_insert_post($page_data);
7022
+
7023
+	add_option($option, $page_id);
7024 7024
 
7025 7025
 }
7026 7026
 
@@ -7051,9 +7051,9 @@  discard block
 block discarded – undo
7051 7051
  * @package GeoDirectory
7052 7052
  */
7053 7053
 function geodir_admin_upgrade_notice() {
7054
-    $class = "error";
7055
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
7056
-    echo"<div class=\"$class\"> <p>$message</p></div>";
7054
+	$class = "error";
7055
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
7056
+	echo"<div class=\"$class\"> <p>$message</p></div>";
7057 7057
 }
7058 7058
 
7059 7059
 
@@ -7069,18 +7069,18 @@  discard block
 block discarded – undo
7069 7069
  */
7070 7070
 function geodire_admin_upgrade_notice( $plugin_data, $r )
7071 7071
 {
7072
-    // readme contents
7073
-    $args = array(
7074
-        'timeout'     => 15,
7075
-        'redirection' => 5
7076
-    );
7077
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
7078
-    $data       = wp_remote_get( $url, $args );
7072
+	// readme contents
7073
+	$args = array(
7074
+		'timeout'     => 15,
7075
+		'redirection' => 5
7076
+	);
7077
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
7078
+	$data       = wp_remote_get( $url, $args );
7079 7079
 
7080
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
7080
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
7081 7081
 
7082
-        geodir_in_plugin_update_message($data['body']);
7083
-    }
7082
+		geodir_in_plugin_update_message($data['body']);
7083
+	}
7084 7084
 }
7085 7085
 
7086 7086
 
@@ -7088,28 +7088,28 @@  discard block
 block discarded – undo
7088 7088
 * @param string $body http response body
7089 7089
 */
7090 7090
 function geodir_in_plugin_update_message($content) {
7091
-    // Output Upgrade Notice
7092
-    $matches        = null;
7093
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
7094
-    $upgrade_notice = '';
7095
-    if ( preg_match( $regexp, $content, $matches ) ) {
7096
-        if(empty($matches)){return;}
7097
-        //print_r($matches );
7098
-        $version = trim( $matches[1] );
7099
-        if($version && $version>GEODIRECTORY_VERSION){
7100
-
7101
-
7102
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
7103
-        if ( version_compare( WC_VERSION, $version, '<' ) ) {
7104
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
7105
-            foreach ( $notices as $index => $line ) {
7106
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
7107
-            }
7108
-            $upgrade_notice .= '</div> ';
7109
-        }
7110
-        }
7111
-    }
7112
-    echo $upgrade_notice;
7091
+	// Output Upgrade Notice
7092
+	$matches        = null;
7093
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
7094
+	$upgrade_notice = '';
7095
+	if ( preg_match( $regexp, $content, $matches ) ) {
7096
+		if(empty($matches)){return;}
7097
+		//print_r($matches );
7098
+		$version = trim( $matches[1] );
7099
+		if($version && $version>GEODIRECTORY_VERSION){
7100
+
7101
+
7102
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
7103
+		if ( version_compare( WC_VERSION, $version, '<' ) ) {
7104
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
7105
+			foreach ( $notices as $index => $line ) {
7106
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
7107
+			}
7108
+			$upgrade_notice .= '</div> ';
7109
+		}
7110
+		}
7111
+	}
7112
+	echo $upgrade_notice;
7113 7113
 }
7114 7114
 
7115 7115
 /**
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.
Indentation   +1305 added lines, -1305 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * GeoDirectory Admin.
4
- *
5
- * Main admin file which loads all settings panels and sets up admin menus.
6
- *
7
- * @since 1.0.0
8
- * @package GeoDirectory
9
- */
3
+	 * GeoDirectory Admin.
4
+	 *
5
+	 * Main admin file which loads all settings panels and sets up admin menus.
6
+	 *
7
+	 * @since 1.0.0
8
+	 * @package GeoDirectory
9
+	 */
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.
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.
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.
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 297
 
298
-        global $wpdb, $plugin_prefix;
298
+		global $wpdb, $plugin_prefix;
299 299
 
300
-        $old_html_variable = '';
300
+		$old_html_variable = '';
301 301
 
302
-        $data_type = trim($request_field['data_type']);
302
+		$data_type = trim($request_field['data_type']);
303 303
 
304
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
304
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
305 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
-        }
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 310
 
311
-        $cf = trim($result_str, '_');
311
+		$cf = trim($result_str, '_');
312 312
 
313 313
 
314
-        /*-------- check dublicate validation --------*/
314
+		/*-------- check dublicate validation --------*/
315 315
 
316
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
317
-        $post_type = $request_field['listing_type'];
316
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
317
+		$post_type = $request_field['listing_type'];
318 318
 
319
-        if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
320
-            $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
321
-        }
319
+		if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
320
+			$cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
321
+		}
322 322
 
323
-        $check_html_variable = $wpdb->get_var(
324
-            $wpdb->prepare(
325
-                "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
326
-                array($cf, $cehhtmlvar_name, $post_type)
327
-            )
328
-        );
323
+		$check_html_variable = $wpdb->get_var(
324
+			$wpdb->prepare(
325
+				"select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
326
+				array($cf, $cehhtmlvar_name, $post_type)
327
+			)
328
+		);
329 329
 
330 330
 
331
-        if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
331
+		if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
332 332
 
333
-            if ($cf != '') {
333
+			if ($cf != '') {
334 334
 
335
-                $post_meta_info = $wpdb->get_row(
336
-                    $wpdb->prepare(
337
-                        "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
338
-                        array($cf)
339
-                    )
340
-                );
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 341
 
342
-            }
342
+			}
343 343
 
344
-            if (!empty($post_meta_info)) {
345
-                $post_val = $post_meta_info;
346
-                $old_html_variable = $post_val->htmlvar_name;
344
+			if (!empty($post_meta_info)) {
345
+				$post_val = $post_meta_info;
346
+				$old_html_variable = $post_val->htmlvar_name;
347 347
 
348
-            }
348
+			}
349 349
 
350 350
 
351 351
 
352
-            if ($post_type == '') $post_type = 'gd_place';
352
+			if ($post_type == '') $post_type = 'gd_place';
353 353
 
354 354
 
355
-            $detail_table = $plugin_prefix . $post_type . '_detail';
355
+			$detail_table = $plugin_prefix . $post_type . '_detail';
356 356
 
357
-            $admin_title = $request_field['admin_title'];
358
-            $site_title = $request_field['site_title'];
359
-            $data_type = $request_field['data_type'];
360
-            $field_type = $request_field['field_type'];
361
-            $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'] : '';
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 379
 
380
-            if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
381
-                $htmlvar_name = 'geodir_' . $htmlvar_name;
382
-            }
380
+			if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
381
+				$htmlvar_name = 'geodir_' . $htmlvar_name;
382
+			}
383 383
 
384
-            $option_values = '';
385
-            if (isset($request_field['option_values']))
386
-                $option_values = $request_field['option_values'];
384
+			$option_values = '';
385
+			if (isset($request_field['option_values']))
386
+				$option_values = $request_field['option_values'];
387 387
 
388
-            $cat_sort = '';
389
-            if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort']))
390
-                $cat_sort = implode(",", $request_field['cat_sort']);
388
+			$cat_sort = '';
389
+			if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort']))
390
+				$cat_sort = implode(",", $request_field['cat_sort']);
391 391
 
392
-            $cat_filter = '';
393
-            if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter']))
394
-                $cat_filter = implode(",", $request_field['cat_filter']);
392
+			$cat_filter = '';
393
+			if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter']))
394
+				$cat_filter = implode(",", $request_field['cat_filter']);
395 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();
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();
400 400
 
401
-                $package_info = geodir_post_package_info($package_info, '', $post_type);
402
-                $price_pkg = $package_info->pid;
403
-            }
401
+				$package_info = geodir_post_package_info($package_info, '', $post_type);
402
+				$price_pkg = $package_info->pid;
403
+			}
404 404
 
405 405
 
406
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
407
-                $extra_fields = $request_field['extra'];
406
+			if (isset($request_field['extra']) && !empty($request_field['extra']))
407
+				$extra_fields = $request_field['extra'];
408 408
 
409
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
410
-                $is_default = $request_field['is_default'];
411
-            else
412
-                $is_default = '0';
409
+			if (isset($request_field['is_default']) && $request_field['is_default'] != '')
410
+				$is_default = $request_field['is_default'];
411
+			else
412
+				$is_default = '0';
413 413
 
414
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
415
-                $is_admin = $request_field['is_admin'];
416
-            else
417
-                $is_admin = '0';
414
+			if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
415
+				$is_admin = $request_field['is_admin'];
416
+			else
417
+				$is_admin = '0';
418 418
 
419 419
 
420
-            if ($is_active == '') $is_active = 1;
421
-            if ($is_required == '') $is_required = 0;
420
+			if ($is_active == '') $is_active = 1;
421
+			if ($is_required == '') $is_required = 0;
422 422
 
423 423
 
424
-            if ($sort_order == '') {
424
+			if ($sort_order == '') {
425 425
 
426
-                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
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;
429
-            }
428
+				$sort_order = (int)$last_order + 1;
429
+			}
430 430
 
431
-            $default_value_add = '';
431
+			$default_value_add = '';
432 432
 
433
-            if (!empty($post_meta_info)) {
434
-                switch ($field_type):
433
+			if (!empty($post_meta_info)) {
434
+				switch ($field_type):
435 435
 
436
-                    case 'address':
436
+					case 'address':
437 437
 
438
-                        if ($htmlvar_name != '') {
439
-                            $prefix = $htmlvar_name . '_';
440
-                        }
441
-                        $old_prefix = $old_html_variable . '_';
438
+						if ($htmlvar_name != '') {
439
+							$prefix = $htmlvar_name . '_';
440
+						}
441
+						$old_prefix = $old_html_variable . '_';
442 442
 
443 443
 
444
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
444
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
445 445
 
446
-                        if ($default_value != '') {
447
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
448
-                        }
446
+						if ($default_value != '') {
447
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
448
+						}
449 449
 
450
-                        $wpdb->query($meta_field_add);
450
+						$wpdb->query($meta_field_add);
451 451
 
452
-                        if ($extra_fields != '') {
452
+						if ($extra_fields != '') {
453 453
 
454
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
454
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
455 455
 
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";
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 459
 
460
-                                    if ($default_value != '') {
461
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
462
-                                    }
460
+									if ($default_value != '') {
461
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
462
+									}
463 463
 
464
-                                    $wpdb->query($meta_field_add);
465
-                                } else {
464
+									$wpdb->query($meta_field_add);
465
+								} else {
466 466
 
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);
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);
472 472
 
473
-                                }
473
+								}
474 474
 
475 475
 
476
-                            }
476
+							}
477 477
 
478 478
 
479
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
479
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
480 480
 
481
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
481
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
482 482
 
483
-                                if ($is_column) {
484
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
483
+								if ($is_column) {
484
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
485 485
 
486
-                                    if ($default_value != '') {
487
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
488
-                                    }
486
+									if ($default_value != '') {
487
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
488
+									}
489 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
-                                    }
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
+									}
496 496
 
497
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
498
-                                }
497
+									geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
498
+								}
499 499
 
500
-                            }
501
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
500
+							}
501
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
502 502
 
503
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
503
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
504 504
 
505
-                                if ($is_column) {
505
+								if ($is_column) {
506 506
 
507
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
507
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
508 508
 
509
-                                    if ($default_value != '') {
510
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
511
-                                    }
509
+									if ($default_value != '') {
510
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
511
+									}
512 512
 
513
-                                    $wpdb->query($meta_field_add);
514
-                                } else {
513
+									$wpdb->query($meta_field_add);
514
+								} else {
515 515
 
516
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
517
-                                    if ($default_value != '') {
518
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
519
-                                    }
516
+									$meta_field_add = "VARCHAR( 50 ) NULL";
517
+									if ($default_value != '') {
518
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
519
+									}
520 520
 
521
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
521
+									geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
522 522
 
523
-                                }
523
+								}
524 524
 
525
-                            }
526
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
525
+							}
526
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
527 527
 
528
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
528
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
529 529
 
530
-                                if ($is_column) {
530
+								if ($is_column) {
531 531
 
532
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
532
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
533 533
 
534
-                                    if ($default_value != '') {
535
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
536
-                                    }
534
+									if ($default_value != '') {
535
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
536
+									}
537 537
 
538
-                                    $wpdb->query($meta_field_add);
539
-                                } else {
538
+									$wpdb->query($meta_field_add);
539
+								} else {
540 540
 
541
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
542
-                                    if ($default_value != '') {
543
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
544
-                                    }
541
+									$meta_field_add = "VARCHAR( 50 ) NULL";
542
+									if ($default_value != '') {
543
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
544
+									}
545 545
 
546
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
546
+									geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
547 547
 
548
-                                }
548
+								}
549 549
 
550
-                            }
551
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
550
+							}
551
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
552 552
 
553
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
554
-                                if ($is_column) {
553
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
554
+								if ($is_column) {
555 555
 
556
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
556
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
557 557
 
558
-                                    if ($default_value != '') {
559
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
560
-                                    }
558
+									if ($default_value != '') {
559
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
560
+									}
561 561
 
562
-                                    $wpdb->query($meta_field_add);
563
-                                } else {
562
+									$wpdb->query($meta_field_add);
563
+								} else {
564 564
 
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
-                                    }
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
+									}
570 570
 
571
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
571
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
572 572
 
573
-                                }
573
+								}
574 574
 
575 575
 
576
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
576
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
577 577
 
578
-                                if ($is_column) {
579
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
578
+								if ($is_column) {
579
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
580 580
 
581
-                                    if ($default_value != '') {
582
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
583
-                                    }
581
+									if ($default_value != '') {
582
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
583
+									}
584 584
 
585
-                                    $wpdb->query($meta_field_add);
586
-                                } else {
585
+									$wpdb->query($meta_field_add);
586
+								} else {
587 587
 
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
-                                    }
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
+									}
593 593
 
594
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
595
-                                }
594
+									geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
595
+								}
596 596
 
597
-                            }
598
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
597
+							}
598
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
599 599
 
600
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
600
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
601 601
 
602
-                                if ($is_column) {
603
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
602
+								if ($is_column) {
603
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
604 604
 
605
-                                    if ($default_value != '') {
606
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
607
-                                    }
605
+									if ($default_value != '') {
606
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
607
+									}
608 608
 
609
-                                    $wpdb->query($meta_field_add);
610
-                                } else {
609
+									$wpdb->query($meta_field_add);
610
+								} else {
611 611
 
612
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
612
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
613 613
 
614
-                                    $meta_field_add = "VARCHAR( 15 ) NULL";
615
-                                    if ($default_value != '') {
616
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
617
-                                    }
614
+									$meta_field_add = "VARCHAR( 15 ) NULL";
615
+									if ($default_value != '') {
616
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
617
+									}
618 618
 
619
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
620
-                                }
619
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
620
+								}
621 621
 
622 622
 
623
-                            }
624
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
623
+							}
624
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
625 625
 
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";
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";
629 629
 
630
-                                    if ($default_value != '') {
631
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
632
-                                    }
630
+									if ($default_value != '') {
631
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
632
+									}
633 633
 
634
-                                    $wpdb->query($meta_field_add);
634
+									$wpdb->query($meta_field_add);
635 635
 
636
-                                } else {
636
+								} else {
637 637
 
638
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
638
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
639 639
 
640
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
641
-                                    if ($default_value != '') {
642
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
643
-                                    }
640
+									$meta_field_add = "VARCHAR( 3 ) NULL";
641
+									if ($default_value != '') {
642
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
643
+									}
644 644
 
645
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
646
-                                }
645
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
646
+								}
647 647
 
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'");
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'");
652 652
 
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'";
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'";
656 656
 
657
-                                    $wpdb->query($meta_field_add);
658
-                                } else {
659
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
657
+									$wpdb->query($meta_field_add);
658
+								} else {
659
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
660 660
 
661
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
662
-                                    $meta_field_add .= " DEFAULT '1'";
661
+									$meta_field_add = "VARCHAR( 3 ) NULL";
662
+									$meta_field_add .= " DEFAULT '1'";
663 663
 
664
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
665
-                                }
664
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
665
+								}
666 666
 
667
-                            }
668
-                        }// end extra
667
+							}
668
+						}// end extra
669 669
 
670
-                        break;
670
+						break;
671 671
 
672
-                    case 'checkbox':
673
-                    case 'multiselect':
674
-                    case 'select':
675
-                    case 'taxonomy':
672
+					case 'checkbox':
673
+					case 'multiselect':
674
+					case 'select':
675
+					case 'taxonomy':
676 676
 
677
-                    $op_size = '500';
677
+					$op_size = '500';
678 678
 
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
-                    }
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
+					}
694 694
 
695
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
695
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
696 696
 
697
-                        if ($default_value != '') {
698
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
699
-                        }
697
+						if ($default_value != '') {
698
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
699
+						}
700 700
 
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
-                    }
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
+					}
705 705
 
706
-                        if (isset($request_field['cat_display_type']))
707
-                            $extra_fields = $request_field['cat_display_type'];
706
+						if (isset($request_field['cat_display_type']))
707
+							$extra_fields = $request_field['cat_display_type'];
708 708
 
709
-                        if (isset($request_field['multi_display_type']))
710
-                            $extra_fields = $request_field['multi_display_type'];
709
+						if (isset($request_field['multi_display_type']))
710
+							$extra_fields = $request_field['multi_display_type'];
711 711
 
712 712
 
713
-                        break;
713
+						break;
714 714
 
715
-                    case 'textarea':
716
-                    case 'html':
715
+					case 'textarea':
716
+					case 'html':
717
+
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'];
717 724
 
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'];
725
+						break;
724 726
 
725
-                        break;
727
+					case 'fieldset':
728
+						// Nothig happend for fieldset
729
+						break;
730
+
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
+				}
726 760
 
727
-                    case 'fieldset':
728
-                        // Nothig happend for fieldset
729
-                        break;
761
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
730 762
 
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 
763
+				$wpdb->query(
764
+
765
+					$wpdb->prepare(
766
+
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
+
852
+
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
+								}
854 861
 
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);
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 = '';
2860 2839
 							}
2861 2840
 
2862
-                            $html .= '</span></div>';
2841
+							$geodir_odd_even = '';
2842
+							if ($fields_location == 'detail') {
2863 2843
 
2844
+								$geodir_odd_even = 'geodir_more_info_odd';
2845
+								if ($i % 2 == 0)
2846
+									$geodir_odd_even = 'geodir_more_info_even';
2864 2847
 
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
-                            }
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>';
2860
+							}
2872 2861
 
2873
-                            /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
2862
+							$html .= '</span></div>';
2874 2863
 
2875
-                        } else {
2876 2864
 
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
-                                }
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
+
2875
+						} else {
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
+								}
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.
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.
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   +1349 added lines, -1349 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
-    exit;
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
+	exit;
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
-    exit;
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
+	exit;
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>
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 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>
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.
Spacing   +11 added lines, -11 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
     }
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
662 662
                             $is_geodir_location_found = true;
663 663
                     }
664
-                }  else if ($geodir_show_location_url == 'region_city') {
664
+                } else if ($geodir_show_location_url == 'region_city') {
665 665
                     if (count($geodir_terms) >= 2) {
666 666
                         $gd_region = urldecode($geodir_terms[0]);
667 667
                         $gd_city = urldecode($geodir_terms[1]);
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   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Geodirectory custom post types/taxonomies related functions.
4
- *
5
- * @since 1.0.0
6
- * @package GeoDirectory
7
- */
3
+	 * Geodirectory custom post types/taxonomies related functions.
4
+	 *
5
+	 * @since 1.0.0
6
+	 * @package GeoDirectory
7
+	 */
8 8
 
9 9
 /**
10 10
  * Register the texonomies.
@@ -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,115 +437,115 @@  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);
528
+		$geodir_post_type = '';
529
+		$geodir_term = '';
530
+		$geodir_set_location_session = true;
531
+		$geodir_taxonomis = geodir_get_taxonomies('', true);
532 532
 		
533
-	    foreach ($geodir_taxonomis as $taxonomy) {
534
-            if (array_key_exists($taxonomy, $wp->query_vars)) {
535
-                $is_geodir_taxonomy = true;
536
-                $geodir_taxonomy = $taxonomy;
537
-                $geodir_post_type = str_replace('category', '', $taxonomy);
538
-                $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
539
-                $geodir_term = $wp->query_vars[$geodir_taxonomy];
540
-                break;
541
-            }
542
-        }
543
-        // now get an array of all terms seperated by '/'
544
-        $geodir_terms = explode('/', $geodir_term);
545
-        $geodir_last_term = end($geodir_terms);
546
-
547
-        if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
548
-            $wp->query_vars['post_type'] = $geodir_post_type;
533
+		foreach ($geodir_taxonomis as $taxonomy) {
534
+			if (array_key_exists($taxonomy, $wp->query_vars)) {
535
+				$is_geodir_taxonomy = true;
536
+				$geodir_taxonomy = $taxonomy;
537
+				$geodir_post_type = str_replace('category', '', $taxonomy);
538
+				$geodir_post_type = str_replace('_tags', '', $geodir_post_type);
539
+				$geodir_term = $wp->query_vars[$geodir_taxonomy];
540
+				break;
541
+			}
542
+		}
543
+		// now get an array of all terms seperated by '/'
544
+		$geodir_terms = explode('/', $geodir_term);
545
+		$geodir_last_term = end($geodir_terms);
546
+
547
+		if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
548
+			$wp->query_vars['post_type'] = $geodir_post_type;
549 549
 
550 550
 			// now check if last term is a post of geodirectory post types
551 551
 			$geodir_post = get_posts(array(
@@ -594,196 +594,196 @@  discard block
 block discarded – undo
594 594
 				//return ;
595 595
 			}
596 596
 
597
-            $geodir_location_terms = '';
598
-            // if last term is not a post then check if last term is a term of the specific texonomy or not
599
-            if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
600
-                $is_geodir_taxonomy_term = true;
597
+			$geodir_location_terms = '';
598
+			// if last term is not a post then check if last term is a term of the specific texonomy or not
599
+			if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
600
+				$is_geodir_taxonomy_term = true;
601 601
 
602
-                $geodir_set_location_session = false;
603
-            }
602
+				$geodir_set_location_session = false;
603
+			}
604 604
 
605 605
 
606
-            // now check if there is location parts in the url or not
607
-            if (get_option('geodir_add_location_url')) {				
606
+			// now check if there is location parts in the url or not
607
+			if (get_option('geodir_add_location_url')) {				
608 608
 				$default_location = geodir_get_default_location();
609 609
                 
610 610
 				if ($geodir_show_location_url == 'all') {
611
-                    if (count($geodir_terms) >= 3) {
612
-                        $gd_country = urldecode($geodir_terms[0]);
613
-                        $gd_region = urldecode($geodir_terms[1]);
614
-                        $gd_city = urldecode($geodir_terms[2]);
615
-                    } else if (count($geodir_terms) >= 2) {
616
-                        $gd_country = urldecode($geodir_terms[0]);
617
-                        $gd_region = urldecode($geodir_terms[1]);
618
-                    } else if (count($geodir_terms) >= 1) {
619
-                        $gd_country = urldecode($geodir_terms[0]);
620
-                    }
621
-
622
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
623
-                        geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
624
-                        geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
625
-                    )
626
-                        $is_geodir_location_found = true;
627
-
628
-                    // if location has not been found for country , region and city then search for country and region only
629
-
630
-                    if (!$is_geodir_location_found) {
631
-                        $gd_city = '';
632
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
633
-                            geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
634
-                        )
635
-                            $is_geodir_location_found = true;
636
-
637
-                    }
638
-
639
-                    // if location has not been found for country , region  then search for country only
640
-                    if (!$is_geodir_location_found) {
641
-                        $gd_city = '';
642
-                        $gd_region = '';
643
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
644
-                            $is_geodir_location_found = true;
645
-                    }
646
-                } else if ($geodir_show_location_url == 'country_city') {
647
-                    if (count($geodir_terms) >= 2) {
648
-                        $gd_country = urldecode($geodir_terms[0]);
649
-                        $gd_city = urldecode($geodir_terms[1]);
650
-                    } else if (count($geodir_terms) >= 1) {
651
-                        $gd_country = urldecode($geodir_terms[0]);
652
-                    }
653
-
654
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
655
-                        $is_geodir_location_found = true;
656
-
657
-                    // if location has not been found for country and city  then search for country only
658
-                    if (!$is_geodir_location_found) {
659
-                        $gd_city = '';
611
+					if (count($geodir_terms) >= 3) {
612
+						$gd_country = urldecode($geodir_terms[0]);
613
+						$gd_region = urldecode($geodir_terms[1]);
614
+						$gd_city = urldecode($geodir_terms[2]);
615
+					} else if (count($geodir_terms) >= 2) {
616
+						$gd_country = urldecode($geodir_terms[0]);
617
+						$gd_region = urldecode($geodir_terms[1]);
618
+					} else if (count($geodir_terms) >= 1) {
619
+						$gd_country = urldecode($geodir_terms[0]);
620
+					}
621
+
622
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
623
+						geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
624
+						geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
625
+					)
626
+						$is_geodir_location_found = true;
627
+
628
+					// if location has not been found for country , region and city then search for country and region only
629
+
630
+					if (!$is_geodir_location_found) {
631
+						$gd_city = '';
632
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
633
+							geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
634
+						)
635
+							$is_geodir_location_found = true;
636
+
637
+					}
638
+
639
+					// if location has not been found for country , region  then search for country only
640
+					if (!$is_geodir_location_found) {
641
+						$gd_city = '';
642
+						$gd_region = '';
643
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
644
+							$is_geodir_location_found = true;
645
+					}
646
+				} else if ($geodir_show_location_url == 'country_city') {
647
+					if (count($geodir_terms) >= 2) {
648
+						$gd_country = urldecode($geodir_terms[0]);
649
+						$gd_city = urldecode($geodir_terms[1]);
650
+					} else if (count($geodir_terms) >= 1) {
651
+						$gd_country = urldecode($geodir_terms[0]);
652
+					}
653
+
654
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
655
+						$is_geodir_location_found = true;
656
+
657
+					// if location has not been found for country and city  then search for country only
658
+					if (!$is_geodir_location_found) {
659
+						$gd_city = '';
660 660
                         
661 661
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
662
-                            $is_geodir_location_found = true;
663
-                    }
664
-                }  else if ($geodir_show_location_url == 'region_city') {
665
-                    if (count($geodir_terms) >= 2) {
666
-                        $gd_region = urldecode($geodir_terms[0]);
667
-                        $gd_city = urldecode($geodir_terms[1]);
668
-                    } else if (count($geodir_terms) >= 1) {
669
-                        $gd_region = urldecode($geodir_terms[0]);
670
-                    }
671
-
672
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
673
-                        $is_geodir_location_found = true;
674
-
675
-                    // if location has not been found for region and city  then search for region only
676
-                    if (!$is_geodir_location_found) {
677
-                        $gd_city = '';
662
+							$is_geodir_location_found = true;
663
+					}
664
+				}  else if ($geodir_show_location_url == 'region_city') {
665
+					if (count($geodir_terms) >= 2) {
666
+						$gd_region = urldecode($geodir_terms[0]);
667
+						$gd_city = urldecode($geodir_terms[1]);
668
+					} else if (count($geodir_terms) >= 1) {
669
+						$gd_region = urldecode($geodir_terms[0]);
670
+					}
671
+
672
+					if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
673
+						$is_geodir_location_found = true;
674
+
675
+					// if location has not been found for region and city  then search for region only
676
+					if (!$is_geodir_location_found) {
677
+						$gd_city = '';
678 678
                         
679 679
 						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
680
-                            $is_geodir_location_found = true;
681
-                    }
682
-                } else {
683
-                    $gd_city = $geodir_terms[0];
684
-
685
-                    if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
686
-                        $is_geodir_location_found = true;
687
-                        $gd_region = $default_location->region_slug;
688
-                        $gd_country = $default_location->country_slug;
689
-                    }
690
-                }
691
-                // if locaton still not found then clear location related session variables
692
-                if ($is_geodir_location_found && $geodir_set_location_session) {
693
-                    $gd_session->set('gd_multi_location', 1);
694
-                    $gd_session->set('gd_country', $gd_country);
695
-                    $gd_session->set('gd_region', $gd_region);
696
-                    $gd_session->set('gd_city', $gd_city);
697
-                }
698
-
699
-                if ($geodir_show_location_url == 'all') {
680
+							$is_geodir_location_found = true;
681
+					}
682
+				} else {
683
+					$gd_city = $geodir_terms[0];
684
+
685
+					if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
686
+						$is_geodir_location_found = true;
687
+						$gd_region = $default_location->region_slug;
688
+						$gd_country = $default_location->country_slug;
689
+					}
690
+				}
691
+				// if locaton still not found then clear location related session variables
692
+				if ($is_geodir_location_found && $geodir_set_location_session) {
693
+					$gd_session->set('gd_multi_location', 1);
694
+					$gd_session->set('gd_country', $gd_country);
695
+					$gd_session->set('gd_region', $gd_region);
696
+					$gd_session->set('gd_city', $gd_city);
697
+				}
698
+
699
+				if ($geodir_show_location_url == 'all') {
700 700
 				} else if ($geodir_show_location_url == 'country_city') {
701 701
 					$gd_region = '';
702 702
 				} else if ($geodir_show_location_url == 'region_city') {
703 703
 					$gd_country = '';
704 704
 				} else {
705 705
 					$gd_country = '';
706
-                    $gd_region = '';
706
+					$gd_region = '';
707
+				}
708
+
709
+				if ($is_geodir_location_found) {
710
+					$wp->query_vars['gd_country'] = $gd_country;
711
+					$wp->query_vars['gd_region'] = $gd_region;
712
+					$wp->query_vars['gd_city'] = $gd_city;
713
+				} else {
714
+					$gd_country = '';
715
+					$gd_region = '';
716
+					$gd_city = '';
707 717
 				}
718
+			}
719
+
720
+			$wp->query_vars[$geodir_taxonomy] = $geodir_term;
721
+			// eliminate location related terms from taxonomy term
722
+			if ($gd_country != '')
723
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
724
+
725
+			if ($gd_region != '')
726
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
+
728
+			if ($gd_city != '')
729
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
+
731
+
732
+			$wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
733
+			$wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
708 734
 
709
-                if ($is_geodir_location_found) {
710
-                    $wp->query_vars['gd_country'] = $gd_country;
711
-                    $wp->query_vars['gd_region'] = $gd_region;
712
-                    $wp->query_vars['gd_city'] = $gd_city;
713
-                } else {
714
-                    $gd_country = '';
715
-                    $gd_region = '';
716
-                    $gd_city = '';
717
-                }
718
-            }
719
-
720
-            $wp->query_vars[$geodir_taxonomy] = $geodir_term;
721
-            // eliminate location related terms from taxonomy term
722
-            if ($gd_country != '')
723
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
724
-
725
-            if ($gd_region != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
-
728
-            if ($gd_city != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
-
731
-
732
-            $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
733
-            $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
734
-
735
-            $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
736
-
737
-            if ($wp->query_vars[$geodir_taxonomy] == '') {
738
-                unset($wp->query_vars[$geodir_taxonomy]);
739
-            } else {
740
-                if (!$is_geodir_taxonomy_term) {
741
-                    foreach ($wp->query_vars as $key => $vars) {
742
-                        unset($wp->query_vars[$key]);
743
-                    }
744
-                    $wp->query_vars['error'] = '404';
745
-                }
746
-            }
747
-        }
748
-    }
735
+			$wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
736
+
737
+			if ($wp->query_vars[$geodir_taxonomy] == '') {
738
+				unset($wp->query_vars[$geodir_taxonomy]);
739
+			} else {
740
+				if (!$is_geodir_taxonomy_term) {
741
+					foreach ($wp->query_vars as $key => $vars) {
742
+						unset($wp->query_vars[$key]);
743
+					}
744
+					$wp->query_vars['error'] = '404';
745
+				}
746
+			}
747
+		}
748
+	}
749 749
 	
750 750
 	// Unset location session if gd page and location not set.
751 751
 	if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
752 752
 		$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
753 753
 	}
754 754
 
755
-    if ($gd_session->get('gd_multi_location') == 1) {
756
-        $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
757
-        $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
758
-        $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
759
-    }
755
+	if ($gd_session->get('gd_multi_location') == 1) {
756
+		$wp->query_vars['gd_country'] = $gd_session->get('gd_country');
757
+		$wp->query_vars['gd_region'] = $gd_session->get('gd_region');
758
+		$wp->query_vars['gd_city'] = $gd_session->get('gd_city');
759
+	}
760 760
 
761
-    // now check if there is location parts in the url or not
762
-    if (get_option('geodir_add_location_url')) {        
761
+	// now check if there is location parts in the url or not
762
+	if (get_option('geodir_add_location_url')) {        
763 763
 		if ($geodir_show_location_url == 'all') {
764 764
 		} else if ($geodir_show_location_url == 'country_city') {
765 765
 			 if (isset($wp->query_vars['gd_region']))
766
-                $wp->query_vars['gd_region'] = '';
766
+				$wp->query_vars['gd_region'] = '';
767 767
 		} else if ($geodir_show_location_url == 'region_city') {
768 768
 			if (isset($wp->query_vars['gd_country']))
769
-                $wp->query_vars['gd_country'] = '';
769
+				$wp->query_vars['gd_country'] = '';
770 770
 		} else {
771 771
 			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
772
+				$wp->query_vars['gd_country'] = '';
773 773
 
774
-            if (isset($wp->query_vars['gd_region']))
775
-                $wp->query_vars['gd_region'] = '';
774
+			if (isset($wp->query_vars['gd_region']))
775
+				$wp->query_vars['gd_region'] = '';
776 776
 		}
777
-    } else {
778
-        if (isset($wp->query_vars['gd_country']))
779
-            $wp->query_vars['gd_country'] = '';
777
+	} else {
778
+		if (isset($wp->query_vars['gd_country']))
779
+			$wp->query_vars['gd_country'] = '';
780 780
 
781
-        if (isset($wp->query_vars['gd_region']))
782
-            $wp->query_vars['gd_region'] = '';
781
+		if (isset($wp->query_vars['gd_region']))
782
+			$wp->query_vars['gd_region'] = '';
783 783
 
784
-        if (isset($wp->query_vars['gd_city']))
785
-            $wp->query_vars['gd_city'] = '';
786
-    }
784
+		if (isset($wp->query_vars['gd_city']))
785
+			$wp->query_vars['gd_city'] = '';
786
+	}
787 787
 }
788 788
 
789 789
 /**
@@ -797,24 +797,24 @@  discard block
 block discarded – undo
797 797
  */
798 798
 function geodir_custom_post_status()
799 799
 {
800
-    // Vertual Page Status
801
-    register_post_status('virtual', array(
802
-        'label' => _x('Virtual', 'page', 'geodirectory'),
803
-        'public' => true,
804
-        'exclude_from_search' => true,
805
-        'show_in_admin_all_list' => true,
806
-        'show_in_admin_status_list' => true,
807
-        'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
808
-    ));
809
-
810
-    /**
811
-     * Called after we register the custom post status 'Virtual'.
812
-     *
813
-     * Can be use to add more post statuses.
814
-     *
815
-     * @since 1.0.0
816
-     */
817
-    do_action('geodir_custom_post_status');
800
+	// Vertual Page Status
801
+	register_post_status('virtual', array(
802
+		'label' => _x('Virtual', 'page', 'geodirectory'),
803
+		'public' => true,
804
+		'exclude_from_search' => true,
805
+		'show_in_admin_all_list' => true,
806
+		'show_in_admin_status_list' => true,
807
+		'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
808
+	));
809
+
810
+	/**
811
+	 * Called after we register the custom post status 'Virtual'.
812
+	 *
813
+	 * Can be use to add more post statuses.
814
+	 *
815
+	 * @since 1.0.0
816
+	 */
817
+	do_action('geodir_custom_post_status');
818 818
 }
819 819
 
820 820
 /**
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
  */
830 830
 function geodir_get_term_link($termlink, $term, $taxonomy)
831 831
 {
832
-    return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
832
+	return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
833 833
 }
834 834
 
835 835
 /**
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
  */
844 844
 function geodir_get_posttype_link($link, $post_type)
845 845
 {
846
-    return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
846
+	return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
847 847
 }
848 848
 
849 849
 /**
@@ -858,13 +858,13 @@  discard block
 block discarded – undo
858 858
  */
859 859
 function exclude_from_wp_list_pages($exclude_array)
860 860
 {
861
-    $pages_ids = array();
862
-    $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
863
-    foreach ($pages_array as $page) {
864
-        $pages_ids[] = $page->ID;
865
-    }
866
-    $exclude_array = $exclude_array + $pages_ids;
867
-    return $exclude_array;
861
+	$pages_ids = array();
862
+	$pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
863
+	foreach ($pages_array as $page) {
864
+		$pages_ids[] = $page->ID;
865
+	}
866
+	$exclude_array = $exclude_array + $pages_ids;
867
+	return $exclude_array;
868 868
 }
869 869
 
870 870
 /**
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
  */
878 878
 function geodir_exclude_page($query)
879 879
 {
880
-    add_filter('posts_where', 'geodir_exclude_page_where', 100);
881
-    return $query;
880
+	add_filter('posts_where', 'geodir_exclude_page_where', 100);
881
+	return $query;
882 882
 }
883 883
 
884 884
 /**
@@ -893,9 +893,9 @@  discard block
 block discarded – undo
893 893
  */
894 894
 function geodir_exclude_page_where($where)
895 895
 {
896
-    global $wpdb;
897
-    if (is_admin())
898
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
896
+	global $wpdb;
897
+	if (is_admin())
898
+		$where .= " AND $wpdb->posts.post_status != 'virtual'";
899 899
 
900
-    return $where;
900
+	return $where;
901 901
 }
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.
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         $add_listing_link = get_page_link(geodir_add_listing_page_id());
158 158
 
159
-        return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
159
+        return esc_url(add_query_arg(array('listing_type' => $post_type), $add_listing_link));
160 160
     } else
161 161
         return get_bloginfo('url');
162 162
 }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 function geodir_is_page($gdpage = '')
249 249
 {
250 250
 
251
-    global $wp_query, $post,$wp;
251
+    global $wp_query, $post, $wp;
252 252
     //if(!is_admin()):
253 253
 
254 254
     switch ($gdpage):
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
             if (is_author() && isset($_REQUEST['geodir_dashbord']))
305 305
                 return true;
306 306
 			
307
-			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
308
-				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
307
+			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
308
+				if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
309 309
 					return true;
310 310
 				}
311 311
 			}
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
359 359
             if (get_option('geodir_set_as_home'))
360 360
                 $wp->query_vars['gd_is_geodir_page'] = true;
361
-            if(geodir_is_page('home')){
361
+            if (geodir_is_page('home')) {
362 362
                 $wp->query_vars['gd_is_geodir_page'] = true;
363 363
             }
364 364
 
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 
428 428
 
429 429
 //check if homepage
430
-        if(!isset($wp->query_vars['gd_is_geodir_page'])
430
+        if (!isset($wp->query_vars['gd_is_geodir_page'])
431 431
             && !isset($wp->query_vars['page_id'])
432 432
             && !isset($wp->query_vars['pagename'])
433
-            && is_page_geodir_home()){
433
+            && is_page_geodir_home()) {
434 434
             $wp->query_vars['gd_is_geodir_page'] = true;
435 435
         }
436 436
         //echo $wp->query_vars['gd_is_geodir_page'] ;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     function createRandomString()
532 532
     {
533 533
         $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
534
-        srand((double)microtime() * 1000000);
534
+        srand((double) microtime() * 1000000);
535 535
         $i = 0;
536 536
         $rstring = '';
537 537
         while ($i <= 25) {
@@ -665,11 +665,11 @@  discard block
 block discarded – undo
665 665
         }
666 666
 		
667 667
 		if (!empty($subject)) {
668
-			$subject = __(stripslashes_deep($subject),'geodirectory');
668
+			$subject = __(stripslashes_deep($subject), 'geodirectory');
669 669
 		}
670 670
 		
671 671
 		if (!empty($message)) {
672
-			$message = __(stripslashes_deep($message),'geodirectory');
672
+			$message = __(stripslashes_deep($message), 'geodirectory');
673 673
 		}
674 674
 
675 675
         $to_message = nl2br($to_message);
@@ -704,12 +704,12 @@  discard block
 block discarded – undo
704 704
             $fromEmailName = get_option('site_email_name');
705 705
         }
706 706
 
707
-        $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#]');
708
-        $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);
707
+        $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#]');
708
+        $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);
709 709
         $message = str_replace($search_array, $replace_array, $message);
710 710
 
711
-        $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#]');
712
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login);
711
+        $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#]');
712
+        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login);
713 713
         $subject = str_replace($search_array, $replace_array, $subject);
714 714
 
715 715
         $headers = 'MIME-Version: 1.0' . "\r\n";
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
         $to = $toEmail;
721 721
         $sent = wp_mail($to, $subject, $message, $headers);
722 722
 
723
-        if( ! $sent ) {
724
-            if ( is_array( $to ) ) {
725
-                $to = implode( ',', $to );
723
+        if (!$sent) {
724
+            if (is_array($to)) {
725
+                $to = implode(',', $to);
726 726
             }
727 727
             $log_message = sprintf(
728
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
728
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
729 729
                 $message_type,
730
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
730
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
731 731
                 $to,
732 732
                 $subject
733 733
             );
734
-            geodir_error_log( $log_message );
734
+            geodir_error_log($log_message);
735 735
         }
736 736
 
737 737
         ///////// ADMIN BCC EMIALS
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
             $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
744 744
             $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
745 745
 
746
-            $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#]');
746
+            $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#]');
747 747
             $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);
748 748
             $message = str_replace($search_array, $replace_array, $message);
749 749
 
750
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
750
+            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
751 751
             $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
752 752
             $subject = str_replace($search_array, $replace_array, $subject);
753 753
 
@@ -772,21 +772,21 @@  discard block
 block discarded – undo
772 772
             $admin_bcc = true;
773 773
         }
774 774
 
775
-        if($admin_bcc===true){
775
+        if ($admin_bcc === true) {
776 776
             $sent = wp_mail($to, $subject, $message, $headers);
777 777
 
778
-            if( ! $sent ) {
779
-                if ( is_array( $to ) ) {
780
-                    $to = implode( ',', $to );
778
+            if (!$sent) {
779
+                if (is_array($to)) {
780
+                    $to = implode(',', $to);
781 781
                 }
782 782
                 $log_message = sprintf(
783
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
783
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
784 784
                     $message_type,
785
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
785
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
786 786
                     $to,
787 787
                     $subject
788 788
                 );
789
-                geodir_error_log( $log_message );
789
+                geodir_error_log($log_message);
790 790
             }
791 791
         }
792 792
 
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
             $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
882 882
 			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
883 883
 				
884
-			if(geodir_is_page('detail') && isset($post->country_slug)){
884
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
885 885
                 $location_terms = array(
886 886
                     'gd_country' => $post->country_slug,
887 887
                     'gd_region' => $post->region_slug,
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
             $breadcrumb .= stripslashes_deep($page_title);
1137 1137
             $breadcrumb .= '</li>';
1138 1138
         } else if (is_tag()) {
1139
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1139
+            $breadcrumb .= "<li> " . $separator . single_tag_title('', false) . '</li>';
1140 1140
         } else if (is_day()) {
1141 1141
             $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1142 1142
             the_time('F jS, Y');
@@ -1241,16 +1241,16 @@  discard block
 block discarded – undo
1241 1241
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1242 1242
     }
1243 1243
     elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
1244
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1244
+        $log_message = __('Remote file is incorrect size', 'geodirectory');
1245 1245
     }
1246 1246
     elseif (0 == $filesize) {
1247 1247
         $log_message = __('Zero size file downloaded', 'geodirectory');
1248 1248
     }
1249 1249
 
1250
-    if($log_message){
1250
+    if ($log_message) {
1251 1251
         $del = unlink($upload['file']);
1252
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1253
-        return new WP_Error('import_file_error',$log_message );
1252
+        if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
1253
+        return new WP_Error('import_file_error', $log_message);
1254 1254
     }
1255 1255
 
1256 1256
 
@@ -1266,10 +1266,10 @@  discard block
 block discarded – undo
1266 1266
  */
1267 1267
 function geodir_max_upload_size()
1268 1268
 {
1269
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1269
+    $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
1270 1270
 
1271 1271
     if ($max_filesize > 0 && $max_filesize < 1) {
1272
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1272
+        $max_filesize = (int) ($max_filesize * 1024) . 'kb';
1273 1273
     } else {
1274 1274
         $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1275 1275
     }
@@ -1338,35 +1338,35 @@  discard block
 block discarded – undo
1338 1338
     {
1339 1339
         global $wpdb;
1340 1340
         if ($message_type == 'expiration') {
1341
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1342
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1341
+            $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
1342
+            $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
1343 1343
         } elseif ($message_type == 'post_submited') {
1344
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1345
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1344
+            $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
1345
+            $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
1346 1346
         } elseif ($message_type == 'renew') {
1347
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1348
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1347
+            $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
1348
+            $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
1349 1349
         } elseif ($message_type == 'upgrade') {
1350
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1351
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1350
+            $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
1351
+            $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
1352 1352
         } elseif ($message_type == 'claim_approved') {
1353
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1354
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1353
+            $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
1354
+            $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
1355 1355
         } elseif ($message_type == 'claim_rejected') {
1356
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1357
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1356
+            $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
1357
+            $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
1358 1358
         } elseif ($message_type == 'claim_requested') {
1359
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1360
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1359
+            $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
1360
+            $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
1361 1361
         } elseif ($message_type == 'auto_claim') {
1362
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1363
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1362
+            $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
1363
+            $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
1364 1364
         } elseif ($message_type == 'payment_success') {
1365
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1366
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1365
+            $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
1366
+            $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
1367 1367
         } elseif ($message_type == 'payment_fail') {
1368
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1369
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1368
+            $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
1369
+            $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
1370 1370
         }
1371 1371
         $transaction_details = $custom_1;
1372 1372
         $fromEmail = get_option('site_email');
@@ -1407,18 +1407,18 @@  discard block
 block discarded – undo
1407 1407
         $to = $fromEmail;
1408 1408
         $message = $client_message;
1409 1409
         $sent = wp_mail($to, $subject, $message, $headers);
1410
-        if( ! $sent ) {
1411
-            if ( is_array( $to ) ) {
1412
-                $to = implode( ',', $to );
1410
+        if (!$sent) {
1411
+            if (is_array($to)) {
1412
+                $to = implode(',', $to);
1413 1413
             }
1414 1414
             $log_message = sprintf(
1415
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1415
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1416 1416
                 $message_type,
1417
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1417
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1418 1418
                 $to,
1419 1419
                 $subject
1420 1420
             );
1421
-            geodir_error_log( $log_message );
1421
+            geodir_error_log($log_message);
1422 1422
         }
1423 1423
     }
1424 1424
 }
@@ -1444,18 +1444,18 @@  discard block
 block discarded – undo
1444 1444
     {
1445 1445
         $login_details = '';
1446 1446
         if ($message_type == 'send_friend') {
1447
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1448
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1447
+            $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
1448
+            $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
1449 1449
         } elseif ($message_type == 'send_enquiry') {
1450
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1451
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1450
+            $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
1451
+            $message = __(get_option('email_enquiry_content'), 'geodirectory');
1452 1452
         } elseif ($message_type == 'forgot_password') {
1453
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1454
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1453
+            $subject = __(get_option('forgot_password_subject'), 'geodirectory');
1454
+            $message = __(get_option('forgot_password_content'), 'geodirectory');
1455 1455
             $login_details = $to_message;
1456 1456
         } elseif ($message_type == 'registration') {
1457
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1458
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1457
+            $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
1458
+            $message = __(get_option('registration_success_email_content'), 'geodirectory');
1459 1459
             $login_details = $to_message;
1460 1460
         }
1461 1461
         $to_message = nl2br($to_message);
@@ -1489,18 +1489,18 @@  discard block
 block discarded – undo
1489 1489
         $to = $toEmail;
1490 1490
 
1491 1491
         $sent = wp_mail($to, $subject, $message, $headers);
1492
-        if( ! $sent ) {
1493
-            if ( is_array( $to ) ) {
1494
-                $to = implode( ',', $to );
1492
+        if (!$sent) {
1493
+            if (is_array($to)) {
1494
+                $to = implode(',', $to);
1495 1495
             }
1496 1496
             $log_message = sprintf(
1497
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1497
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1498 1498
                 $message_type,
1499
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1499
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1500 1500
                 $to,
1501 1501
                 $subject
1502 1502
             );
1503
-            geodir_error_log( $log_message );
1503
+            geodir_error_log($log_message);
1504 1504
         }
1505 1505
 
1506 1506
         ///////// ADMIN BCC EMIALS
@@ -1526,20 +1526,20 @@  discard block
 block discarded – undo
1526 1526
             $admin_bcc = true;
1527 1527
         }
1528 1528
 
1529
-        if($admin_bcc === true){
1529
+        if ($admin_bcc === true) {
1530 1530
             $sent = wp_mail($to, $subject, $message, $headers);
1531
-            if( ! $sent ) {
1532
-                if ( is_array( $to ) ) {
1533
-                    $to = implode( ',', $to );
1531
+            if (!$sent) {
1532
+                if (is_array($to)) {
1533
+                    $to = implode(',', $to);
1534 1534
                 }
1535 1535
                 $log_message = sprintf(
1536
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1536
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1537 1537
                     $message_type,
1538
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1538
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
1539 1539
                     $to,
1540 1540
                     $subject
1541 1541
                 );
1542
-                geodir_error_log( $log_message );
1542
+                geodir_error_log($log_message);
1543 1543
             }
1544 1544
         }
1545 1545
 
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 function geodir_custom_posts_body_class($classes) {
1588 1588
     global $wpdb, $wp;
1589 1589
     $post_types = geodir_get_posttypes('object');
1590
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1590
+    if (!empty($post_types) && count((array) $post_types) > 1) {
1591 1591
         $classes[] = 'geodir_custom_posts';
1592 1592
     }
1593 1593
 
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
         $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1882 1882
 			" . $join . "
1883 1883
 			" . $where;
1884
-        $rows = (int)$wpdb->get_var($sql);
1884
+        $rows = (int) $wpdb->get_var($sql);
1885 1885
     } else {
1886 1886
         $orderby = geodir_widget_listings_get_order($query_args);
1887 1887
         /**
@@ -1907,10 +1907,10 @@  discard block
 block discarded – undo
1907 1907
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1908 1908
 
1909 1909
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1910
-        if ( !$page )
1910
+        if (!$page)
1911 1911
             $page = 1;
1912 1912
 
1913
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1913
+        $limit = (int) $limit > 0 ? " LIMIT " . absint(($page - 1) * (int) $limit) . ", " . (int) $limit : "";
1914 1914
 
1915 1915
         $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
1916 1916
 			" . $join . "
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
     }
2108 2108
 
2109 2109
     if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2110
-        $limit = (int)$query_args['posts_per_page'];
2110
+        $limit = (int) $query_args['posts_per_page'];
2111 2111
     }
2112 2112
 
2113 2113
     return $limit;
@@ -2250,9 +2250,9 @@  discard block
 block discarded – undo
2250 2250
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2251 2251
     }
2252 2252
     $home_url = str_replace("www.", "", $home_url);
2253
-    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')) ) {
2253
+    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'))) {
2254 2254
         return true;
2255
-    }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')){
2255
+    }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')) {
2256 2256
         return true;
2257 2257
     } else {
2258 2258
         return false;
@@ -2335,7 +2335,7 @@  discard block
 block discarded – undo
2335 2335
 
2336 2336
     $gd_post_type = geodir_get_current_posttype();
2337 2337
 
2338
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2338
+    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
2339 2339
     $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'] : '');
2340 2340
 
2341 2341
     $taxonomy = array();
@@ -2368,14 +2368,14 @@  discard block
 block discarded – undo
2368 2368
             foreach ($b_terms as $key => $val) {
2369 2369
                 $ptype = get_post_type_object(str_replace("category", "", $key));
2370 2370
                 $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2371
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2371
+                $tax_change_output .= "<option value='$key' " . selected($key, $default_taxonomy, false) . ">" . sprintf(__('%s Categories', 'geodirectory'), $cpt_name) . "</option>";
2372 2372
             }
2373 2373
             $tax_change_output .= "</select>";
2374 2374
         }
2375 2375
 
2376 2376
         if (!empty($b_terms)) {
2377
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2378
-            global $cat_count;//make global so we can change via function
2377
+            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array
2378
+            global $cat_count; //make global so we can change via function
2379 2379
             $cat_count = 0;
2380 2380
             ?>
2381 2381
             <div class="geodir-category-list-in clearfix">
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
         $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2440 2440
         $total_post = $cat->count;
2441 2441
 
2442
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2442
+        $term_link = get_term_link($cat, $cat->taxonomy);
2443 2443
         /**
2444 2444
          * Filer the category term link.
2445 2445
          *
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
          * @param int    $cat->term_id The term id.
2449 2449
          * @param string $post_type Wordpress post type.
2450 2450
          */
2451
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2451
+        $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
2452 2452
 
2453 2453
         echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2454 2454
         echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo geodir_ucwords($cat->name) . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
@@ -2582,28 +2582,28 @@  discard block
 block discarded – undo
2582 2582
                 itemWidth: 75,
2583 2583
                 itemMargin: 5,
2584 2584
                 asNavFor: '#geodir_widget_slider',
2585
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2585
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2586 2586
             });
2587 2587
 
2588 2588
             jQuery('#geodir_widget_slider').flexslider({
2589
-                animation: "<?php echo $animation;?>",
2589
+                animation: "<?php echo $animation; ?>",
2590 2590
                 selector: ".geodir-slides > li",
2591 2591
                 namespace: "geodir-",
2592 2592
                 controlNav: true,
2593
-                animationLoop: <?php echo $animationLoop;?>,
2594
-                slideshow: <?php echo $slideshow;?>,
2595
-                slideshowSpeed: <?php echo $slideshowSpeed;?>,
2596
-                animationSpeed: <?php echo $animationSpeed;?>,
2597
-                directionNav: <?php echo $directionNav;?>,
2598
-                maxItems: <?php echo $max_show;?>,
2599
-                <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
2593
+                animationLoop: <?php echo $animationLoop; ?>,
2594
+                slideshow: <?php echo $slideshow; ?>,
2595
+                slideshowSpeed: <?php echo $slideshowSpeed; ?>,
2596
+                animationSpeed: <?php echo $animationSpeed; ?>,
2597
+                directionNav: <?php echo $directionNav; ?>,
2598
+                maxItems: <?php echo $max_show; ?>,
2599
+                <?php if ($slide_width) { echo "itemWidth: " . $slide_width . ","; }?>
2600 2600
                 sync: "#geodir_widget_carousel",
2601 2601
                 start: function (slider) {
2602 2602
                     jQuery('.geodir-listing-flex-loader').hide();
2603 2603
                     jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
2604 2604
                     jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
2605 2605
                 },
2606
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2606
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2607 2607
             });
2608 2608
         });
2609 2609
     </script>
@@ -2644,7 +2644,7 @@  discard block
 block discarded – undo
2644 2644
 
2645 2645
         global $post;
2646 2646
 
2647
-        $current_post = $post;// keep current post info
2647
+        $current_post = $post; // keep current post info
2648 2648
 
2649 2649
         $widget_main_slides = '';
2650 2650
         $nav_slides = '';
@@ -3087,7 +3087,7 @@  discard block
 block discarded – undo
3087 3087
             $geodir_add_location_url = '1';
3088 3088
         }
3089 3089
 
3090
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3090
+        $viewall_url = get_term_link((int) $category[0], $post_type . 'category');
3091 3091
 
3092 3092
         $geodir_add_location_url = NULL;
3093 3093
     }
@@ -3095,7 +3095,7 @@  discard block
 block discarded – undo
3095 3095
         $gd_session->set('gd_multi_location', 1);
3096 3096
     }
3097 3097
 
3098
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3098
+    if (is_wp_error($viewall_url)) {$viewall_url = ''; }
3099 3099
 
3100 3100
     $query_args = array(
3101 3101
         'posts_per_page' => $post_number,
@@ -3333,14 +3333,14 @@  discard block
 block discarded – undo
3333 3333
  * @package GeoDirectory
3334 3334
  * @return bool
3335 3335
  */
3336
-function geodir_term_review_count_force_update($new_status, $old_status='', $post='')
3336
+function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '')
3337 3337
 {
3338
-    if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
3338
+    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {return; }//do not run if importing listings
3339 3339
 
3340
-    if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
3340
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
3341 3341
         return;
3342 3342
     }
3343
-    if($new_status!=$old_status) {
3343
+    if ($new_status != $old_status) {
3344 3344
         geodir_count_reviews_by_terms(true);
3345 3345
     }
3346 3346
     return true;
@@ -3505,7 +3505,7 @@  discard block
 block discarded – undo
3505 3505
          */
3506 3506
         try {
3507 3507
             require_once($language_file);
3508
-        } catch(Exception $e) {
3508
+        } catch (Exception $e) {
3509 3509
             error_log('Language Error: ' . $e->getMessage());
3510 3510
         }
3511 3511
     }
@@ -3523,18 +3523,18 @@  discard block
 block discarded – undo
3523 3523
  */
3524 3524
 function geodirectory_load_db_language() {
3525 3525
     global $wp_filesystem;
3526
-    if( empty( $wp_filesystem ) ) {
3527
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3526
+    if (empty($wp_filesystem)) {
3527
+        require_once(ABSPATH . '/wp-admin/includes/file.php');
3528 3528
         WP_Filesystem();
3529 3529
         global $wp_filesystem;
3530 3530
     }
3531 3531
 
3532 3532
     $language_file = geodir_plugin_path() . '/db-language.php';
3533 3533
 
3534
-    if(is_file($language_file) && !is_writable($language_file))
3534
+    if (is_file($language_file) && !is_writable($language_file))
3535 3535
         return false; // Not possible to create.
3536 3536
 
3537
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3537
+    if (!is_file($language_file) && !is_writable(dirname($language_file)))
3538 3538
         return false; // Not possible to create.
3539 3539
 
3540 3540
     $contents_strings = array();
@@ -3568,7 +3568,7 @@  discard block
 block discarded – undo
3568 3568
     $contents = implode(PHP_EOL, $contents_head);
3569 3569
 
3570 3570
     if (!empty($contents_strings)) {
3571
-        foreach ( $contents_strings as $string ) {
3571
+        foreach ($contents_strings as $string) {
3572 3572
             if (is_scalar($string) && $string != '') {
3573 3573
                 $string = str_replace("'", "\'", $string);
3574 3574
                 $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 
3579 3579
     $contents .= implode(PHP_EOL, $contents_foot);
3580 3580
 
3581
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3581
+    if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE))
3582 3582
         return false; // Failure; could not write file.
3583 3583
 
3584 3584
     return true;
@@ -3604,7 +3604,7 @@  discard block
 block discarded – undo
3604 3604
     $rows = $wpdb->get_results($sql);
3605 3605
 
3606 3606
     if (!empty($rows)) {
3607
-        foreach($rows as $row) {
3607
+        foreach ($rows as $row) {
3608 3608
             if (!empty($row->admin_title))
3609 3609
                 $translation_texts[] = stripslashes_deep($row->admin_title);
3610 3610
 			
@@ -3642,7 +3642,7 @@  discard block
 block discarded – undo
3642 3642
     $rows = $wpdb->get_results($sql);
3643 3643
 
3644 3644
     if (!empty($rows)) {
3645
-        foreach($rows as $row) {
3645
+        foreach ($rows as $row) {
3646 3646
             if (!empty($row->site_title))
3647 3647
                 $translation_texts[] = stripslashes_deep($row->site_title);
3648 3648
 
@@ -3660,7 +3660,7 @@  discard block
 block discarded – undo
3660 3660
 		$rows = $wpdb->get_results($sql);
3661 3661
 
3662 3662
 		if (!empty($rows)) {
3663
-			foreach($rows as $row) {
3663
+			foreach ($rows as $row) {
3664 3664
 				if (!empty($row->field_site_name))
3665 3665
 					$translation_texts[] = stripslashes_deep($row->field_site_name);
3666 3666
 
@@ -3695,7 +3695,7 @@  discard block
 block discarded – undo
3695 3695
      *
3696 3696
      * @param array $geodir_allowed_mime_types and file extensions.
3697 3697
      */
3698
-    return apply_filters( 'geodir_allowed_mime_types', array(
3698
+    return apply_filters('geodir_allowed_mime_types', array(
3699 3699
             'Image' => array( // Image formats.
3700 3700
                 'jpg' => 'image/jpeg',
3701 3701
                 'jpe' => 'image/jpeg',
@@ -3784,13 +3784,13 @@  discard block
 block discarded – undo
3784 3784
 
3785 3785
 
3786 3786
 
3787
-add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
3787
+add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
3788 3788
 /*
3789 3789
  * Add location variables to wpseo replacements.
3790 3790
  *
3791 3791
  * @since 1.5.4
3792 3792
  */
3793
-function geodir_wpseo_replacements($vars){
3793
+function geodir_wpseo_replacements($vars) {
3794 3794
 
3795 3795
     global $wp;
3796 3796
     $title = '';
@@ -3805,12 +3805,12 @@  discard block
 block discarded – undo
3805 3805
      * @param array $location_array The array of location variables.
3806 3806
      * @param array $vars The page title variables.
3807 3807
      */
3808
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
3808
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
3809 3809
     $location_titles = array();
3810
-    if(get_query_var( 'gd_country_full' )){
3811
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
3812
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
3813
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
3810
+    if (get_query_var('gd_country_full')) {
3811
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
3812
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
3813
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
3814 3814
     }
3815 3815
     $location_single = '';
3816 3816
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -3882,23 +3882,23 @@  discard block
 block discarded – undo
3882 3882
     }
3883 3883
 
3884 3884
 
3885
-    if(!empty($location_titles)) {
3885
+    if (!empty($location_titles)) {
3886 3886
         $vars['%%location%%'] = implode(", ", $location_titles);
3887 3887
     }
3888 3888
 
3889 3889
 
3890
-    if(!empty($location_titles)) {
3890
+    if (!empty($location_titles)) {
3891 3891
         $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
3892 3892
     }
3893 3893
 
3894 3894
 
3895 3895
 
3896
-    if($location_single) {
3897
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
3896
+    if ($location_single) {
3897
+        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' . $location_single;
3898 3898
     }
3899 3899
 
3900 3900
 
3901
-    if($location_single) {
3901
+    if ($location_single) {
3902 3902
         $vars['%%location_single%%'] = $location_single;
3903 3903
     }
3904 3904
 
@@ -3910,17 +3910,17 @@  discard block
 block discarded – undo
3910 3910
      * @param string $vars The title with variables.
3911 3911
      * @param array $location_array The array of location variables.
3912 3912
      */
3913
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3913
+    return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
3914 3914
 }
3915 3915
 
3916 3916
 
3917
-add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
3918
-add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
3919
-add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
3920
-function geodir_filter_title_variables($title, $gd_page, $sep=''){
3917
+add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
3918
+add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
3919
+add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
3920
+function geodir_filter_title_variables($title, $gd_page, $sep = '') {
3921 3921
 
3922 3922
 
3923
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
3923
+    if (!$gd_page || !$title) {return $title; }// if no a GD page then bail.
3924 3924
     global $post;
3925 3925
     //print_r($post);
3926 3926
     /*
@@ -3962,119 +3962,119 @@  discard block
 block discarded – undo
3962 3962
     }
3963 3963
 
3964 3964
 
3965
-    if(strpos($title,'%%title%%') !== false){
3966
-        $title = str_replace("%%title%%",$post->post_title,$title);
3965
+    if (strpos($title, '%%title%%') !== false) {
3966
+        $title = str_replace("%%title%%", $post->post_title, $title);
3967 3967
     }
3968 3968
 
3969
-    if(strpos($title,'%%sitename%%') !== false){
3970
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
3969
+    if (strpos($title, '%%sitename%%') !== false) {
3970
+        $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
3971 3971
     }
3972 3972
 
3973
-    if(strpos($title,'%%sitedesc%%') !== false){
3974
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
3973
+    if (strpos($title, '%%sitedesc%%') !== false) {
3974
+        $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
3975 3975
     }
3976 3976
 
3977
-    if(strpos($title,'%%excerpt%%') !== false){
3978
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
3977
+    if (strpos($title, '%%excerpt%%') !== false) {
3978
+        $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
3979 3979
     }
3980 3980
 
3981
-    if(strpos($title,'%%pt_single%%') !== false){
3981
+    if (strpos($title, '%%pt_single%%') !== false) {
3982 3982
         $single_name = '';
3983
-        if($gd_page=='search' || $gd_page=='author'){
3983
+        if ($gd_page == 'search' || $gd_page == 'author') {
3984 3984
             $geodir_post_types = get_option('geodir_post_types');
3985 3985
             $spt = esc_attr($_REQUEST['stype']);
3986
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3987
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3986
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
3987
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
3988 3988
             }
3989
-        }elseif($gd_page=='add-listing'){
3989
+        }elseif ($gd_page == 'add-listing') {
3990 3990
             $geodir_post_types = get_option('geodir_post_types');
3991 3991
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
3992
-            if(!$spt && isset($_REQUEST['pid'])){
3993
-                $spt = get_post_type( $_REQUEST['pid'] );
3992
+            if (!$spt && isset($_REQUEST['pid'])) {
3993
+                $spt = get_post_type($_REQUEST['pid']);
3994 3994
             }
3995
-            if(!$spt){$spt='gd_place';}
3996
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3997
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3995
+            if (!$spt) {$spt = 'gd_place'; }
3996
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
3997
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
3998 3998
             }
3999 3999
         }
4000
-        elseif($post->post_type){
4000
+        elseif ($post->post_type) {
4001 4001
             $geodir_post_types = get_option('geodir_post_types');
4002
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4003
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4002
+            if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) {
4003
+                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory');
4004 4004
             }
4005 4005
 
4006 4006
 
4007 4007
         }
4008
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4008
+        $title = str_replace("%%pt_single%%", $single_name, $title);
4009 4009
     }
4010 4010
 
4011
-    if(strpos($title,'%%pt_plural%%') !== false){
4011
+    if (strpos($title, '%%pt_plural%%') !== false) {
4012 4012
         $plural_name = '';
4013
-        if($gd_page=='search' || $gd_page=='author'){
4013
+        if ($gd_page == 'search' || $gd_page == 'author') {
4014 4014
             $geodir_post_types = get_option('geodir_post_types');
4015 4015
             $spt = esc_attr($_REQUEST['stype']);
4016
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4017
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4016
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4017
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4018 4018
             }
4019
-        }elseif($gd_page=='add-listing'){
4019
+        }elseif ($gd_page == 'add-listing') {
4020 4020
             $geodir_post_types = get_option('geodir_post_types');
4021 4021
             $spt = esc_attr($_REQUEST['listing_type']);
4022
-            if(!$spt){$spt='gd_place';}
4023
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4024
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4022
+            if (!$spt) {$spt = 'gd_place'; }
4023
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4024
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4025 4025
             }
4026 4026
         }
4027
-        elseif(isset($post->post_type) && $post->post_type){
4027
+        elseif (isset($post->post_type) && $post->post_type) {
4028 4028
             $geodir_post_types = get_option('geodir_post_types');
4029
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4030
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4029
+            if (isset($geodir_post_types[$post->post_type]['labels']['name'])) {
4030
+                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory');
4031 4031
             }
4032 4032
 
4033 4033
         }
4034
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4034
+        $title = str_replace("%%pt_plural%%", $plural_name, $title);
4035 4035
     }
4036 4036
 
4037 4037
 
4038 4038
 
4039
-    if(strpos($title,'%%category%%') !== false){
4039
+    if (strpos($title, '%%category%%') !== false) {
4040 4040
         $cat_name = '';
4041 4041
 
4042
-        if($gd_page=='detail') {
4042
+        if ($gd_page == 'detail') {
4043 4043
             if ($post->default_category) {
4044 4044
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4045 4045
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4046 4046
             }
4047
-        }elseif($gd_page=='listing'){
4047
+        }elseif ($gd_page == 'listing') {
4048 4048
             $queried_object = get_queried_object();
4049
-            if(isset($queried_object->name)){
4049
+            if (isset($queried_object->name)) {
4050 4050
                 $cat_name = $queried_object->name;
4051 4051
             }
4052 4052
         }
4053
-        $title = str_replace("%%category%%",$cat_name,$title);
4053
+        $title = str_replace("%%category%%", $cat_name, $title);
4054 4054
     }
4055 4055
 
4056
-    if(strpos($title,'%%tag%%') !== false){
4056
+    if (strpos($title, '%%tag%%') !== false) {
4057 4057
         $cat_name = '';
4058 4058
 
4059
-        if($gd_page=='detail') {
4059
+        if ($gd_page == 'detail') {
4060 4060
             if ($post->default_category) {
4061 4061
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4062 4062
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4063 4063
             }
4064
-        }elseif($gd_page=='listing'){
4064
+        }elseif ($gd_page == 'listing') {
4065 4065
             $queried_object = get_queried_object();
4066
-            if(isset($queried_object->name)){
4066
+            if (isset($queried_object->name)) {
4067 4067
                 $cat_name = $queried_object->name;
4068 4068
             }
4069 4069
         }
4070
-        $title = str_replace("%%tag%%",$cat_name,$title);
4070
+        $title = str_replace("%%tag%%", $cat_name, $title);
4071 4071
     }
4072 4072
 
4073 4073
 
4074 4074
 
4075
-    if(strpos($title,'%%id%%') !== false){
4075
+    if (strpos($title, '%%id%%') !== false) {
4076 4076
         $ID = (isset($post->ID)) ? $post->ID : '';
4077
-        $title = str_replace("%%id%%",$ID,$title);
4077
+        $title = str_replace("%%id%%", $ID, $title);
4078 4078
     }
4079 4079
 
4080 4080
     /*
@@ -4087,8 +4087,8 @@  discard block
 block discarded – undo
4087 4087
         }
4088 4088
     */
4089 4089
 
4090
-    if(strpos($title,'%%sep%%') !== false){
4091
-        $title = str_replace("%%sep%%",$sep,$title);
4090
+    if (strpos($title, '%%sep%%') !== false) {
4091
+        $title = str_replace("%%sep%%", $sep, $title);
4092 4092
     }
4093 4093
 
4094 4094
 
@@ -4106,12 +4106,12 @@  discard block
 block discarded – undo
4106 4106
      * @param string $gd_page The page being filtered.
4107 4107
      * @param string $sep The separator, default: `|`.
4108 4108
      */
4109
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4109
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
4110 4110
     $location_titles = array();
4111
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4112
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4113
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4114
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4111
+    if ($gd_page == 'location' && get_query_var('gd_country_full')) {
4112
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4113
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4114
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4115 4115
     }
4116 4116
     $location_single = '';
4117 4117
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4183,65 +4183,65 @@  discard block
 block discarded – undo
4183 4183
     }
4184 4184
 
4185 4185
 
4186
-    if(strpos($title,'%%location%%') !== false){
4186
+    if (strpos($title, '%%location%%') !== false) {
4187 4187
         $location = '';
4188
-        if($location_titles) {
4188
+        if ($location_titles) {
4189 4189
             $location = implode(", ", $location_titles);
4190 4190
         }
4191
-        $title = str_replace("%%location%%",$location,$title);
4191
+        $title = str_replace("%%location%%", $location, $title);
4192 4192
     }
4193 4193
 
4194
-    if(strpos($title,'%%in_location%%') !== false){
4194
+    if (strpos($title, '%%in_location%%') !== false) {
4195 4195
         $location = '';
4196
-        if($location_titles) {
4196
+        if ($location_titles) {
4197 4197
             $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4198 4198
         }
4199
-        $title = str_replace("%%in_location%%",$location,$title);
4199
+        $title = str_replace("%%in_location%%", $location, $title);
4200 4200
     }
4201 4201
 
4202
-    if(strpos($title,'%%in_location_single%%') !== false){
4203
-        if($location_single) {
4204
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4202
+    if (strpos($title, '%%in_location_single%%') !== false) {
4203
+        if ($location_single) {
4204
+            $location_single = __('in', 'geodirectory') . ' ' . $location_single;
4205 4205
         }
4206
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4206
+        $title = str_replace("%%in_location_single%%", $location_single, $title);
4207 4207
     }
4208 4208
 
4209
-    if(strpos($title,'%%location_single%%') !== false){
4210
-        $title = str_replace("%%location_single%%",$location_single,$title);
4209
+    if (strpos($title, '%%location_single%%') !== false) {
4210
+        $title = str_replace("%%location_single%%", $location_single, $title);
4211 4211
     }
4212 4212
 
4213 4213
 
4214
-    if(strpos($title,'%%search_term%%') !== false){
4214
+    if (strpos($title, '%%search_term%%') !== false) {
4215 4215
         $search_term = '';
4216
-        if(isset($_REQUEST['s'])){
4216
+        if (isset($_REQUEST['s'])) {
4217 4217
             $search_term = esc_attr($_REQUEST['s']);
4218 4218
         }
4219
-        $title = str_replace("%%search_term%%",$search_term,$title);
4219
+        $title = str_replace("%%search_term%%", $search_term, $title);
4220 4220
     }
4221 4221
 
4222
-    if(strpos($title,'%%search_near%%') !== false){
4222
+    if (strpos($title, '%%search_near%%') !== false) {
4223 4223
         $search_term = '';
4224
-        if(isset($_REQUEST['snear'])){
4224
+        if (isset($_REQUEST['snear'])) {
4225 4225
             $search_term = esc_attr($_REQUEST['snear']);
4226 4226
         }
4227
-        $title = str_replace("%%search_near%%",$search_term,$title);
4227
+        $title = str_replace("%%search_near%%", $search_term, $title);
4228 4228
     }
4229 4229
 
4230
-    if(strpos($title,'%%name%%') !== false){
4230
+    if (strpos($title, '%%name%%') !== false) {
4231 4231
         $author_name = '';
4232
-        if($author_name = get_the_author()){}
4233
-        else{
4232
+        if ($author_name = get_the_author()) {}
4233
+        else {
4234 4234
             $queried_object = get_queried_object();
4235
-            if(isset($queried_object->data->user_nicename)){
4235
+            if (isset($queried_object->data->user_nicename)) {
4236 4236
                 $author_name = $queried_object->data->user_nicename;
4237 4237
             }
4238 4238
         }
4239
-        $title = str_replace("%%name%%",$author_name,$title);
4239
+        $title = str_replace("%%name%%", $author_name, $title);
4240 4240
     }
4241 4241
 
4242
-    $title = wptexturize( $title );
4243
-    $title = convert_chars( $title );
4244
-    $title = esc_html( $title );
4242
+    $title = wptexturize($title);
4243
+    $title = convert_chars($title);
4244
+    $title = esc_html($title);
4245 4245
 
4246 4246
     /**
4247 4247
      * Filter the title variables after standard ones have been filtered.
@@ -4254,7 +4254,7 @@  discard block
 block discarded – undo
4254 4254
      * @param string $sep The separator, default: `|`.
4255 4255
      */
4256 4256
 
4257
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4257
+    return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
4258 4258
 }
4259 4259
 
4260 4260
 /**
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,20 +282,24 @@  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
-            if (is_single() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
276
-                return true;
295
+            if (is_single() && in_array(get_query_var('post_type'), geodir_get_posttypes())) {
296
+                            return true;
297
+            }
277 298
             break;
278 299
         case 'pt':
279
-            if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()) && !is_tax())
280
-                return true;
300
+            if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()) && !is_tax()) {
301
+                            return true;
302
+            }
281 303
 
282 304
             break;
283 305
         case 'listing':
@@ -286,23 +308,27 @@  discard block
 block discarded – undo
286 308
 
287 309
                 return true;
288 310
             }
289
-            if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
290
-                return true;
311
+            if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes())) {
312
+                            return true;
313
+            }
291 314
 
292 315
             break;
293 316
         case 'home':
294 317
 
295
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
296
-                return true;
318
+            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) {
319
+                            return true;
320
+            }
297 321
 
298 322
             break;
299 323
         case 'location':
300
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
301
-                return true;
324
+            if (is_page() && get_query_var('page_id') == geodir_location_page_id()) {
325
+                            return true;
326
+            }
302 327
             break;
303 328
         case 'author':
304
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
305
-                return true;
329
+            if (is_author() && isset($_REQUEST['geodir_dashbord'])) {
330
+                            return true;
331
+            }
306 332
 			
307 333
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
308 334
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
@@ -311,24 +337,29 @@  discard block
 block discarded – undo
311 337
 			}
312 338
             break;
313 339
         case 'search':
314
-            if (is_search() && isset($_REQUEST['geodir_search']))
315
-                return true;
340
+            if (is_search() && isset($_REQUEST['geodir_search'])) {
341
+                            return true;
342
+            }
316 343
             break;
317 344
         case 'info':
318
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
319
-                return true;
345
+            if (is_page() && get_query_var('page_id') == geodir_info_page_id()) {
346
+                            return true;
347
+            }
320 348
             break;
321 349
         case 'login':
322
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
323
-                return true;
350
+            if (is_page() && get_query_var('page_id') == geodir_login_page_id()) {
351
+                            return true;
352
+            }
324 353
             break;
325 354
         case 'checkout':
326
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
327
-                return true;
355
+            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) {
356
+                            return true;
357
+            }
328 358
             break;
329 359
         case 'invoices':
330
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
331
-                return true;
360
+            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) {
361
+                            return true;
362
+            }
332 363
             break;
333 364
         default:
334 365
             return false;
@@ -356,8 +387,9 @@  discard block
 block discarded – undo
356 387
         //$wp->query_vars['gd_is_geodir_page'] = false;
357 388
         //print_r()
358 389
         if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
359
-            if (get_option('geodir_set_as_home'))
360
-                $wp->query_vars['gd_is_geodir_page'] = true;
390
+            if (get_option('geodir_set_as_home')) {
391
+                            $wp->query_vars['gd_is_geodir_page'] = true;
392
+            }
361 393
             if(geodir_is_page('home')){
362 394
                 $wp->query_vars['gd_is_geodir_page'] = true;
363 395
             }
@@ -376,8 +408,9 @@  discard block
 block discarded – undo
376 408
                 || $wp->query_vars['page_id'] == geodir_login_page_id()
377 409
                 || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
378 410
                 || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
379
-            )
380
-                $wp->query_vars['gd_is_geodir_page'] = true;
411
+            ) {
412
+                            $wp->query_vars['gd_is_geodir_page'] = true;
413
+            }
381 414
         }
382 415
 
383 416
         if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
@@ -394,8 +427,9 @@  discard block
 block discarded – undo
394 427
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
395 428
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
396 429
                 )
397
-            )
398
-                $wp->query_vars['gd_is_geodir_page'] = true;
430
+            ) {
431
+                            $wp->query_vars['gd_is_geodir_page'] = true;
432
+            }
399 433
         }
400 434
 
401 435
 
@@ -418,12 +452,14 @@  discard block
 block discarded – undo
418 452
             }
419 453
         }
420 454
 
421
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
422
-            $wp->query_vars['gd_is_geodir_page'] = true;
455
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) {
456
+                    $wp->query_vars['gd_is_geodir_page'] = true;
457
+        }
423 458
 
424 459
 
425
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
426
-            $wp->query_vars['gd_is_geodir_page'] = true;
460
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) {
461
+                    $wp->query_vars['gd_is_geodir_page'] = true;
462
+        }
427 463
 
428 464
 
429 465
 //check if homepage
@@ -453,11 +489,12 @@  discard block
 block discarded – undo
453 489
 function geodir_is_geodir_page()
454 490
 {
455 491
     global $wp;
456
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
457
-        return true;
458
-    else
459
-        return false;
460
-}
492
+    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) {
493
+            return true;
494
+    } else {
495
+            return false;
496
+    }
497
+    }
461 498
 
462 499
 if (!function_exists('geodir_get_imagesize')) {
463 500
     /**
@@ -754,20 +791,16 @@  discard block
 block discarded – undo
754 791
             $subject .= ' - ADMIN BCC COPY';
755 792
             $admin_bcc = true;
756 793
 
757
-        }
758
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
794
+        } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
759 795
             $subject .= ' - ADMIN BCC COPY';
760 796
             $admin_bcc = true;
761
-        }
762
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
797
+        } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
763 798
             $subject .= ' - ADMIN BCC COPY';
764 799
             $admin_bcc = true;
765
-        }
766
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
800
+        } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
767 801
             $subject .= ' - ADMIN BCC COPY';
768 802
             $admin_bcc = true;
769
-        }
770
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
803
+        } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
771 804
             $subject .= ' - ADMIN BCC COPY';
772 805
             $admin_bcc = true;
773 806
         }
@@ -936,21 +969,24 @@  discard block
 block discarded – undo
936 969
             $is_location_last = '';
937 970
             $is_taxonomy_last = '';
938 971
             $breadcrumb .= '<li>';
939
-            if (get_query_var($gd_post_type . 'category'))
940
-                $gd_taxonomy = $gd_post_type . 'category';
941
-            elseif (get_query_var($gd_post_type . '_tags'))
942
-                $gd_taxonomy = $gd_post_type . '_tags';
972
+            if (get_query_var($gd_post_type . 'category')) {
973
+                            $gd_taxonomy = $gd_post_type . 'category';
974
+            } elseif (get_query_var($gd_post_type . '_tags')) {
975
+                            $gd_taxonomy = $gd_post_type . '_tags';
976
+            }
943 977
 
944 978
             $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
945
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
946
-                $is_location_last = false;
947
-            else
948
-                $is_location_last = true;
949
-
950
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
951
-                $is_taxonomy_last = true;
952
-            else
953
-                $is_taxonomy_last = false;
979
+            if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
980
+                            $is_location_last = false;
981
+            } else {
982
+                            $is_location_last = true;
983
+            }
984
+
985
+            if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
986
+                            $is_taxonomy_last = true;
987
+            } else {
988
+                            $is_taxonomy_last = false;
989
+            }
954 990
 
955 991
             if (!empty($location_terms)) {
956 992
                 $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
@@ -1032,8 +1068,9 @@  discard block
 block discarded – undo
1032 1068
                 {
1033 1069
                     if (get_query_var($gd_post_type . '_tags')) {
1034 1070
                         $cat_link = $listing_link . 'tags/';
1035
-                    } else
1036
-                        $cat_link = $listing_link;
1071
+                    } else {
1072
+                                            $cat_link = $listing_link;
1073
+                    }
1037 1074
 
1038 1075
                     foreach ($location_terms as $key => $location_term) {
1039 1076
                         if ($location_manager && in_array($key, $hide_url_part)) {
@@ -1060,9 +1097,9 @@  discard block
 block discarded – undo
1060 1097
                             $term_link_text = geodir_ucwords(urldecode($term_link_text));
1061 1098
                         }
1062 1099
 
1063
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1064
-                            $breadcrumb .= $separator . $term_link_text;
1065
-                        else {
1100
+                        if ($term_index == count($term_array) && $is_taxonomy_last) {
1101
+                                                    $breadcrumb .= $separator . $term_link_text;
1102
+                        } else {
1066 1103
                             $cat_link .= $term . '/';
1067 1104
                             $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1068 1105
                         }
@@ -1073,8 +1110,9 @@  discard block
 block discarded – undo
1073 1110
 
1074 1111
             }
1075 1112
 
1076
-            if (geodir_is_page('detail'))
1077
-                $breadcrumb .= $separator . get_the_title();
1113
+            if (geodir_is_page('detail')) {
1114
+                            $breadcrumb .= $separator . get_the_title();
1115
+            }
1078 1116
 
1079 1117
             $breadcrumb .= '</li>';
1080 1118
 
@@ -1111,8 +1149,9 @@  discard block
 block discarded – undo
1111 1149
 
1112 1150
                 $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1113 1151
                 $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1114
-            } else
1115
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1152
+            } else {
1153
+                            $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1154
+            }
1116 1155
 
1117 1156
             $breadcrumb .= '</li>';
1118 1157
         } elseif (is_category() || is_single()) {
@@ -1187,12 +1226,14 @@  discard block
 block discarded – undo
1187 1226
     function geodir_allow_wpadmin()
1188 1227
     {
1189 1228
         global $wpdb;
1190
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1229
+        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) {
1230
+        	// checking action in request to allow ajax request go through
1191 1231
         {
1192 1232
             if (current_user_can('manage_options')) {
1193 1233
             } else {
1194 1234
 
1195
-                wp_redirect(home_url());
1235
+                wp_redirect(home_url());
1236
+        }
1196 1237
                 exit;
1197 1238
             }
1198 1239
 
@@ -1224,8 +1265,9 @@  discard block
 block discarded – undo
1224 1265
     $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1225 1266
 
1226 1267
     $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1227
-    if ($upload['error'])
1228
-        return new WP_Error('upload_dir_error', $upload['error']);
1268
+    if ($upload['error']) {
1269
+            return new WP_Error('upload_dir_error', $upload['error']);
1270
+    }
1229 1271
 
1230 1272
     // fetch the remote url and write it to the placeholder file
1231 1273
     $headers = wp_get_http($url, $upload['file']);
@@ -1239,11 +1281,9 @@  discard block
 block discarded – undo
1239 1281
     // make sure the fetch was successful
1240 1282
     elseif ($headers['response'] != '200') {
1241 1283
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1242
-    }
1243
-    elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
1284
+    } elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
1244 1285
         $log_message =  __('Remote file is incorrect size', 'geodirectory');
1245
-    }
1246
-    elseif (0 == $filesize) {
1286
+    } elseif (0 == $filesize) {
1247 1287
         $log_message = __('Zero size file downloaded', 'geodirectory');
1248 1288
     }
1249 1289
 
@@ -1295,10 +1335,11 @@  discard block
 block discarded – undo
1295 1335
 function geodir_dummy_folder_exists()
1296 1336
 {
1297 1337
     $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1298
-    if (!is_dir($path))
1299
-        return false;
1300
-    else
1301
-        return true;
1338
+    if (!is_dir($path)) {
1339
+            return false;
1340
+    } else {
1341
+            return true;
1342
+    }
1302 1343
 
1303 1344
 }
1304 1345
 
@@ -1516,12 +1557,10 @@  discard block
 block discarded – undo
1516 1557
         if ($message_type == 'registration' && get_option('bcc_new_user')) {
1517 1558
             $subject .= ' - ADMIN BCC COPY';
1518 1559
             $admin_bcc = true;
1519
-        }
1520
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1560
+        } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1521 1561
             $subject .= ' - ADMIN BCC COPY';
1522 1562
             $admin_bcc = true;
1523
-        }
1524
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1563
+        } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1525 1564
             $subject .= ' - ADMIN BCC COPY';
1526 1565
             $admin_bcc = true;
1527 1566
         }
@@ -1565,7 +1604,9 @@  discard block
 block discarded – undo
1565 1604
         $res = array();
1566 1605
         foreach ($ids_array as $id) {
1567 1606
             $xlat = icl_object_id($id, $type, false);
1568
-            if (!is_null($xlat)) $res[] = $xlat;
1607
+            if (!is_null($xlat)) {
1608
+            	$res[] = $xlat;
1609
+            }
1569 1610
         }
1570 1611
         return $res;
1571 1612
     } else {
@@ -1907,8 +1948,9 @@  discard block
 block discarded – undo
1907 1948
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1908 1949
 
1909 1950
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1910
-        if ( !$page )
1911
-            $page = 1;
1951
+        if ( !$page ) {
1952
+                    $page = 1;
1953
+        }
1912 1954
 
1913 1955
         $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1914 1956
 
@@ -2252,7 +2294,7 @@  discard block
 block discarded – undo
2252 2294
     $home_url = str_replace("www.", "", $home_url);
2253 2295
     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')) ) {
2254 2296
         return true;
2255
-    }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')){
2297
+    } 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')){
2256 2298
         return true;
2257 2299
     } else {
2258 2300
         return false;
@@ -2746,8 +2788,9 @@  discard block
 block discarded – undo
2746 2788
                         $name = $postobj->labels->name;
2747 2789
 
2748 2790
                         $selected = '';
2749
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2750
-                            $selected = 'selected="selected"';
2791
+                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
2792
+                                                    $selected = 'selected="selected"';
2793
+                        }
2751 2794
 
2752 2795
                         /**
2753 2796
                          * Filter add listing link.
@@ -3214,8 +3257,9 @@  discard block
 block discarded – undo
3214 3257
             $geodir_is_widget_listing = false;
3215 3258
 
3216 3259
             $GLOBALS['post'] = $current_post;
3217
-            if (!empty($current_post))
3218
-                setup_postdata($current_post);
3260
+            if (!empty($current_post)) {
3261
+                            setup_postdata($current_post);
3262
+            }
3219 3263
             $map_jason = $current_map_jason;
3220 3264
             $map_canvas_arr = $current_map_canvas_arr;
3221 3265
             ?>
@@ -3531,11 +3575,15 @@  discard block
 block discarded – undo
3531 3575
 
3532 3576
     $language_file = geodir_plugin_path() . '/db-language.php';
3533 3577
 
3534
-    if(is_file($language_file) && !is_writable($language_file))
3535
-        return false; // Not possible to create.
3578
+    if(is_file($language_file) && !is_writable($language_file)) {
3579
+            return false;
3580
+    }
3581
+    // Not possible to create.
3536 3582
 
3537
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3538
-        return false; // Not possible to create.
3583
+    if(!is_file($language_file) && !is_writable(dirname($language_file))) {
3584
+            return false;
3585
+    }
3586
+    // Not possible to create.
3539 3587
 
3540 3588
     $contents_strings = array();
3541 3589
 
@@ -3578,8 +3626,10 @@  discard block
 block discarded – undo
3578 3626
 
3579 3627
     $contents .= implode(PHP_EOL, $contents_foot);
3580 3628
 
3581
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3582
-        return false; // Failure; could not write file.
3629
+    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) {
3630
+            return false;
3631
+    }
3632
+    // Failure; could not write file.
3583 3633
 
3584 3634
     return true;
3585 3635
 }
@@ -3605,23 +3655,29 @@  discard block
 block discarded – undo
3605 3655
 
3606 3656
     if (!empty($rows)) {
3607 3657
         foreach($rows as $row) {
3608
-            if (!empty($row->admin_title))
3609
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3658
+            if (!empty($row->admin_title)) {
3659
+                            $translation_texts[] = stripslashes_deep($row->admin_title);
3660
+            }
3610 3661
 			
3611
-            if (!empty($row->admin_desc))
3612
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3662
+            if (!empty($row->admin_desc)) {
3663
+                            $translation_texts[] = stripslashes_deep($row->admin_desc);
3664
+            }
3613 3665
 
3614
-            if (!empty($row->site_title))
3615
-                $translation_texts[] = stripslashes_deep($row->site_title);
3666
+            if (!empty($row->site_title)) {
3667
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3668
+            }
3616 3669
 
3617
-            if (!empty($row->clabels))
3618
-                $translation_texts[] = stripslashes_deep($row->clabels);
3670
+            if (!empty($row->clabels)) {
3671
+                            $translation_texts[] = stripslashes_deep($row->clabels);
3672
+            }
3619 3673
 
3620
-            if (!empty($row->required_msg))
3621
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3674
+            if (!empty($row->required_msg)) {
3675
+                            $translation_texts[] = stripslashes_deep($row->required_msg);
3676
+            }
3622 3677
 			
3623
-			if (!empty($row->default_value))
3624
-                $translation_texts[] = stripslashes_deep($row->default_value);
3678
+			if (!empty($row->default_value)) {
3679
+			                $translation_texts[] = stripslashes_deep($row->default_value);
3680
+			}
3625 3681
 			
3626 3682
 			if (!empty($row->option_values)) {
3627 3683
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3643,14 +3699,17 @@  discard block
 block discarded – undo
3643 3699
 
3644 3700
     if (!empty($rows)) {
3645 3701
         foreach($rows as $row) {
3646
-            if (!empty($row->site_title))
3647
-                $translation_texts[] = stripslashes_deep($row->site_title);
3702
+            if (!empty($row->site_title)) {
3703
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3704
+            }
3648 3705
 
3649
-            if (!empty($row->asc_title))
3650
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3706
+            if (!empty($row->asc_title)) {
3707
+                            $translation_texts[] = stripslashes_deep($row->asc_title);
3708
+            }
3651 3709
 
3652
-            if (!empty($row->desc_title))
3653
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3710
+            if (!empty($row->desc_title)) {
3711
+                            $translation_texts[] = stripslashes_deep($row->desc_title);
3712
+            }
3654 3713
         }
3655 3714
     }
3656 3715
 	
@@ -3661,14 +3720,17 @@  discard block
 block discarded – undo
3661 3720
 
3662 3721
 		if (!empty($rows)) {
3663 3722
 			foreach($rows as $row) {
3664
-				if (!empty($row->field_site_name))
3665
-					$translation_texts[] = stripslashes_deep($row->field_site_name);
3723
+				if (!empty($row->field_site_name)) {
3724
+									$translation_texts[] = stripslashes_deep($row->field_site_name);
3725
+				}
3666 3726
 
3667
-				if (!empty($row->front_search_title))
3668
-					$translation_texts[] = stripslashes_deep($row->front_search_title);
3727
+				if (!empty($row->front_search_title)) {
3728
+									$translation_texts[] = stripslashes_deep($row->front_search_title);
3729
+				}
3669 3730
 
3670
-				if (!empty($row->field_desc))
3671
-					$translation_texts[] = stripslashes_deep($row->field_desc);
3731
+				if (!empty($row->field_desc)) {
3732
+									$translation_texts[] = stripslashes_deep($row->field_desc);
3733
+				}
3672 3734
 			}
3673 3735
 		}
3674 3736
 	}
@@ -3986,7 +4048,7 @@  discard block
 block discarded – undo
3986 4048
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3987 4049
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3988 4050
             }
3989
-        }elseif($gd_page=='add-listing'){
4051
+        } elseif($gd_page=='add-listing'){
3990 4052
             $geodir_post_types = get_option('geodir_post_types');
3991 4053
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
3992 4054
             if(!$spt && isset($_REQUEST['pid'])){
@@ -3996,8 +4058,7 @@  discard block
 block discarded – undo
3996 4058
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3997 4059
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3998 4060
             }
3999
-        }
4000
-        elseif($post->post_type){
4061
+        } elseif($post->post_type){
4001 4062
             $geodir_post_types = get_option('geodir_post_types');
4002 4063
             if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4003 4064
                 $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
@@ -4016,15 +4077,14 @@  discard block
 block discarded – undo
4016 4077
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4017 4078
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4018 4079
             }
4019
-        }elseif($gd_page=='add-listing'){
4080
+        } elseif($gd_page=='add-listing'){
4020 4081
             $geodir_post_types = get_option('geodir_post_types');
4021 4082
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4022 4083
             if(!$spt){$spt='gd_place';}
4023 4084
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4024 4085
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4025 4086
             }
4026
-        }
4027
-        elseif(isset($post->post_type) && $post->post_type){
4087
+        } elseif(isset($post->post_type) && $post->post_type){
4028 4088
             $geodir_post_types = get_option('geodir_post_types');
4029 4089
             if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4030 4090
                 $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
@@ -4044,7 +4104,7 @@  discard block
 block discarded – undo
4044 4104
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4045 4105
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4046 4106
             }
4047
-        }elseif($gd_page=='listing'){
4107
+        } elseif($gd_page=='listing'){
4048 4108
             $queried_object = get_queried_object();
4049 4109
             if(isset($queried_object->name)){
4050 4110
                 $cat_name = $queried_object->name;
@@ -4061,7 +4121,7 @@  discard block
 block discarded – undo
4061 4121
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4062 4122
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4063 4123
             }
4064
-        }elseif($gd_page=='listing'){
4124
+        } elseif($gd_page=='listing'){
4065 4125
             $queried_object = get_queried_object();
4066 4126
             if(isset($queried_object->name)){
4067 4127
                 $cat_name = $queried_object->name;
@@ -4229,8 +4289,7 @@  discard block
 block discarded – undo
4229 4289
 
4230 4290
     if(strpos($title,'%%name%%') !== false){
4231 4291
         $author_name = '';
4232
-        if($author_name = get_the_author()){}
4233
-        else{
4292
+        if($author_name = get_the_author()){} else{
4234 4293
             $queried_object = get_queried_object();
4235 4294
             if(isset($queried_object->data->user_nicename)){
4236 4295
                 $author_name = $queried_object->data->user_nicename;
@@ -4276,38 +4335,54 @@  discard block
 block discarded – undo
4276 4335
             $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4277 4336
 
4278 4337
             if (!empty($labels)) {
4279
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4280
-                    $translation_texts[] = $labels['name'];
4281
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4282
-                    $translation_texts[] = $labels['singular_name'];
4283
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4284
-                    $translation_texts[] = $labels['add_new'];
4285
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4286
-                    $translation_texts[] = $labels['add_new_item'];
4287
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4288
-                    $translation_texts[] = $labels['edit_item'];
4289
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4290
-                    $translation_texts[] = $labels['new_item'];
4291
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4292
-                    $translation_texts[] = $labels['view_item'];
4293
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4294
-                    $translation_texts[] = $labels['search_items'];
4295
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4296
-                    $translation_texts[] = $labels['not_found'];
4297
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4298
-                    $translation_texts[] = $labels['not_found_in_trash'];
4299
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4300
-                    $translation_texts[] = $labels['label_post_profile'];
4301
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4302
-                    $translation_texts[] = $labels['label_post_info'];
4303
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4304
-                    $translation_texts[] = $labels['label_post_images'];
4305
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4306
-                    $translation_texts[] = $labels['label_post_map'];
4307
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4308
-                    $translation_texts[] = $labels['label_reviews'];
4309
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4310
-                    $translation_texts[] = $labels['label_related_listing'];
4338
+                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
4339
+                                    $translation_texts[] = $labels['name'];
4340
+                }
4341
+                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
4342
+                                    $translation_texts[] = $labels['singular_name'];
4343
+                }
4344
+                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
4345
+                                    $translation_texts[] = $labels['add_new'];
4346
+                }
4347
+                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
4348
+                                    $translation_texts[] = $labels['add_new_item'];
4349
+                }
4350
+                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
4351
+                                    $translation_texts[] = $labels['edit_item'];
4352
+                }
4353
+                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
4354
+                                    $translation_texts[] = $labels['new_item'];
4355
+                }
4356
+                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
4357
+                                    $translation_texts[] = $labels['view_item'];
4358
+                }
4359
+                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
4360
+                                    $translation_texts[] = $labels['search_items'];
4361
+                }
4362
+                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
4363
+                                    $translation_texts[] = $labels['not_found'];
4364
+                }
4365
+                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
4366
+                                    $translation_texts[] = $labels['not_found_in_trash'];
4367
+                }
4368
+                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
4369
+                                    $translation_texts[] = $labels['label_post_profile'];
4370
+                }
4371
+                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
4372
+                                    $translation_texts[] = $labels['label_post_info'];
4373
+                }
4374
+                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
4375
+                                    $translation_texts[] = $labels['label_post_images'];
4376
+                }
4377
+                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
4378
+                                    $translation_texts[] = $labels['label_post_map'];
4379
+                }
4380
+                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
4381
+                                    $translation_texts[] = $labels['label_reviews'];
4382
+                }
4383
+                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
4384
+                                    $translation_texts[] = $labels['label_related_listing'];
4385
+                }
4311 4386
             }
4312 4387
 
4313 4388
             if ($description != '' && !in_array($description, $translation_texts)) {
@@ -4315,11 +4390,13 @@  discard block
 block discarded – undo
4315 4390
             }
4316 4391
 
4317 4392
             if (!empty($seo)) {
4318
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4319
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4393
+                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
4394
+                                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4395
+                }
4320 4396
 
4321
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4322
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4397
+                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
4398
+                                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4399
+                }
4323 4400
             }
4324 4401
         }
4325 4402
     }
@@ -4345,16 +4422,20 @@  discard block
 block discarded – undo
4345 4422
         $hide_region_part = get_option('geodir_location_hide_region_part');
4346 4423
 
4347 4424
         if ($hide_region_part && $hide_country_part) {
4348
-            if (isset($location_terms['gd_country']))
4349
-                unset($location_terms['gd_country']);
4350
-            if (isset($location_terms['gd_region']))
4351
-                unset($location_terms['gd_region']);
4425
+            if (isset($location_terms['gd_country'])) {
4426
+                            unset($location_terms['gd_country']);
4427
+            }
4428
+            if (isset($location_terms['gd_region'])) {
4429
+                            unset($location_terms['gd_region']);
4430
+            }
4352 4431
         } else if ($hide_region_part && !$hide_country_part) {
4353
-            if (isset($location_terms['gd_region']))
4354
-                unset($location_terms['gd_region']);
4432
+            if (isset($location_terms['gd_region'])) {
4433
+                            unset($location_terms['gd_region']);
4434
+            }
4355 4435
         } else if (!$hide_region_part && $hide_country_part) {
4356
-            if (isset($location_terms['gd_country']))
4357
-                unset($location_terms['gd_country']);
4436
+            if (isset($location_terms['gd_country'])) {
4437
+                            unset($location_terms['gd_country']);
4438
+            }
4358 4439
         }
4359 4440
     }
4360 4441
 
Please login to merge, or discard this patch.
Indentation   +2906 added lines, -2906 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,7 +47,7 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_plugin_path()
49 49
 {
50
-    return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
50
+	return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
51 51
 }
52 52
 
53 53
 /**
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
  */
62 62
 function geodir_is_plugin_active($plugin)
63 63
 {
64
-    $active_plugins = get_option('active_plugins');
65
-    foreach ($active_plugins as $key => $active_plugin) {
66
-        if (strstr($active_plugin, $plugin)) return true;
67
-    }
68
-    return false;
64
+	$active_plugins = get_option('active_plugins');
65
+	foreach ($active_plugins as $key => $active_plugin) {
66
+		if (strstr($active_plugin, $plugin)) return true;
67
+	}
68
+	return false;
69 69
 }
70 70
 
71 71
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function geodir_get_formated_date($date)
83 83
 {
84
-    return mysql2date(get_option('date_format'), $date);
84
+	return mysql2date(get_option('date_format'), $date);
85 85
 }
86 86
 
87 87
 /**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
  */
97 97
 function geodir_get_formated_time($time)
98 98
 {
99
-    return mysql2date(get_option('time_format'), $time, $translate = true);
99
+	return mysql2date(get_option('time_format'), $time, $translate = true);
100 100
 }
101 101
 
102 102
 
@@ -114,26 +114,26 @@  discard block
 block discarded – undo
114 114
  */
115 115
 function geodir_getlink($url, $params = array(), $use_existing_arguments = false)
116 116
 {
117
-    if ($use_existing_arguments) $params = $params + $_GET;
118
-    if (!$params) return $url;
119
-    $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.
123
-
124
-    $params_arr = array();
125
-    foreach ($params as $key => $value) {
126
-        if (gettype($value) == 'array') { //Handle array data properly
127
-            foreach ($value as $val) {
128
-                $params_arr[] = $key . '[]=' . urlencode($val);
129
-            }
130
-        } else {
131
-            $params_arr[] = $key . '=' . urlencode($value);
132
-        }
133
-    }
134
-    $link .= implode('&', $params_arr);
117
+	if ($use_existing_arguments) $params = $params + $_GET;
118
+	if (!$params) return $url;
119
+	$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.
123
+
124
+	$params_arr = array();
125
+	foreach ($params as $key => $value) {
126
+		if (gettype($value) == 'array') { //Handle array data properly
127
+			foreach ($value as $val) {
128
+				$params_arr[] = $key . '[]=' . urlencode($val);
129
+			}
130
+		} else {
131
+			$params_arr[] = $key . '=' . urlencode($value);
132
+		}
133
+	}
134
+	$link .= implode('&', $params_arr);
135 135
 
136
-    return $link;
136
+	return $link;
137 137
 }
138 138
 
139 139
 
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function geodir_get_addlisting_link($post_type = '')
150 150
 {
151
-    global $wpdb;
151
+	global $wpdb;
152 152
 
153
-    //$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
154
-    $check_pkg = 1;
155
-    if (post_type_exists($post_type) && $check_pkg) {
153
+	//$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
154
+	$check_pkg = 1;
155
+	if (post_type_exists($post_type) && $check_pkg) {
156 156
 
157
-        $add_listing_link = get_page_link(geodir_add_listing_page_id());
157
+		$add_listing_link = get_page_link(geodir_add_listing_page_id());
158 158
 
159
-        return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
160
-    } else
161
-        return get_bloginfo('url');
159
+		return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
160
+	} else
161
+		return get_bloginfo('url');
162 162
 }
163 163
 
164 164
 /**
@@ -171,19 +171,19 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function geodir_curPageURL()
173 173
 {
174
-    $pageURL = 'http';
175
-    if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
176
-        $pageURL .= "s";
177
-    }
178
-    $pageURL .= "://";
179
-    $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
180
-    /**
181
-     * Filter the current page URL returned by function geodir_curPageURL().
182
-     *
183
-     * @since 1.4.1
184
-     * @param string $pageURL The URL of the current page.
185
-     */
186
-    return apply_filters('geodir_curPageURL', $pageURL);
174
+	$pageURL = 'http';
175
+	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
176
+		$pageURL .= "s";
177
+	}
178
+	$pageURL .= "://";
179
+	$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
180
+	/**
181
+	 * Filter the current page URL returned by function geodir_curPageURL().
182
+	 *
183
+	 * @since 1.4.1
184
+	 * @param string $pageURL The URL of the current page.
185
+	 */
186
+	return apply_filters('geodir_curPageURL', $pageURL);
187 187
 }
188 188
 
189 189
 
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
 function geodir_clean($string)
201 201
 {
202 202
 
203
-    $string = trim(strip_tags(stripslashes($string)));
204
-    $string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
205
-    $string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
206
-    $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
203
+	$string = trim(strip_tags(stripslashes($string)));
204
+	$string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
205
+	$string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
206
+	$string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
207 207
 
208
-    return $string;
208
+	return $string;
209 209
 }
210 210
 
211 211
 /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
  */
218 218
 function geodir_get_weekday()
219 219
 {
220
-    return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
220
+	return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
221 221
 }
222 222
 
223 223
 /**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
  */
230 230
 function geodir_get_weeks()
231 231
 {
232
-    return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
232
+	return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
233 233
 }
234 234
 
235 235
 
@@ -248,97 +248,97 @@  discard block
 block discarded – undo
248 248
 function geodir_is_page($gdpage = '')
249 249
 {
250 250
 
251
-    global $wp_query, $post,$wp;
252
-    //if(!is_admin()):
253
-
254
-    switch ($gdpage):
255
-        case 'add-listing':
256
-
257
-            if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
258
-                return true;
259
-            } elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
260
-                return true;
261
-            }
262
-
263
-            break;
264
-        case 'preview':
265
-            if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
266
-                && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
267
-            )
268
-                return true;
269
-            break;
270
-        case 'listing-success':
271
-            if (is_page() && get_query_var('page_id') == geodir_success_page_id())
272
-                return true;
273
-            break;
274
-        case 'detail':
275
-            if (is_single() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
276
-                return true;
277
-            break;
278
-        case 'pt':
279
-            if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()) && !is_tax())
280
-                return true;
281
-
282
-            break;
283
-        case 'listing':
284
-            if (is_tax() && geodir_get_taxonomy_posttype()) {
285
-                global $current_term, $taxonomy, $term;
286
-
287
-                return true;
288
-            }
289
-            if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
290
-                return true;
291
-
292
-            break;
293
-        case 'home':
294
-
295
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
296
-                return true;
297
-
298
-            break;
299
-        case 'location':
300
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
301
-                return true;
302
-            break;
303
-        case 'author':
304
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
305
-                return true;
251
+	global $wp_query, $post,$wp;
252
+	//if(!is_admin()):
253
+
254
+	switch ($gdpage):
255
+		case 'add-listing':
256
+
257
+			if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
258
+				return true;
259
+			} elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
260
+				return true;
261
+			}
262
+
263
+			break;
264
+		case 'preview':
265
+			if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
266
+				&& in_array($_REQUEST['listing_type'], geodir_get_posttypes())
267
+			)
268
+				return true;
269
+			break;
270
+		case 'listing-success':
271
+			if (is_page() && get_query_var('page_id') == geodir_success_page_id())
272
+				return true;
273
+			break;
274
+		case 'detail':
275
+			if (is_single() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
276
+				return true;
277
+			break;
278
+		case 'pt':
279
+			if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()) && !is_tax())
280
+				return true;
281
+
282
+			break;
283
+		case 'listing':
284
+			if (is_tax() && geodir_get_taxonomy_posttype()) {
285
+				global $current_term, $taxonomy, $term;
286
+
287
+				return true;
288
+			}
289
+			if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
290
+				return true;
291
+
292
+			break;
293
+		case 'home':
294
+
295
+			if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
296
+				return true;
297
+
298
+			break;
299
+		case 'location':
300
+			if (is_page() && get_query_var('page_id') == geodir_location_page_id())
301
+				return true;
302
+			break;
303
+		case 'author':
304
+			if (is_author() && isset($_REQUEST['geodir_dashbord']))
305
+				return true;
306 306
 			
307 307
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
308 308
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
309 309
 					return true;
310 310
 				}
311 311
 			}
312
-            break;
313
-        case 'search':
314
-            if (is_search() && isset($_REQUEST['geodir_search']))
315
-                return true;
316
-            break;
317
-        case 'info':
318
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
319
-                return true;
320
-            break;
321
-        case 'login':
322
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
323
-                return true;
324
-            break;
325
-        case 'checkout':
326
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
327
-                return true;
328
-            break;
329
-        case 'invoices':
330
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
331
-                return true;
332
-            break;
333
-        default:
334
-            return false;
335
-            break;
336
-
337
-    endswitch;
338
-
339
-    //endif;
340
-
341
-    return false;
312
+			break;
313
+		case 'search':
314
+			if (is_search() && isset($_REQUEST['geodir_search']))
315
+				return true;
316
+			break;
317
+		case 'info':
318
+			if (is_page() && get_query_var('page_id') == geodir_info_page_id())
319
+				return true;
320
+			break;
321
+		case 'login':
322
+			if (is_page() && get_query_var('page_id') == geodir_login_page_id())
323
+				return true;
324
+			break;
325
+		case 'checkout':
326
+			if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
327
+				return true;
328
+			break;
329
+		case 'invoices':
330
+			if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
331
+				return true;
332
+			break;
333
+		default:
334
+			return false;
335
+			break;
336
+
337
+	endswitch;
338
+
339
+	//endif;
340
+
341
+	return false;
342 342
 }
343 343
 
344 344
 /**
@@ -352,94 +352,94 @@  discard block
 block discarded – undo
352 352
  */
353 353
 function geodir_set_is_geodir_page($wp)
354 354
 {
355
-    if (!is_admin()) {
356
-        //$wp->query_vars['gd_is_geodir_page'] = false;
357
-        //print_r()
358
-        if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
359
-            if (get_option('geodir_set_as_home'))
360
-                $wp->query_vars['gd_is_geodir_page'] = true;
361
-            if(geodir_is_page('home')){
362
-                $wp->query_vars['gd_is_geodir_page'] = true;
363
-            }
355
+	if (!is_admin()) {
356
+		//$wp->query_vars['gd_is_geodir_page'] = false;
357
+		//print_r()
358
+		if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
359
+			if (get_option('geodir_set_as_home'))
360
+				$wp->query_vars['gd_is_geodir_page'] = true;
361
+			if(geodir_is_page('home')){
362
+				$wp->query_vars['gd_is_geodir_page'] = true;
363
+			}
364 364
 
365 365
 
366
-        }
366
+		}
367 367
 
368
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
369
-            if (
370
-                $wp->query_vars['page_id'] == geodir_add_listing_page_id()
371
-                || $wp->query_vars['page_id'] == geodir_preview_page_id()
372
-                || $wp->query_vars['page_id'] == geodir_success_page_id()
373
-                || $wp->query_vars['page_id'] == geodir_location_page_id()
374
-                || $wp->query_vars['page_id'] == geodir_home_page_id()
375
-                || $wp->query_vars['page_id'] == geodir_info_page_id()
376
-                || $wp->query_vars['page_id'] == geodir_login_page_id()
377
-                || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
378
-                || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
379
-            )
380
-                $wp->query_vars['gd_is_geodir_page'] = true;
381
-        }
368
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
369
+			if (
370
+				$wp->query_vars['page_id'] == geodir_add_listing_page_id()
371
+				|| $wp->query_vars['page_id'] == geodir_preview_page_id()
372
+				|| $wp->query_vars['page_id'] == geodir_success_page_id()
373
+				|| $wp->query_vars['page_id'] == geodir_location_page_id()
374
+				|| $wp->query_vars['page_id'] == geodir_home_page_id()
375
+				|| $wp->query_vars['page_id'] == geodir_info_page_id()
376
+				|| $wp->query_vars['page_id'] == geodir_login_page_id()
377
+				|| (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
378
+				|| (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
379
+			)
380
+				$wp->query_vars['gd_is_geodir_page'] = true;
381
+		}
382 382
 
383
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
384
-            $page = get_page_by_path($wp->query_vars['pagename']);
385
-
386
-            if (!empty($page) && (
387
-                    $page->ID == geodir_add_listing_page_id()
388
-                    || $page->ID == geodir_preview_page_id()
389
-                    || $page->ID == geodir_success_page_id()
390
-                    || $page->ID == geodir_location_page_id()
391
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
392
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
393
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
394
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
395
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
396
-                )
397
-            )
398
-                $wp->query_vars['gd_is_geodir_page'] = true;
399
-        }
383
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
384
+			$page = get_page_by_path($wp->query_vars['pagename']);
385
+
386
+			if (!empty($page) && (
387
+					$page->ID == geodir_add_listing_page_id()
388
+					|| $page->ID == geodir_preview_page_id()
389
+					|| $page->ID == geodir_success_page_id()
390
+					|| $page->ID == geodir_location_page_id()
391
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
392
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
393
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
394
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
395
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
396
+				)
397
+			)
398
+				$wp->query_vars['gd_is_geodir_page'] = true;
399
+		}
400 400
 
401 401
 
402
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
403
-            $requested_post_type = $wp->query_vars['post_type'];
404
-            // check if this post type is geodirectory post types 
405
-            $post_type_array = geodir_get_posttypes();
406
-            if (in_array($requested_post_type, $post_type_array)) {
407
-                $wp->query_vars['gd_is_geodir_page'] = true;
408
-            }
409
-        }
402
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
403
+			$requested_post_type = $wp->query_vars['post_type'];
404
+			// check if this post type is geodirectory post types 
405
+			$post_type_array = geodir_get_posttypes();
406
+			if (in_array($requested_post_type, $post_type_array)) {
407
+				$wp->query_vars['gd_is_geodir_page'] = true;
408
+			}
409
+		}
410 410
 
411
-        if (!isset($wp->query_vars['gd_is_geodir_page'])) {
412
-            $geodir_taxonomis = geodir_get_taxonomies('', true);
413
-            foreach ($geodir_taxonomis as $taxonomy) {
414
-                if (array_key_exists($taxonomy, $wp->query_vars)) {
415
-                    $wp->query_vars['gd_is_geodir_page'] = true;
416
-                    break;
417
-                }
418
-            }
419
-        }
411
+		if (!isset($wp->query_vars['gd_is_geodir_page'])) {
412
+			$geodir_taxonomis = geodir_get_taxonomies('', true);
413
+			foreach ($geodir_taxonomis as $taxonomy) {
414
+				if (array_key_exists($taxonomy, $wp->query_vars)) {
415
+					$wp->query_vars['gd_is_geodir_page'] = true;
416
+					break;
417
+				}
418
+			}
419
+		}
420 420
 
421
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
422
-            $wp->query_vars['gd_is_geodir_page'] = true;
421
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
422
+			$wp->query_vars['gd_is_geodir_page'] = true;
423 423
 
424 424
 
425
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
426
-            $wp->query_vars['gd_is_geodir_page'] = true;
425
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
426
+			$wp->query_vars['gd_is_geodir_page'] = true;
427 427
 
428 428
 
429 429
 //check if homepage
430
-        if(!isset($wp->query_vars['gd_is_geodir_page'])
431
-            && !isset($wp->query_vars['page_id'])
432
-            && !isset($wp->query_vars['pagename'])
433
-            && is_page_geodir_home()){
434
-            $wp->query_vars['gd_is_geodir_page'] = true;
435
-        }
436
-        //echo $wp->query_vars['gd_is_geodir_page'] ;
437
-        /*echo "<pre>" ;
430
+		if(!isset($wp->query_vars['gd_is_geodir_page'])
431
+			&& !isset($wp->query_vars['page_id'])
432
+			&& !isset($wp->query_vars['pagename'])
433
+			&& is_page_geodir_home()){
434
+			$wp->query_vars['gd_is_geodir_page'] = true;
435
+		}
436
+		//echo $wp->query_vars['gd_is_geodir_page'] ;
437
+		/*echo "<pre>" ;
438 438
 		print_r($wp) ;
439 439
 		echo "</pre>" ;
440 440
 	//	exit();
441 441
 			*/
442
-    } // end of is admin
442
+	} // end of is admin
443 443
 }
444 444
 
445 445
 /**
@@ -452,56 +452,56 @@  discard block
 block discarded – undo
452 452
  */
453 453
 function geodir_is_geodir_page()
454 454
 {
455
-    global $wp;
456
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
457
-        return true;
458
-    else
459
-        return false;
455
+	global $wp;
456
+	if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
457
+		return true;
458
+	else
459
+		return false;
460 460
 }
461 461
 
462 462
 if (!function_exists('geodir_get_imagesize')) {
463
-    /**
464
-     * Get image size using the size key .
465
-     *
466
-     * @since 1.0.0
467
-     * @package GeoDirectory
468
-     * @param string $size The image size key.
469
-     * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
470
-     */
471
-    function geodir_get_imagesize($size = '')
472
-    {
473
-
474
-        $imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
475
-            'thumbnail' => array('w' => 125, 'h' => 125),
476
-            'widget-thumb' => array('w' => 50, 'h' => 50),
477
-            'slider-thumb' => array('w' => 100, 'h' => 100)
478
-        );
479
-
480
-        /**
481
-         * Filter the image sizes array.
482
-         *
483
-         * @since 1.0.0
484
-         * @param array $imagesizes Image size array.
485
-         */
486
-        $imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
487
-
488
-        if (!empty($size) && array_key_exists($size, $imagesizes)) {
489
-            /**
490
-             * Filters image size of the passed key.
491
-             *
492
-             * @since 1.0.0
493
-             * @param array $imagesizes[$size] Image size array of the passed key.
494
-             */
495
-            return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
496
-
497
-        } elseif (!empty($size)) {
498
-
499
-            return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
463
+	/**
464
+	 * Get image size using the size key .
465
+	 *
466
+	 * @since 1.0.0
467
+	 * @package GeoDirectory
468
+	 * @param string $size The image size key.
469
+	 * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
470
+	 */
471
+	function geodir_get_imagesize($size = '')
472
+	{
473
+
474
+		$imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
475
+			'thumbnail' => array('w' => 125, 'h' => 125),
476
+			'widget-thumb' => array('w' => 50, 'h' => 50),
477
+			'slider-thumb' => array('w' => 100, 'h' => 100)
478
+		);
479
+
480
+		/**
481
+		 * Filter the image sizes array.
482
+		 *
483
+		 * @since 1.0.0
484
+		 * @param array $imagesizes Image size array.
485
+		 */
486
+		$imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
487
+
488
+		if (!empty($size) && array_key_exists($size, $imagesizes)) {
489
+			/**
490
+			 * Filters image size of the passed key.
491
+			 *
492
+			 * @since 1.0.0
493
+			 * @param array $imagesizes[$size] Image size array of the passed key.
494
+			 */
495
+			return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
496
+
497
+		} elseif (!empty($size)) {
498
+
499
+			return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
500 500
 
501
-        }
501
+		}
502 502
 
503
-        return $imagesizes;
504
-    }
503
+		return $imagesizes;
504
+	}
505 505
 }
506 506
 
507 507
 /**
@@ -521,148 +521,148 @@  discard block
 block discarded – undo
521 521
 
522 522
 
523 523
 if (!function_exists('createRandomString')) {
524
-    /**
525
-     * Creates random string.
526
-     *
527
-     * @since 1.0.0
528
-     * @package GeoDirectory
529
-     * @return string Random string.
530
-     */
531
-    function createRandomString()
532
-    {
533
-        $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
534
-        srand((double)microtime() * 1000000);
535
-        $i = 0;
536
-        $rstring = '';
537
-        while ($i <= 25) {
538
-            $num = rand() % 33;
539
-            $tmp = substr($chars, $num, 1);
540
-            $rstring = $rstring . $tmp;
541
-            $i++;
542
-        }
543
-        return $rstring;
544
-    }
524
+	/**
525
+	 * Creates random string.
526
+	 *
527
+	 * @since 1.0.0
528
+	 * @package GeoDirectory
529
+	 * @return string Random string.
530
+	 */
531
+	function createRandomString()
532
+	{
533
+		$chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
534
+		srand((double)microtime() * 1000000);
535
+		$i = 0;
536
+		$rstring = '';
537
+		while ($i <= 25) {
538
+			$num = rand() % 33;
539
+			$tmp = substr($chars, $num, 1);
540
+			$rstring = $rstring . $tmp;
541
+			$i++;
542
+		}
543
+		return $rstring;
544
+	}
545 545
 }
546 546
 
547 547
 if (!function_exists('geodir_getDistanceRadius')) {
548
-    /**
549
-     * Calculates the distance radius.
550
-     *
551
-     * @since 1.0.0
552
-     * @package GeoDirectory
553
-     * @param string $uom Measurement unit type.
554
-     * @return float The mean radius.
555
-     */
556
-    function geodir_getDistanceRadius($uom = 'km')
557
-    {
548
+	/**
549
+	 * Calculates the distance radius.
550
+	 *
551
+	 * @since 1.0.0
552
+	 * @package GeoDirectory
553
+	 * @param string $uom Measurement unit type.
554
+	 * @return float The mean radius.
555
+	 */
556
+	function geodir_getDistanceRadius($uom = 'km')
557
+	{
558 558
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
559
-        switch (geodir_strtolower($uom)):
560
-            case 'km'    :
561
-                $earthMeanRadius = 6371.009; // km
562
-                break;
563
-            case 'm'    :
564
-            case 'meters'    :
565
-                $earthMeanRadius = 6371.009 * 1000; // km
566
-                break;
567
-            case 'miles'    :
568
-                $earthMeanRadius = 3958.761; // miles
569
-                break;
570
-            case 'yards'    :
571
-            case 'yds'    :
572
-                $earthMeanRadius = 3958.761 * 1760; // yards
573
-                break;
574
-            case 'feet'    :
575
-            case 'ft'    :
576
-                $earthMeanRadius = 3958.761 * 1760 * 3; // feet
577
-                break;
578
-            case 'nm'    :
579
-                $earthMeanRadius = 3440.069; //  miles
580
-                break;
581
-            default:
582
-                $earthMeanRadius = 3958.761; // miles
583
-                break;
584
-        endswitch;
585
-        return $earthMeanRadius;
586
-    }
559
+		switch (geodir_strtolower($uom)):
560
+			case 'km'    :
561
+				$earthMeanRadius = 6371.009; // km
562
+				break;
563
+			case 'm'    :
564
+			case 'meters'    :
565
+				$earthMeanRadius = 6371.009 * 1000; // km
566
+				break;
567
+			case 'miles'    :
568
+				$earthMeanRadius = 3958.761; // miles
569
+				break;
570
+			case 'yards'    :
571
+			case 'yds'    :
572
+				$earthMeanRadius = 3958.761 * 1760; // yards
573
+				break;
574
+			case 'feet'    :
575
+			case 'ft'    :
576
+				$earthMeanRadius = 3958.761 * 1760 * 3; // feet
577
+				break;
578
+			case 'nm'    :
579
+				$earthMeanRadius = 3440.069; //  miles
580
+				break;
581
+			default:
582
+				$earthMeanRadius = 3958.761; // miles
583
+				break;
584
+		endswitch;
585
+		return $earthMeanRadius;
586
+	}
587 587
 }
588 588
 
589 589
 
590 590
 if (!function_exists('geodir_calculateDistanceFromLatLong')) {
591
-    /**
592
-     * Calculate the great circle distance between two points identified by longitude and latitude.
593
-     *
594
-     * @since 1.0.0
595
-     * @package GeoDirectory
596
-     * @param array $point1 Latitude and Longitude of point 1.
597
-     * @param array $point2 Latitude and Longitude of point 2.
598
-     * @param string $uom Unit of measurement.
599
-     * @return float The distance.
600
-     */
601
-    function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
602
-    {
591
+	/**
592
+	 * Calculate the great circle distance between two points identified by longitude and latitude.
593
+	 *
594
+	 * @since 1.0.0
595
+	 * @package GeoDirectory
596
+	 * @param array $point1 Latitude and Longitude of point 1.
597
+	 * @param array $point2 Latitude and Longitude of point 2.
598
+	 * @param string $uom Unit of measurement.
599
+	 * @return float The distance.
600
+	 */
601
+	function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
602
+	{
603 603
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
604 604
 
605
-        $earthMeanRadius = geodir_getDistanceRadius($uom);
605
+		$earthMeanRadius = geodir_getDistanceRadius($uom);
606 606
 
607
-        $deltaLatitude = deg2rad($point2['latitude'] - $point1['latitude']);
608
-        $deltaLongitude = deg2rad($point2['longitude'] - $point1['longitude']);
609
-        $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
610
-            cos(deg2rad($point1['latitude'])) * cos(deg2rad($point2['latitude'])) *
611
-            sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
612
-        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
613
-        $distance = $earthMeanRadius * $c;
614
-        return $distance;
607
+		$deltaLatitude = deg2rad($point2['latitude'] - $point1['latitude']);
608
+		$deltaLongitude = deg2rad($point2['longitude'] - $point1['longitude']);
609
+		$a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
610
+			cos(deg2rad($point1['latitude'])) * cos(deg2rad($point2['latitude'])) *
611
+			sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
612
+		$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
613
+		$distance = $earthMeanRadius * $c;
614
+		return $distance;
615 615
 
616
-    }
616
+	}
617 617
 }
618 618
 
619 619
 
620 620
 if (!function_exists('geodir_sendEmail')) {
621
-    /**
622
-     * The main function that send transactional emails using the args provided.
623
-     *
624
-     * @since 1.0.0
625
-     * @since 1.5.7 Added db translations for notifications subject and content.
626
-     * @package GeoDirectory
627
-     * @param string $fromEmail Sender email address.
628
-     * @param string $fromEmailName Sender name.
629
-     * @param string $toEmail Receiver email address.
630
-     * @param string $toEmailName Receiver name.
631
-     * @param string $to_subject Email subject.
632
-     * @param string $to_message Email content.
633
-     * @param string $extra Not being used.
634
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
635
-     * @param string $post_id The post ID.
636
-     * @param string $user_id The user ID.
637
-     */
638
-    function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
639
-        $login_details = '';
640
-
641
-        // strip slashes from subject & message text
642
-        $to_subject = stripslashes_deep($to_subject);
643
-        $to_message = stripslashes_deep($to_message);
644
-
645
-        if ($message_type == 'send_friend') {
646
-            $subject = get_option('geodir_email_friend_subject');
647
-            $message = get_option('geodir_email_friend_content');
648
-        } elseif ($message_type == 'send_enquiry') {
649
-            $subject = get_option('geodir_email_enquiry_subject');
650
-            $message = get_option('geodir_email_enquiry_content');
651
-        } elseif ($message_type == 'forgot_password') {
652
-            $subject = get_option('geodir_forgot_password_subject');
653
-            $message = get_option('geodir_forgot_password_content');
654
-            $login_details = $to_message;
655
-        } elseif ($message_type == 'registration') {
656
-            $subject = get_option('geodir_registration_success_email_subject');
657
-            $message = get_option('geodir_registration_success_email_content');
658
-            $login_details = $to_message;
659
-        } elseif ($message_type == 'post_submit') {
660
-            $subject = get_option('geodir_post_submited_success_email_subject');
661
-            $message = get_option('geodir_post_submited_success_email_content');
662
-        } elseif ($message_type == 'listing_published') {
663
-            $subject = get_option('geodir_post_published_email_subject');
664
-            $message = get_option('geodir_post_published_email_content');
665
-        }
621
+	/**
622
+	 * The main function that send transactional emails using the args provided.
623
+	 *
624
+	 * @since 1.0.0
625
+	 * @since 1.5.7 Added db translations for notifications subject and content.
626
+	 * @package GeoDirectory
627
+	 * @param string $fromEmail Sender email address.
628
+	 * @param string $fromEmailName Sender name.
629
+	 * @param string $toEmail Receiver email address.
630
+	 * @param string $toEmailName Receiver name.
631
+	 * @param string $to_subject Email subject.
632
+	 * @param string $to_message Email content.
633
+	 * @param string $extra Not being used.
634
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
635
+	 * @param string $post_id The post ID.
636
+	 * @param string $user_id The user ID.
637
+	 */
638
+	function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
639
+		$login_details = '';
640
+
641
+		// strip slashes from subject & message text
642
+		$to_subject = stripslashes_deep($to_subject);
643
+		$to_message = stripslashes_deep($to_message);
644
+
645
+		if ($message_type == 'send_friend') {
646
+			$subject = get_option('geodir_email_friend_subject');
647
+			$message = get_option('geodir_email_friend_content');
648
+		} elseif ($message_type == 'send_enquiry') {
649
+			$subject = get_option('geodir_email_enquiry_subject');
650
+			$message = get_option('geodir_email_enquiry_content');
651
+		} elseif ($message_type == 'forgot_password') {
652
+			$subject = get_option('geodir_forgot_password_subject');
653
+			$message = get_option('geodir_forgot_password_content');
654
+			$login_details = $to_message;
655
+		} elseif ($message_type == 'registration') {
656
+			$subject = get_option('geodir_registration_success_email_subject');
657
+			$message = get_option('geodir_registration_success_email_content');
658
+			$login_details = $to_message;
659
+		} elseif ($message_type == 'post_submit') {
660
+			$subject = get_option('geodir_post_submited_success_email_subject');
661
+			$message = get_option('geodir_post_submited_success_email_content');
662
+		} elseif ($message_type == 'listing_published') {
663
+			$subject = get_option('geodir_post_published_email_subject');
664
+			$message = get_option('geodir_post_published_email_content');
665
+		}
666 666
 		
667 667
 		if (!empty($subject)) {
668 668
 			$subject = __(stripslashes_deep($subject),'geodirectory');
@@ -672,125 +672,125 @@  discard block
 block discarded – undo
672 672
 			$message = __(stripslashes_deep($message),'geodirectory');
673 673
 		}
674 674
 
675
-        $to_message = nl2br($to_message);
676
-        $sitefromEmail = get_option('site_email');
677
-        $sitefromEmailName = get_site_emailName();
678
-        $productlink = get_permalink($post_id);
675
+		$to_message = nl2br($to_message);
676
+		$sitefromEmail = get_option('site_email');
677
+		$sitefromEmailName = get_site_emailName();
678
+		$productlink = get_permalink($post_id);
679 679
 
680
-        $user_login = '';
681
-        if ($user_id > 0 && $user_info = get_userdata($user_id)) {
682
-            $user_login = $user_info->user_login;
683
-        }
680
+		$user_login = '';
681
+		if ($user_id > 0 && $user_info = get_userdata($user_id)) {
682
+			$user_login = $user_info->user_login;
683
+		}
684 684
 
685
-        $posted_date = '';
686
-        $listingLink = '';
685
+		$posted_date = '';
686
+		$listingLink = '';
687 687
 
688
-        $post_info = get_post($post_id);
688
+		$post_info = get_post($post_id);
689 689
 
690
-        if ($post_info) {
691
-            $posted_date = $post_info->post_date;
692
-            $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
693
-        }
694
-        $siteurl = home_url();
695
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
696
-        $loginurl = geodir_login_url();
697
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
690
+		if ($post_info) {
691
+			$posted_date = $post_info->post_date;
692
+			$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
693
+		}
694
+		$siteurl = home_url();
695
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
696
+		$loginurl = geodir_login_url();
697
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
698 698
 
699
-        if ($fromEmail == '') {
700
-            $fromEmail = get_option('site_email');
701
-        }
699
+		if ($fromEmail == '') {
700
+			$fromEmail = get_option('site_email');
701
+		}
702 702
 
703
-        if ($fromEmailName == '') {
704
-            $fromEmailName = get_option('site_email_name');
705
-        }
703
+		if ($fromEmailName == '') {
704
+			$fromEmailName = get_option('site_email_name');
705
+		}
706 706
 
707
-        $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#]');
708
-        $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);
709
-        $message = str_replace($search_array, $replace_array, $message);
710
-
711
-        $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#]');
712
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login);
713
-        $subject = str_replace($search_array, $replace_array, $subject);
714
-
715
-        $headers = 'MIME-Version: 1.0' . "\r\n";
716
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
717
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
718
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
719
-
720
-        $to = $toEmail;
721
-        $sent = wp_mail($to, $subject, $message, $headers);
722
-
723
-        if( ! $sent ) {
724
-            if ( is_array( $to ) ) {
725
-                $to = implode( ',', $to );
726
-            }
727
-            $log_message = sprintf(
728
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
729
-                $message_type,
730
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
731
-                $to,
732
-                $subject
733
-            );
734
-            geodir_error_log( $log_message );
735
-        }
707
+		$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#]');
708
+		$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);
709
+		$message = str_replace($search_array, $replace_array, $message);
736 710
 
737
-        ///////// ADMIN BCC EMIALS
738
-        $adminEmail = get_bloginfo('admin_email');
739
-        $to = $adminEmail;
711
+		$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#]');
712
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login);
713
+		$subject = str_replace($search_array, $replace_array, $subject);
740 714
 
741
-        $admin_bcc = false;
742
-        if ($message_type == 'post_submit') {
743
-            $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
744
-            $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
715
+		$headers = 'MIME-Version: 1.0' . "\r\n";
716
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
717
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
718
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
745 719
 
746
-            $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#]');
747
-            $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);
748
-            $message = str_replace($search_array, $replace_array, $message);
720
+		$to = $toEmail;
721
+		$sent = wp_mail($to, $subject, $message, $headers);
749 722
 
750
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
751
-            $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
752
-            $subject = str_replace($search_array, $replace_array, $subject);
723
+		if( ! $sent ) {
724
+			if ( is_array( $to ) ) {
725
+				$to = implode( ',', $to );
726
+			}
727
+			$log_message = sprintf(
728
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
729
+				$message_type,
730
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
731
+				$to,
732
+				$subject
733
+			);
734
+			geodir_error_log( $log_message );
735
+		}
753 736
 
754
-            $subject .= ' - ADMIN BCC COPY';
755
-            $admin_bcc = true;
737
+		///////// ADMIN BCC EMIALS
738
+		$adminEmail = get_bloginfo('admin_email');
739
+		$to = $adminEmail;
756 740
 
757
-        }
758
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
759
-            $subject .= ' - ADMIN BCC COPY';
760
-            $admin_bcc = true;
761
-        }
762
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
763
-            $subject .= ' - ADMIN BCC COPY';
764
-            $admin_bcc = true;
765
-        }
766
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
767
-            $subject .= ' - ADMIN BCC COPY';
768
-            $admin_bcc = true;
769
-        }
770
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
771
-            $subject .= ' - ADMIN BCC COPY';
772
-            $admin_bcc = true;
773
-        }
741
+		$admin_bcc = false;
742
+		if ($message_type == 'post_submit') {
743
+			$subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
744
+			$message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
774 745
 
775
-        if($admin_bcc===true){
776
-            $sent = wp_mail($to, $subject, $message, $headers);
777
-
778
-            if( ! $sent ) {
779
-                if ( is_array( $to ) ) {
780
-                    $to = implode( ',', $to );
781
-                }
782
-                $log_message = sprintf(
783
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
784
-                    $message_type,
785
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
786
-                    $to,
787
-                    $subject
788
-                );
789
-                geodir_error_log( $log_message );
790
-            }
791
-        }
746
+			$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#]');
747
+			$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);
748
+			$message = str_replace($search_array, $replace_array, $message);
749
+
750
+			$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
751
+			$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
752
+			$subject = str_replace($search_array, $replace_array, $subject);
753
+
754
+			$subject .= ' - ADMIN BCC COPY';
755
+			$admin_bcc = true;
756
+
757
+		}
758
+		elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
759
+			$subject .= ' - ADMIN BCC COPY';
760
+			$admin_bcc = true;
761
+		}
762
+		elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
763
+			$subject .= ' - ADMIN BCC COPY';
764
+			$admin_bcc = true;
765
+		}
766
+		elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
767
+			$subject .= ' - ADMIN BCC COPY';
768
+			$admin_bcc = true;
769
+		}
770
+		elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
771
+			$subject .= ' - ADMIN BCC COPY';
772
+			$admin_bcc = true;
773
+		}
774
+
775
+		if($admin_bcc===true){
776
+			$sent = wp_mail($to, $subject, $message, $headers);
777
+
778
+			if( ! $sent ) {
779
+				if ( is_array( $to ) ) {
780
+					$to = implode( ',', $to );
781
+				}
782
+				$log_message = sprintf(
783
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
784
+					$message_type,
785
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
786
+					$to,
787
+					$subject
788
+				);
789
+				geodir_error_log( $log_message );
790
+			}
791
+		}
792 792
 
793
-    }
793
+	}
794 794
 }
795 795
 
796 796
 
@@ -803,27 +803,27 @@  discard block
 block discarded – undo
803 803
 function geodir_taxonomy_breadcrumb()
804 804
 {
805 805
 
806
-    $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
807
-    $parent = $term->parent;
806
+	$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
807
+	$parent = $term->parent;
808 808
 
809
-    while ($parent):
810
-        $parents[] = $parent;
811
-        $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
812
-        $parent = $new_parent->parent;
813
-    endwhile;
809
+	while ($parent):
810
+		$parents[] = $parent;
811
+		$new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
812
+		$parent = $new_parent->parent;
813
+	endwhile;
814 814
 
815
-    if (!empty($parents)):
816
-        $parents = array_reverse($parents);
815
+	if (!empty($parents)):
816
+		$parents = array_reverse($parents);
817 817
 
818
-        foreach ($parents as $parent):
819
-            $item = get_term_by('id', $parent, get_query_var('taxonomy'));
820
-            $url = get_term_link($item, get_query_var('taxonomy'));
821
-            echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
822
-        endforeach;
818
+		foreach ($parents as $parent):
819
+			$item = get_term_by('id', $parent, get_query_var('taxonomy'));
820
+			$url = get_term_link($item, get_query_var('taxonomy'));
821
+			echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
822
+		endforeach;
823 823
 
824
-    endif;
824
+	endif;
825 825
 
826
-    echo '<li> > ' . $term->name . '</li>';
826
+	echo '<li> > ' . $term->name . '</li>';
827 827
 }
828 828
 
829 829
 
@@ -839,365 +839,365 @@  discard block
 block discarded – undo
839 839
  */
840 840
 function geodir_breadcrumb()
841 841
 {
842
-    global $wp_query, $geodir_add_location_url;
843
-
844
-    /**
845
-     * Filter breadcrumb separator.
846
-     *
847
-     * @since 1.0.0
848
-     */
849
-    $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
850
-
851
-    if (!geodir_is_page('home')) {
852
-        $breadcrumb = '';
853
-        $url_categoris = '';
854
-        $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
855
-        /**
856
-         * Filter breadcrumb's first link.
857
-         *
858
-         * @since 1.0.0
859
-         */
860
-        $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
842
+	global $wp_query, $geodir_add_location_url;
843
+
844
+	/**
845
+	 * Filter breadcrumb separator.
846
+	 *
847
+	 * @since 1.0.0
848
+	 */
849
+	$separator = apply_filters('geodir_breadcrumb_separator', ' > ');
850
+
851
+	if (!geodir_is_page('home')) {
852
+		$breadcrumb = '';
853
+		$url_categoris = '';
854
+		$breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
855
+		/**
856
+		 * Filter breadcrumb's first link.
857
+		 *
858
+		 * @since 1.0.0
859
+		 */
860
+		$breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
861
+
862
+		$gd_post_type = geodir_get_current_posttype();
863
+		$post_type_info = get_post_type_object($gd_post_type);
864
+
865
+		remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
866
+
867
+		$listing_link = get_post_type_archive_link($gd_post_type);
868
+
869
+		add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
870
+		$listing_link = rtrim($listing_link, '/');
871
+		$listing_link .= '/';
872
+
873
+		$post_type_for_location_link = $listing_link;
874
+		$location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
875
+
876
+		global $wp, $gd_session;
877
+		$location_link = $post_type_for_location_link;
878
+
879
+		if (geodir_is_page('detail') || geodir_is_page('listing')) {
880
+			global $post;
881
+			$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
882
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
883
+				
884
+			if(geodir_is_page('detail') && isset($post->country_slug)){
885
+				$location_terms = array(
886
+					'gd_country' => $post->country_slug,
887
+					'gd_region' => $post->region_slug,
888
+					'gd_city' => $post->city_slug
889
+				);
890
+				
891
+				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
892
+					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
893
+				}
894
+			}
861 895
 
862
-        $gd_post_type = geodir_get_current_posttype();
863
-        $post_type_info = get_post_type_object($gd_post_type);
896
+			$geodir_show_location_url = get_option('geodir_show_location_url');
864 897
 
865
-        remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
898
+			$hide_url_part = array();
899
+			if ($location_manager) {
900
+				$hide_country_part = get_option('geodir_location_hide_country_part');
901
+				$hide_region_part = get_option('geodir_location_hide_region_part');
866 902
 
867
-        $listing_link = get_post_type_archive_link($gd_post_type);
903
+				if ($hide_region_part && $hide_country_part) {
904
+					$hide_url_part = array('gd_country', 'gd_region');
905
+				} else if ($hide_region_part && !$hide_country_part) {
906
+					$hide_url_part = array('gd_region');
907
+				} else if (!$hide_region_part && $hide_country_part) {
908
+					$hide_url_part = array('gd_country');
909
+				}
910
+			}
868 911
 
869
-        add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
870
-        $listing_link = rtrim($listing_link, '/');
871
-        $listing_link .= '/';
912
+			$hide_text_part = array();
913
+			if ($geodir_show_location_url == 'country_city') {
914
+				$hide_text_part = array('gd_region');
872 915
 
873
-        $post_type_for_location_link = $listing_link;
874
-        $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
916
+				if (isset($location_terms['gd_region']) && !$location_manager) {
917
+					unset($location_terms['gd_region']);
918
+				}
919
+			} else if ($geodir_show_location_url == 'region_city') {
920
+				$hide_text_part = array('gd_country');
875 921
 
876
-        global $wp, $gd_session;
877
-        $location_link = $post_type_for_location_link;
922
+				if (isset($location_terms['gd_country']) && !$location_manager) {
923
+					unset($location_terms['gd_country']);
924
+				}
925
+			} else if ($geodir_show_location_url == 'city') {
926
+				$hide_text_part = array('gd_country', 'gd_region');
878 927
 
879
-        if (geodir_is_page('detail') || geodir_is_page('listing')) {
880
-            global $post;
881
-            $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
882
-			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
883
-				
884
-			if(geodir_is_page('detail') && isset($post->country_slug)){
885
-                $location_terms = array(
886
-                    'gd_country' => $post->country_slug,
887
-                    'gd_region' => $post->region_slug,
888
-                    'gd_city' => $post->city_slug
889
-                );
890
-				
891
-				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
892
-					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
928
+				if (isset($location_terms['gd_country']) && !$location_manager) {
929
+					unset($location_terms['gd_country']);
893 930
 				}
894
-            }
895
-
896
-            $geodir_show_location_url = get_option('geodir_show_location_url');
897
-
898
-            $hide_url_part = array();
899
-            if ($location_manager) {
900
-                $hide_country_part = get_option('geodir_location_hide_country_part');
901
-                $hide_region_part = get_option('geodir_location_hide_region_part');
902
-
903
-                if ($hide_region_part && $hide_country_part) {
904
-                    $hide_url_part = array('gd_country', 'gd_region');
905
-                } else if ($hide_region_part && !$hide_country_part) {
906
-                    $hide_url_part = array('gd_region');
907
-                } else if (!$hide_region_part && $hide_country_part) {
908
-                    $hide_url_part = array('gd_country');
909
-                }
910
-            }
911
-
912
-            $hide_text_part = array();
913
-            if ($geodir_show_location_url == 'country_city') {
914
-                $hide_text_part = array('gd_region');
915
-
916
-                if (isset($location_terms['gd_region']) && !$location_manager) {
917
-                    unset($location_terms['gd_region']);
918
-                }
919
-            } else if ($geodir_show_location_url == 'region_city') {
920
-                $hide_text_part = array('gd_country');
921
-
922
-                if (isset($location_terms['gd_country']) && !$location_manager) {
923
-                    unset($location_terms['gd_country']);
924
-                }
925
-            } else if ($geodir_show_location_url == 'city') {
926
-                $hide_text_part = array('gd_country', 'gd_region');
927
-
928
-                if (isset($location_terms['gd_country']) && !$location_manager) {
929
-                    unset($location_terms['gd_country']);
930
-                }
931
-                if (isset($location_terms['gd_region']) && !$location_manager) {
932
-                    unset($location_terms['gd_region']);
933
-                }
934
-            }
935
-
936
-            $is_location_last = '';
937
-            $is_taxonomy_last = '';
938
-            $breadcrumb .= '<li>';
939
-            if (get_query_var($gd_post_type . 'category'))
940
-                $gd_taxonomy = $gd_post_type . 'category';
941
-            elseif (get_query_var($gd_post_type . '_tags'))
942
-                $gd_taxonomy = $gd_post_type . '_tags';
943
-
944
-            $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
945
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
946
-                $is_location_last = false;
947
-            else
948
-                $is_location_last = true;
949
-
950
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
951
-                $is_taxonomy_last = true;
952
-            else
953
-                $is_taxonomy_last = false;
954
-
955
-            if (!empty($location_terms)) {
956
-                $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
957
-
958
-                foreach ($location_terms as $key => $location_term) {
959
-                    if ($location_term != '') {
960
-                        if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
961
-                            continue;
962
-                        }
963
-
964
-                        $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
965
-                        $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
966
-                        $gd_location_link_text = ucfirst($gd_location_link_text);
967
-
968
-                        $location_term_actual_country = '';
969
-                        $location_term_actual_region = '';
970
-                        $location_term_actual_city = '';
971
-                        if ($geodir_get_locations) {
972
-                            if ($key == 'gd_country') {
973
-                                $location_term_actual_country = get_actual_location_name('country', $location_term, true);
974
-                            } else if ($key == 'gd_region') {
975
-                                $location_term_actual_region = get_actual_location_name('region', $location_term, true);
976
-                            } else if ($key == 'gd_city') {
977
-                                $location_term_actual_city = get_actual_location_name('city', $location_term, true);
978
-                            }
979
-                        } else {
980
-                            $location_info = geodir_get_location();
981
-
982
-                            if (!empty($location_info) && isset($location_info->location_id)) {
983
-                                if ($key == 'gd_country') {
984
-                                    $location_term_actual_country = __($location_info->country, 'geodirectory');
985
-                                } else if ($key == 'gd_region') {
986
-                                    $location_term_actual_region = __($location_info->region, 'geodirectory');
987
-                                } else if ($key == 'gd_city') {
988
-                                    $location_term_actual_city = __($location_info->city, 'geodirectory');
989
-                                }
990
-                            }
991
-                        }
992
-
993
-                        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'] != '')) {
994
-                            $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
995
-                        } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
996
-                            $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
997
-                        } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
998
-                            $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
999
-                        } else if ($is_location_last && $key == 'gd_neighbourhood') {
1000
-                            $breadcrumb .= $separator . $gd_location_link_text;
1001
-                        } else {
1002
-                            if (get_option('permalink_structure') != '') {
1003
-                                $location_link .= $location_term . '/';
1004
-                            } else {
1005
-                                $location_link .= "&$key=" . $location_term;
1006
-                            }
931
+				if (isset($location_terms['gd_region']) && !$location_manager) {
932
+					unset($location_terms['gd_region']);
933
+				}
934
+			}
1007 935
 
1008
-                            if ($key == 'gd_country' && $location_term_actual_country != '') {
1009
-                                $gd_location_link_text = $location_term_actual_country;
1010
-                            } else if ($key == 'gd_region' && $location_term_actual_region != '') {
1011
-                                $gd_location_link_text = $location_term_actual_region;
1012
-                            } else if ($key == 'gd_city' && $location_term_actual_city != '') {
1013
-                                $gd_location_link_text = $location_term_actual_city;
1014
-                            }
936
+			$is_location_last = '';
937
+			$is_taxonomy_last = '';
938
+			$breadcrumb .= '<li>';
939
+			if (get_query_var($gd_post_type . 'category'))
940
+				$gd_taxonomy = $gd_post_type . 'category';
941
+			elseif (get_query_var($gd_post_type . '_tags'))
942
+				$gd_taxonomy = $gd_post_type . '_tags';
943
+
944
+			$breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
945
+			if (!empty($gd_taxonomy) || geodir_is_page('detail'))
946
+				$is_location_last = false;
947
+			else
948
+				$is_location_last = true;
949
+
950
+			if (!empty($gd_taxonomy) && geodir_is_page('listing'))
951
+				$is_taxonomy_last = true;
952
+			else
953
+				$is_taxonomy_last = false;
954
+
955
+			if (!empty($location_terms)) {
956
+				$geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
957
+
958
+				foreach ($location_terms as $key => $location_term) {
959
+					if ($location_term != '') {
960
+						if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
961
+							continue;
962
+						}
963
+
964
+						$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
965
+						$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
966
+						$gd_location_link_text = ucfirst($gd_location_link_text);
967
+
968
+						$location_term_actual_country = '';
969
+						$location_term_actual_region = '';
970
+						$location_term_actual_city = '';
971
+						if ($geodir_get_locations) {
972
+							if ($key == 'gd_country') {
973
+								$location_term_actual_country = get_actual_location_name('country', $location_term, true);
974
+							} else if ($key == 'gd_region') {
975
+								$location_term_actual_region = get_actual_location_name('region', $location_term, true);
976
+							} else if ($key == 'gd_city') {
977
+								$location_term_actual_city = get_actual_location_name('city', $location_term, true);
978
+							}
979
+						} else {
980
+							$location_info = geodir_get_location();
981
+
982
+							if (!empty($location_info) && isset($location_info->location_id)) {
983
+								if ($key == 'gd_country') {
984
+									$location_term_actual_country = __($location_info->country, 'geodirectory');
985
+								} else if ($key == 'gd_region') {
986
+									$location_term_actual_region = __($location_info->region, 'geodirectory');
987
+								} else if ($key == 'gd_city') {
988
+									$location_term_actual_city = __($location_info->city, 'geodirectory');
989
+								}
990
+							}
991
+						}
1015 992
 
1016
-                            /*
993
+						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'] != '')) {
994
+							$breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
995
+						} else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
996
+							$breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
997
+						} else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
998
+							$breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
999
+						} else if ($is_location_last && $key == 'gd_neighbourhood') {
1000
+							$breadcrumb .= $separator . $gd_location_link_text;
1001
+						} else {
1002
+							if (get_option('permalink_structure') != '') {
1003
+								$location_link .= $location_term . '/';
1004
+							} else {
1005
+								$location_link .= "&$key=" . $location_term;
1006
+							}
1007
+
1008
+							if ($key == 'gd_country' && $location_term_actual_country != '') {
1009
+								$gd_location_link_text = $location_term_actual_country;
1010
+							} else if ($key == 'gd_region' && $location_term_actual_region != '') {
1011
+								$gd_location_link_text = $location_term_actual_region;
1012
+							} else if ($key == 'gd_city' && $location_term_actual_city != '') {
1013
+								$gd_location_link_text = $location_term_actual_city;
1014
+							}
1015
+
1016
+							/*
1017 1017
                             if (geodir_is_page('detail') && !empty($hide_text_part) && in_array($key, $hide_text_part)) {
1018 1018
                                 continue;
1019 1019
                             }
1020 1020
                             */
1021 1021
 
1022
-                            $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1023
-                        }
1024
-                    }
1025
-                }
1026
-            }
1027
-
1028
-            if (!empty($gd_taxonomy)) {
1029
-                $term_index = 1;
1030
-
1031
-                //if(get_option('geodir_add_categories_url'))
1032
-                {
1033
-                    if (get_query_var($gd_post_type . '_tags')) {
1034
-                        $cat_link = $listing_link . 'tags/';
1035
-                    } else
1036
-                        $cat_link = $listing_link;
1037
-
1038
-                    foreach ($location_terms as $key => $location_term) {
1039
-                        if ($location_manager && in_array($key, $hide_url_part)) {
1040
-                            continue;
1041
-                        }
1042
-
1043
-                        if ($location_term != '') {
1044
-                            if (get_option('permalink_structure') != '') {
1045
-                                $cat_link .= $location_term . '/';
1046
-                            }
1047
-                        }
1048
-                    }
1049
-
1050
-                    $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1051
-                    foreach ($term_array as $term) {
1052
-                        $term_link_text = preg_replace('/-(\d+)$/', '', $term);
1053
-                        $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1054
-
1055
-                        // get term actual name
1056
-                        $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1057
-                        if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1058
-                            $term_link_text = urldecode($term_info['name']);
1059
-                        } else {
1060
-                            $term_link_text = geodir_ucwords(urldecode($term_link_text));
1061
-                        }
1062
-
1063
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1064
-                            $breadcrumb .= $separator . $term_link_text;
1065
-                        else {
1066
-                            $cat_link .= $term . '/';
1067
-                            $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1068
-                        }
1069
-                        $term_index++;
1070
-                    }
1071
-                }
1072
-
1073
-
1074
-            }
1075
-
1076
-            if (geodir_is_page('detail'))
1077
-                $breadcrumb .= $separator . get_the_title();
1078
-
1079
-            $breadcrumb .= '</li>';
1080
-
1081
-
1082
-        } elseif (geodir_is_page('author')) {
1083
-            $user_id = get_current_user_id();
1084
-            $author_link = get_author_posts_url($user_id);
1085
-            $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1086
-
1087
-            /**
1088
-             * Filter author page link.
1089
-             *
1090
-             * @since 1.0.0
1091
-             * @param string $default_author_link Default author link.
1092
-             * @param int $user_id Author ID.
1093
-             */
1094
-            $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1095
-
1096
-            $breadcrumb .= '<li>';
1097
-            $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1098
-
1099
-            if (isset($_REQUEST['list'])) {
1100
-                $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1101
-
1102
-                /**
1103
-                 * Filter author page link.
1104
-                 *
1105
-                 * @since 1.0.0
1106
-                 * @param string $author_link Author page link.
1107
-                 * @param int $user_id Author ID.
1108
-                 * @param string $_REQUEST['stype'] Post type.
1109
-                 */
1110
-                $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1111
-
1112
-                $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1113
-                $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1114
-            } else
1115
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1116
-
1117
-            $breadcrumb .= '</li>';
1118
-        } elseif (is_category() || is_single()) {
1119
-            $category = get_the_category();
1120
-            if (is_category()) {
1121
-                $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1122
-            }
1123
-            if (is_single()) {
1124
-                $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1125
-                $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1126
-            }
1127
-            /* End of my version ##################################################### */
1128
-        } else if (is_page()) {
1129
-            $page_title = get_the_title();
1130
-
1131
-            if (geodir_is_page('location')) {
1132
-                $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1133
-            }
1134
-
1135
-            $breadcrumb .= '<li>' . $separator;
1136
-            $breadcrumb .= stripslashes_deep($page_title);
1137
-            $breadcrumb .= '</li>';
1138
-        } else if (is_tag()) {
1139
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1140
-        } else if (is_day()) {
1141
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1142
-            the_time('F jS, Y');
1143
-            $breadcrumb .= '</li>';
1144
-        } else if (is_month()) {
1145
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1146
-            the_time('F, Y');
1147
-            $breadcrumb .= '</li>';
1148
-        } else if (is_year()) {
1149
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1150
-            the_time('Y');
1151
-            $breadcrumb .= '</li>';
1152
-        } else if (is_author()) {
1153
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1154
-            $breadcrumb .= '</li>';
1155
-        } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1156
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1157
-            $breadcrumb .= '</li>';
1158
-        } else if (is_search()) {
1159
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1160
-            $breadcrumb .= '</li>';
1161
-        }
1162
-        $breadcrumb .= '</ul></div>';
1163
-
1164
-        /**
1165
-         * Filter breadcrumb html output.
1166
-         *
1167
-         * @since 1.0.0
1168
-         * @param string $breadcrumb Breadcrumb HTML.
1169
-         * @param string $separator Breadcrumb separator.
1170
-         */
1171
-        echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1172
-    }
1022
+							$breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1023
+						}
1024
+					}
1025
+				}
1026
+			}
1027
+
1028
+			if (!empty($gd_taxonomy)) {
1029
+				$term_index = 1;
1030
+
1031
+				//if(get_option('geodir_add_categories_url'))
1032
+				{
1033
+					if (get_query_var($gd_post_type . '_tags')) {
1034
+						$cat_link = $listing_link . 'tags/';
1035
+					} else
1036
+						$cat_link = $listing_link;
1037
+
1038
+					foreach ($location_terms as $key => $location_term) {
1039
+						if ($location_manager && in_array($key, $hide_url_part)) {
1040
+							continue;
1041
+						}
1042
+
1043
+						if ($location_term != '') {
1044
+							if (get_option('permalink_structure') != '') {
1045
+								$cat_link .= $location_term . '/';
1046
+							}
1047
+						}
1048
+					}
1049
+
1050
+					$term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1051
+					foreach ($term_array as $term) {
1052
+						$term_link_text = preg_replace('/-(\d+)$/', '', $term);
1053
+						$term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1054
+
1055
+						// get term actual name
1056
+						$term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1057
+						if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1058
+							$term_link_text = urldecode($term_info['name']);
1059
+						} else {
1060
+							$term_link_text = geodir_ucwords(urldecode($term_link_text));
1061
+						}
1062
+
1063
+						if ($term_index == count($term_array) && $is_taxonomy_last)
1064
+							$breadcrumb .= $separator . $term_link_text;
1065
+						else {
1066
+							$cat_link .= $term . '/';
1067
+							$breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1068
+						}
1069
+						$term_index++;
1070
+					}
1071
+				}
1072
+
1073
+
1074
+			}
1075
+
1076
+			if (geodir_is_page('detail'))
1077
+				$breadcrumb .= $separator . get_the_title();
1078
+
1079
+			$breadcrumb .= '</li>';
1080
+
1081
+
1082
+		} elseif (geodir_is_page('author')) {
1083
+			$user_id = get_current_user_id();
1084
+			$author_link = get_author_posts_url($user_id);
1085
+			$default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1086
+
1087
+			/**
1088
+			 * Filter author page link.
1089
+			 *
1090
+			 * @since 1.0.0
1091
+			 * @param string $default_author_link Default author link.
1092
+			 * @param int $user_id Author ID.
1093
+			 */
1094
+			$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1095
+
1096
+			$breadcrumb .= '<li>';
1097
+			$breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1098
+
1099
+			if (isset($_REQUEST['list'])) {
1100
+				$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1101
+
1102
+				/**
1103
+				 * Filter author page link.
1104
+				 *
1105
+				 * @since 1.0.0
1106
+				 * @param string $author_link Author page link.
1107
+				 * @param int $user_id Author ID.
1108
+				 * @param string $_REQUEST['stype'] Post type.
1109
+				 */
1110
+				$author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1111
+
1112
+				$breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1113
+				$breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1114
+			} else
1115
+				$breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1116
+
1117
+			$breadcrumb .= '</li>';
1118
+		} elseif (is_category() || is_single()) {
1119
+			$category = get_the_category();
1120
+			if (is_category()) {
1121
+				$breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1122
+			}
1123
+			if (is_single()) {
1124
+				$breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1125
+				$breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1126
+			}
1127
+			/* End of my version ##################################################### */
1128
+		} else if (is_page()) {
1129
+			$page_title = get_the_title();
1130
+
1131
+			if (geodir_is_page('location')) {
1132
+				$page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1133
+			}
1134
+
1135
+			$breadcrumb .= '<li>' . $separator;
1136
+			$breadcrumb .= stripslashes_deep($page_title);
1137
+			$breadcrumb .= '</li>';
1138
+		} else if (is_tag()) {
1139
+			$breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1140
+		} else if (is_day()) {
1141
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1142
+			the_time('F jS, Y');
1143
+			$breadcrumb .= '</li>';
1144
+		} else if (is_month()) {
1145
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1146
+			the_time('F, Y');
1147
+			$breadcrumb .= '</li>';
1148
+		} else if (is_year()) {
1149
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1150
+			the_time('Y');
1151
+			$breadcrumb .= '</li>';
1152
+		} else if (is_author()) {
1153
+			$breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1154
+			$breadcrumb .= '</li>';
1155
+		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1156
+			$breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1157
+			$breadcrumb .= '</li>';
1158
+		} else if (is_search()) {
1159
+			$breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1160
+			$breadcrumb .= '</li>';
1161
+		}
1162
+		$breadcrumb .= '</ul></div>';
1163
+
1164
+		/**
1165
+		 * Filter breadcrumb html output.
1166
+		 *
1167
+		 * @since 1.0.0
1168
+		 * @param string $breadcrumb Breadcrumb HTML.
1169
+		 * @param string $separator Breadcrumb separator.
1170
+		 */
1171
+		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1172
+	}
1173 1173
 }
1174 1174
 
1175 1175
 
1176 1176
 add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
1177 1177
 if (!function_exists('geodir_allow_wpadmin')) {
1178
-    /**
1179
-     * Allow only admins to access wp-admin.
1180
-     *
1181
-     * Normal users will be redirected to home page.
1182
-     *
1183
-     * @since 1.0.0
1184
-     * @package GeoDirectory
1185
-     * @global object $wpdb WordPress Database object.
1186
-     */
1187
-    function geodir_allow_wpadmin()
1188
-    {
1189
-        global $wpdb;
1190
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1191
-        {
1192
-            if (current_user_can('manage_options')) {
1193
-            } else {
1194
-
1195
-                wp_redirect(home_url());
1196
-                exit;
1197
-            }
1178
+	/**
1179
+	 * Allow only admins to access wp-admin.
1180
+	 *
1181
+	 * Normal users will be redirected to home page.
1182
+	 *
1183
+	 * @since 1.0.0
1184
+	 * @package GeoDirectory
1185
+	 * @global object $wpdb WordPress Database object.
1186
+	 */
1187
+	function geodir_allow_wpadmin()
1188
+	{
1189
+		global $wpdb;
1190
+		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1191
+		{
1192
+			if (current_user_can('manage_options')) {
1193
+			} else {
1194
+
1195
+				wp_redirect(home_url());
1196
+				exit;
1197
+			}
1198 1198
 
1199
-        }
1200
-    }
1199
+		}
1200
+	}
1201 1201
 }
1202 1202
 
1203 1203
 
@@ -1211,50 +1211,50 @@  discard block
 block discarded – undo
1211 1211
  */
1212 1212
 function fetch_remote_file($url)
1213 1213
 {
1214
-    // extract the file name and extension from the url
1215
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1216
-    $file_name = basename($url);
1217
-    if (strpos($file_name, '?') !== false) {
1218
-        list($file_name) = explode('?', $file_name);
1219
-    }
1220
-
1221
-
1222
-    // get placeholder file in the upload dir with a unique, sanitized filename
1223
-
1224
-    $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1225
-
1226
-    $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1227
-    if ($upload['error'])
1228
-        return new WP_Error('upload_dir_error', $upload['error']);
1229
-
1230
-    // fetch the remote url and write it to the placeholder file
1231
-    $headers = wp_get_http($url, $upload['file']);
1232
-
1233
-    $log_message = '';
1234
-    $filesize = filesize($upload['file']);
1235
-    // request failed
1236
-    if (!$headers) {
1237
-        $log_message = __('Remote server did not respond', 'geodirectory');
1238
-    }
1239
-    // make sure the fetch was successful
1240
-    elseif ($headers['response'] != '200') {
1241
-        $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1242
-    }
1243
-    elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
1244
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1245
-    }
1246
-    elseif (0 == $filesize) {
1247
-        $log_message = __('Zero size file downloaded', 'geodirectory');
1248
-    }
1249
-
1250
-    if($log_message){
1251
-        $del = unlink($upload['file']);
1252
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1253
-        return new WP_Error('import_file_error',$log_message );
1254
-    }
1255
-
1256
-
1257
-    return $upload;
1214
+	// extract the file name and extension from the url
1215
+	require_once(ABSPATH . 'wp-includes/pluggable.php');
1216
+	$file_name = basename($url);
1217
+	if (strpos($file_name, '?') !== false) {
1218
+		list($file_name) = explode('?', $file_name);
1219
+	}
1220
+
1221
+
1222
+	// get placeholder file in the upload dir with a unique, sanitized filename
1223
+
1224
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1225
+
1226
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1227
+	if ($upload['error'])
1228
+		return new WP_Error('upload_dir_error', $upload['error']);
1229
+
1230
+	// fetch the remote url and write it to the placeholder file
1231
+	$headers = wp_get_http($url, $upload['file']);
1232
+
1233
+	$log_message = '';
1234
+	$filesize = filesize($upload['file']);
1235
+	// request failed
1236
+	if (!$headers) {
1237
+		$log_message = __('Remote server did not respond', 'geodirectory');
1238
+	}
1239
+	// make sure the fetch was successful
1240
+	elseif ($headers['response'] != '200') {
1241
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1242
+	}
1243
+	elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
1244
+		$log_message =  __('Remote file is incorrect size', 'geodirectory');
1245
+	}
1246
+	elseif (0 == $filesize) {
1247
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1248
+	}
1249
+
1250
+	if($log_message){
1251
+		$del = unlink($upload['file']);
1252
+		if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1253
+		return new WP_Error('import_file_error',$log_message );
1254
+	}
1255
+
1256
+
1257
+	return $upload;
1258 1258
 }
1259 1259
 
1260 1260
 /**
@@ -1266,21 +1266,21 @@  discard block
 block discarded – undo
1266 1266
  */
1267 1267
 function geodir_max_upload_size()
1268 1268
 {
1269
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1270
-
1271
-    if ($max_filesize > 0 && $max_filesize < 1) {
1272
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1273
-    } else {
1274
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1275
-    }
1276
-
1277
-    /**
1278
-     * Filter default image upload size limit.
1279
-     *
1280
-     * @since 1.0.0
1281
-     * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1282
-     */
1283
-    return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1269
+	$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1270
+
1271
+	if ($max_filesize > 0 && $max_filesize < 1) {
1272
+		$max_filesize = (int)($max_filesize * 1024) . 'kb';
1273
+	} else {
1274
+		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1275
+	}
1276
+
1277
+	/**
1278
+	 * Filter default image upload size limit.
1279
+	 *
1280
+	 * @since 1.0.0
1281
+	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1282
+	 */
1283
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1284 1284
 }
1285 1285
 
1286 1286
 /**
@@ -1294,11 +1294,11 @@  discard block
 block discarded – undo
1294 1294
  */
1295 1295
 function geodir_dummy_folder_exists()
1296 1296
 {
1297
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1298
-    if (!is_dir($path))
1299
-        return false;
1300
-    else
1301
-        return true;
1297
+	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1298
+	if (!is_dir($path))
1299
+		return false;
1300
+	else
1301
+		return true;
1302 1302
 
1303 1303
 }
1304 1304
 
@@ -1313,237 +1313,237 @@  discard block
 block discarded – undo
1313 1313
  */
1314 1314
 function  geodir_get_author_info($aid)
1315 1315
 {
1316
-    global $wpdb;
1317
-    /*$infosql = "select * from $wpdb->users where ID=$aid";*/
1318
-    $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1319
-    $info = $wpdb->get_results($infosql);
1320
-    if ($info) {
1321
-        return $info[0];
1322
-    }
1316
+	global $wpdb;
1317
+	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1318
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1319
+	$info = $wpdb->get_results($infosql);
1320
+	if ($info) {
1321
+		return $info[0];
1322
+	}
1323 1323
 }
1324 1324
 
1325 1325
 if (!function_exists('adminEmail')) {
1326
-    /**
1327
-     * Send emails to client on post submission, renew etc.
1328
-     *
1329
-     * @since 1.0.0
1330
-     * @package GeoDirectory
1331
-     * @global object $wpdb WordPress Database object.
1332
-     * @param int|string $page_id Page ID.
1333
-     * @param int|string $user_id User ID.
1334
-     * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1335
-     * @param string $custom_1 Custom data to be sent.
1336
-     */
1337
-    function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1338
-    {
1339
-        global $wpdb;
1340
-        if ($message_type == 'expiration') {
1341
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1342
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1343
-        } elseif ($message_type == 'post_submited') {
1344
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1345
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1346
-        } elseif ($message_type == 'renew') {
1347
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1348
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1349
-        } elseif ($message_type == 'upgrade') {
1350
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1351
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1352
-        } elseif ($message_type == 'claim_approved') {
1353
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1354
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1355
-        } elseif ($message_type == 'claim_rejected') {
1356
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1357
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1358
-        } elseif ($message_type == 'claim_requested') {
1359
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1360
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1361
-        } elseif ($message_type == 'auto_claim') {
1362
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1363
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1364
-        } elseif ($message_type == 'payment_success') {
1365
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1366
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1367
-        } elseif ($message_type == 'payment_fail') {
1368
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1369
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1370
-        }
1371
-        $transaction_details = $custom_1;
1372
-        $fromEmail = get_option('site_email');
1373
-        $fromEmailName = get_site_emailName();
1326
+	/**
1327
+	 * Send emails to client on post submission, renew etc.
1328
+	 *
1329
+	 * @since 1.0.0
1330
+	 * @package GeoDirectory
1331
+	 * @global object $wpdb WordPress Database object.
1332
+	 * @param int|string $page_id Page ID.
1333
+	 * @param int|string $user_id User ID.
1334
+	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1335
+	 * @param string $custom_1 Custom data to be sent.
1336
+	 */
1337
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1338
+	{
1339
+		global $wpdb;
1340
+		if ($message_type == 'expiration') {
1341
+			$subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1342
+			$client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1343
+		} elseif ($message_type == 'post_submited') {
1344
+			$subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1345
+			$client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1346
+		} elseif ($message_type == 'renew') {
1347
+			$subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1348
+			$client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1349
+		} elseif ($message_type == 'upgrade') {
1350
+			$subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1351
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1352
+		} elseif ($message_type == 'claim_approved') {
1353
+			$subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1354
+			$client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1355
+		} elseif ($message_type == 'claim_rejected') {
1356
+			$subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1357
+			$client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1358
+		} elseif ($message_type == 'claim_requested') {
1359
+			$subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1360
+			$client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1361
+		} elseif ($message_type == 'auto_claim') {
1362
+			$subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1363
+			$client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1364
+		} elseif ($message_type == 'payment_success') {
1365
+			$subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1366
+			$client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1367
+		} elseif ($message_type == 'payment_fail') {
1368
+			$subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1369
+			$client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1370
+		}
1371
+		$transaction_details = $custom_1;
1372
+		$fromEmail = get_option('site_email');
1373
+		$fromEmailName = get_site_emailName();
1374 1374
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1375
-        $pkg_limit = get_property_price_info_listing($page_id);
1376
-        $alivedays = $pkg_limit['days'];
1377
-        $productlink = get_permalink($page_id);
1378
-        $post_info = get_post($page_id);
1379
-        $post_date = date('dS F,Y', strtotime($post_info->post_date));
1380
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1381
-        $loginurl = geodir_login_url();
1382
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1383
-        $siteurl = home_url();
1384
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1385
-        $user_info = get_userdata($user_id);
1386
-        $user_email = $user_info->user_email;
1387
-        $display_name = geodir_get_client_name($user_id);
1388
-        $user_login = $user_info->user_login;
1389
-        $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1390
-        if ($number_of_grace_days == '') {
1391
-            $number_of_grace_days = 1;
1392
-        }
1393
-        if ($post_info->post_type == 'event') {
1394
-            $post_type = 'event';
1395
-        } else {
1396
-            $post_type = 'listing';
1397
-        }
1398
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1399
-        $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#]');
1400
-        $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);
1401
-        $client_message = str_replace($search_array, $replace_array, $client_message);
1402
-        $subject = str_replace($search_array, $replace_array, $subject);
1403
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1404
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1405
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1406
-
1407
-        $to = $fromEmail;
1408
-        $message = $client_message;
1409
-        $sent = wp_mail($to, $subject, $message, $headers);
1410
-        if( ! $sent ) {
1411
-            if ( is_array( $to ) ) {
1412
-                $to = implode( ',', $to );
1413
-            }
1414
-            $log_message = sprintf(
1415
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1416
-                $message_type,
1417
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1418
-                $to,
1419
-                $subject
1420
-            );
1421
-            geodir_error_log( $log_message );
1422
-        }
1423
-    }
1375
+		$pkg_limit = get_property_price_info_listing($page_id);
1376
+		$alivedays = $pkg_limit['days'];
1377
+		$productlink = get_permalink($page_id);
1378
+		$post_info = get_post($page_id);
1379
+		$post_date = date('dS F,Y', strtotime($post_info->post_date));
1380
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1381
+		$loginurl = geodir_login_url();
1382
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1383
+		$siteurl = home_url();
1384
+		$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1385
+		$user_info = get_userdata($user_id);
1386
+		$user_email = $user_info->user_email;
1387
+		$display_name = geodir_get_client_name($user_id);
1388
+		$user_login = $user_info->user_login;
1389
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1390
+		if ($number_of_grace_days == '') {
1391
+			$number_of_grace_days = 1;
1392
+		}
1393
+		if ($post_info->post_type == 'event') {
1394
+			$post_type = 'event';
1395
+		} else {
1396
+			$post_type = 'listing';
1397
+		}
1398
+		$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1399
+		$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#]');
1400
+		$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);
1401
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1402
+		$subject = str_replace($search_array, $replace_array, $subject);
1403
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1404
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1405
+		$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1406
+
1407
+		$to = $fromEmail;
1408
+		$message = $client_message;
1409
+		$sent = wp_mail($to, $subject, $message, $headers);
1410
+		if( ! $sent ) {
1411
+			if ( is_array( $to ) ) {
1412
+				$to = implode( ',', $to );
1413
+			}
1414
+			$log_message = sprintf(
1415
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1416
+				$message_type,
1417
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1418
+				$to,
1419
+				$subject
1420
+			);
1421
+			geodir_error_log( $log_message );
1422
+		}
1423
+	}
1424 1424
 }
1425 1425
 
1426 1426
 if (!function_exists('sendEmail')) {
1427
-    /**
1428
-     * @todo could be a duplicate of geodir_sendEmail.
1429
-     *
1430
-     * @since 1.0.0
1431
-     * @package GeoDirectory
1432
-     * @param string $fromEmail Sender email address.
1433
-     * @param string $fromEmailName Sender name.
1434
-     * @param string $toEmail Receiver email address.
1435
-     * @param string $toEmailName Receiver name.
1436
-     * @param string $to_subject Email subject.
1437
-     * @param string $to_message Email content.
1438
-     * @param string $extra Not being used.
1439
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1440
-     * @param string $post_id The post ID.
1441
-     * @param string $user_id The user ID.
1442
-     */
1443
-    function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1444
-    {
1445
-        $login_details = '';
1446
-        if ($message_type == 'send_friend') {
1447
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1448
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1449
-        } elseif ($message_type == 'send_enquiry') {
1450
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1451
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1452
-        } elseif ($message_type == 'forgot_password') {
1453
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1454
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1455
-            $login_details = $to_message;
1456
-        } elseif ($message_type == 'registration') {
1457
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1458
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1459
-            $login_details = $to_message;
1460
-        }
1461
-        $to_message = nl2br($to_message);
1462
-        $sitefromEmail = get_option('site_email');
1463
-        $sitefromEmailName = get_site_emailName();
1464
-        $productlink = get_permalink($post_id);
1465
-        $post_info = get_post($post_id);
1466
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1467
-        $siteurl = home_url();
1468
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1469
-        $loginurl = geodir_login_url();
1470
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1471
-        if ($fromEmail == '') {
1472
-            $fromEmail = get_option('site_email');
1473
-        }
1474
-        if ($fromEmailName == '') {
1475
-            $fromEmailName = get_option('site_email_name');
1476
-        }
1477
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1478
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1479
-        $message = str_replace($search_array, $replace_array, $message);
1480
-
1481
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1482
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1483
-        $subject = str_replace($search_array, $replace_array, $subject);
1484
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1485
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1486
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1487
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1488
-
1489
-        $to = $toEmail;
1490
-
1491
-        $sent = wp_mail($to, $subject, $message, $headers);
1492
-        if( ! $sent ) {
1493
-            if ( is_array( $to ) ) {
1494
-                $to = implode( ',', $to );
1495
-            }
1496
-            $log_message = sprintf(
1497
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1498
-                $message_type,
1499
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1500
-                $to,
1501
-                $subject
1502
-            );
1503
-            geodir_error_log( $log_message );
1504
-        }
1427
+	/**
1428
+	 * @todo could be a duplicate of geodir_sendEmail.
1429
+	 *
1430
+	 * @since 1.0.0
1431
+	 * @package GeoDirectory
1432
+	 * @param string $fromEmail Sender email address.
1433
+	 * @param string $fromEmailName Sender name.
1434
+	 * @param string $toEmail Receiver email address.
1435
+	 * @param string $toEmailName Receiver name.
1436
+	 * @param string $to_subject Email subject.
1437
+	 * @param string $to_message Email content.
1438
+	 * @param string $extra Not being used.
1439
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1440
+	 * @param string $post_id The post ID.
1441
+	 * @param string $user_id The user ID.
1442
+	 */
1443
+	function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1444
+	{
1445
+		$login_details = '';
1446
+		if ($message_type == 'send_friend') {
1447
+			$subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1448
+			$message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1449
+		} elseif ($message_type == 'send_enquiry') {
1450
+			$subject = __(get_option('email_enquiry_subject'),'geodirectory');
1451
+			$message = __(get_option('email_enquiry_content'),'geodirectory');
1452
+		} elseif ($message_type == 'forgot_password') {
1453
+			$subject = __(get_option('forgot_password_subject'),'geodirectory');
1454
+			$message = __(get_option('forgot_password_content'),'geodirectory');
1455
+			$login_details = $to_message;
1456
+		} elseif ($message_type == 'registration') {
1457
+			$subject = __(get_option('registration_success_email_subject'),'geodirectory');
1458
+			$message = __(get_option('registration_success_email_content'),'geodirectory');
1459
+			$login_details = $to_message;
1460
+		}
1461
+		$to_message = nl2br($to_message);
1462
+		$sitefromEmail = get_option('site_email');
1463
+		$sitefromEmailName = get_site_emailName();
1464
+		$productlink = get_permalink($post_id);
1465
+		$post_info = get_post($post_id);
1466
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1467
+		$siteurl = home_url();
1468
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1469
+		$loginurl = geodir_login_url();
1470
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1471
+		if ($fromEmail == '') {
1472
+			$fromEmail = get_option('site_email');
1473
+		}
1474
+		if ($fromEmailName == '') {
1475
+			$fromEmailName = get_option('site_email_name');
1476
+		}
1477
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1478
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1479
+		$message = str_replace($search_array, $replace_array, $message);
1480
+
1481
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1482
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1483
+		$subject = str_replace($search_array, $replace_array, $subject);
1484
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1485
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1486
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
1487
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1488
+
1489
+		$to = $toEmail;
1490
+
1491
+		$sent = wp_mail($to, $subject, $message, $headers);
1492
+		if( ! $sent ) {
1493
+			if ( is_array( $to ) ) {
1494
+				$to = implode( ',', $to );
1495
+			}
1496
+			$log_message = sprintf(
1497
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1498
+				$message_type,
1499
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1500
+				$to,
1501
+				$subject
1502
+			);
1503
+			geodir_error_log( $log_message );
1504
+		}
1505 1505
 
1506
-        ///////// ADMIN BCC EMIALS
1507
-        $admin_bcc = false;
1508
-        if ($message_type == 'registration') {
1509
-            $message_raw = explode(__("Password:", 'geodirectory'), $message);
1510
-            $message_raw2 = explode("</p>", $message_raw[1], 2);
1511
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1512
-        }
1513
-        $adminEmail = get_bloginfo('admin_email');
1514
-        $to = $adminEmail;
1506
+		///////// ADMIN BCC EMIALS
1507
+		$admin_bcc = false;
1508
+		if ($message_type == 'registration') {
1509
+			$message_raw = explode(__("Password:", 'geodirectory'), $message);
1510
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1511
+			$message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1512
+		}
1513
+		$adminEmail = get_bloginfo('admin_email');
1514
+		$to = $adminEmail;
1515 1515
 
1516
-        if ($message_type == 'registration' && get_option('bcc_new_user')) {
1517
-            $subject .= ' - ADMIN BCC COPY';
1518
-            $admin_bcc = true;
1519
-        }
1520
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1521
-            $subject .= ' - ADMIN BCC COPY';
1522
-            $admin_bcc = true;
1523
-        }
1524
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1525
-            $subject .= ' - ADMIN BCC COPY';
1526
-            $admin_bcc = true;
1527
-        }
1516
+		if ($message_type == 'registration' && get_option('bcc_new_user')) {
1517
+			$subject .= ' - ADMIN BCC COPY';
1518
+			$admin_bcc = true;
1519
+		}
1520
+		elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1521
+			$subject .= ' - ADMIN BCC COPY';
1522
+			$admin_bcc = true;
1523
+		}
1524
+		elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1525
+			$subject .= ' - ADMIN BCC COPY';
1526
+			$admin_bcc = true;
1527
+		}
1528 1528
 
1529
-        if($admin_bcc === true){
1530
-            $sent = wp_mail($to, $subject, $message, $headers);
1531
-            if( ! $sent ) {
1532
-                if ( is_array( $to ) ) {
1533
-                    $to = implode( ',', $to );
1534
-                }
1535
-                $log_message = sprintf(
1536
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1537
-                    $message_type,
1538
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1539
-                    $to,
1540
-                    $subject
1541
-                );
1542
-                geodir_error_log( $log_message );
1543
-            }
1544
-        }
1529
+		if($admin_bcc === true){
1530
+			$sent = wp_mail($to, $subject, $message, $headers);
1531
+			if( ! $sent ) {
1532
+				if ( is_array( $to ) ) {
1533
+					$to = implode( ',', $to );
1534
+				}
1535
+				$log_message = sprintf(
1536
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1537
+					$message_type,
1538
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1539
+					$to,
1540
+					$subject
1541
+				);
1542
+				geodir_error_log( $log_message );
1543
+			}
1544
+		}
1545 1545
 
1546
-    }
1546
+	}
1547 1547
 }
1548 1548
 
1549 1549
 /*
@@ -1561,16 +1561,16 @@  discard block
 block discarded – undo
1561 1561
  */
1562 1562
 function gd_lang_object_ids($ids_array, $type)
1563 1563
 {
1564
-    if (function_exists('icl_object_id')) {
1565
-        $res = array();
1566
-        foreach ($ids_array as $id) {
1567
-            $xlat = icl_object_id($id, $type, false);
1568
-            if (!is_null($xlat)) $res[] = $xlat;
1569
-        }
1570
-        return $res;
1571
-    } else {
1572
-        return $ids_array;
1573
-    }
1564
+	if (function_exists('icl_object_id')) {
1565
+		$res = array();
1566
+		foreach ($ids_array as $id) {
1567
+			$xlat = icl_object_id($id, $type, false);
1568
+			if (!is_null($xlat)) $res[] = $xlat;
1569
+		}
1570
+		return $res;
1571
+	} else {
1572
+		return $ids_array;
1573
+	}
1574 1574
 }
1575 1575
 
1576 1576
 
@@ -1585,31 +1585,31 @@  discard block
 block discarded – undo
1585 1585
  * @return array Modified Body CSS classes.
1586 1586
  */
1587 1587
 function geodir_custom_posts_body_class($classes) {
1588
-    global $wpdb, $wp;
1589
-    $post_types = geodir_get_posttypes('object');
1590
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1591
-        $classes[] = 'geodir_custom_posts';
1592
-    }
1593
-
1594
-    // fix body class for signup page
1595
-    if (geodir_is_page('login')) {
1596
-        $new_classes = array();
1597
-        $new_classes[] = 'signup page-geodir-signup';
1598
-        if (!empty($classes)) {
1599
-            foreach ($classes as $class) {
1600
-                if ($class && $class != 'home' && $class != 'blog') {
1601
-                    $new_classes[] = $class;
1602
-                }
1603
-            }
1604
-        }
1605
-        $classes = $new_classes;
1606
-    }
1588
+	global $wpdb, $wp;
1589
+	$post_types = geodir_get_posttypes('object');
1590
+	if (!empty($post_types) && count((array)$post_types) > 1) {
1591
+		$classes[] = 'geodir_custom_posts';
1592
+	}
1593
+
1594
+	// fix body class for signup page
1595
+	if (geodir_is_page('login')) {
1596
+		$new_classes = array();
1597
+		$new_classes[] = 'signup page-geodir-signup';
1598
+		if (!empty($classes)) {
1599
+			foreach ($classes as $class) {
1600
+				if ($class && $class != 'home' && $class != 'blog') {
1601
+					$new_classes[] = $class;
1602
+				}
1603
+			}
1604
+		}
1605
+		$classes = $new_classes;
1606
+	}
1607 1607
 
1608
-    if (geodir_is_geodir_page()) {
1609
-        $classes[] = 'geodir-page';
1610
-    }
1608
+	if (geodir_is_geodir_page()) {
1609
+		$classes[] = 'geodir-page';
1610
+	}
1611 1611
 
1612
-    return $classes;
1612
+	return $classes;
1613 1613
 }
1614 1614
 
1615 1615
 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
@@ -1624,12 +1624,12 @@  discard block
 block discarded – undo
1624 1624
  */
1625 1625
 function geodir_map_zoom_level()
1626 1626
 {
1627
-    /**
1628
-     * Filter GD map zoom level.
1629
-     *
1630
-     * @since 1.0.0
1631
-     */
1632
-    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));
1627
+	/**
1628
+	 * Filter GD map zoom level.
1629
+	 *
1630
+	 * @since 1.0.0
1631
+	 */
1632
+	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));
1633 1633
 
1634 1634
 }
1635 1635
 
@@ -1643,12 +1643,12 @@  discard block
 block discarded – undo
1643 1643
  */
1644 1644
 function geodir_option_version_backup($geodir_option_name)
1645 1645
 {
1646
-    $version_date = time();
1647
-    $geodir_option = get_option($geodir_option_name);
1646
+	$version_date = time();
1647
+	$geodir_option = get_option($geodir_option_name);
1648 1648
 
1649
-    if (!empty($geodir_option)) {
1650
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1651
-    }
1649
+	if (!empty($geodir_option)) {
1650
+		add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1651
+	}
1652 1652
 }
1653 1653
 
1654 1654
 /**
@@ -1661,11 +1661,11 @@  discard block
 block discarded – undo
1661 1661
  */
1662 1662
 function get_page_id_geodir_add_listing_page($page_id)
1663 1663
 {
1664
-    if (geodir_wpml_multilingual_status()) {
1665
-        $post_type = 'post_page';
1666
-        $page_id = geodir_get_wpml_element_id($page_id, $post_type);
1667
-    }
1668
-    return $page_id;
1664
+	if (geodir_wpml_multilingual_status()) {
1665
+		$post_type = 'post_page';
1666
+		$page_id = geodir_get_wpml_element_id($page_id, $post_type);
1667
+	}
1668
+	return $page_id;
1669 1669
 }
1670 1670
 
1671 1671
 /**
@@ -1677,10 +1677,10 @@  discard block
 block discarded – undo
1677 1677
  */
1678 1678
 function geodir_wpml_multilingual_status()
1679 1679
 {
1680
-    if (function_exists('icl_object_id')) {
1681
-        return true;
1682
-    }
1683
-    return false;
1680
+	if (function_exists('icl_object_id')) {
1681
+		return true;
1682
+	}
1683
+	return false;
1684 1684
 }
1685 1685
 
1686 1686
 /**
@@ -1694,22 +1694,22 @@  discard block
 block discarded – undo
1694 1694
  */
1695 1695
 function geodir_get_wpml_element_id($page_id, $post_type)
1696 1696
 {
1697
-    global $sitepress;
1698
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1699
-        $trid = $sitepress->get_element_trid($page_id, $post_type);
1697
+	global $sitepress;
1698
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1699
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
1700 1700
 
1701
-        if ($trid > 0) {
1702
-            $translations = $sitepress->get_element_translations($trid, $post_type);
1701
+		if ($trid > 0) {
1702
+			$translations = $sitepress->get_element_translations($trid, $post_type);
1703 1703
 
1704
-            $lang = $sitepress->get_current_language();
1705
-            $lang = $lang ? $lang : $sitepress->get_default_language();
1704
+			$lang = $sitepress->get_current_language();
1705
+			$lang = $lang ? $lang : $sitepress->get_default_language();
1706 1706
 
1707
-            if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1708
-                $page_id = $translations[$lang]->element_id;
1709
-            }
1710
-        }
1711
-    }
1712
-    return $page_id;
1707
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1708
+				$page_id = $translations[$lang]->element_id;
1709
+			}
1710
+		}
1711
+	}
1712
+	return $page_id;
1713 1713
 }
1714 1714
 
1715 1715
 /**
@@ -1721,20 +1721,20 @@  discard block
 block discarded – undo
1721 1721
  */
1722 1722
 function geodir_wpml_check_element_id()
1723 1723
 {
1724
-    global $sitepress;
1725
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1726
-        $el_type = 'post_page';
1727
-        $el_id = get_option('geodir_add_listing_page');
1728
-        $default_lang = $sitepress->get_default_language();
1729
-        $el_details = $sitepress->get_element_language_details($el_id, $el_type);
1730
-
1731
-        if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1732
-            if (!$el_details->source_language_code) {
1733
-                $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1734
-                $sitepress->icl_translations_cache->clear();
1735
-            }
1736
-        }
1737
-    }
1724
+	global $sitepress;
1725
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1726
+		$el_type = 'post_page';
1727
+		$el_id = get_option('geodir_add_listing_page');
1728
+		$default_lang = $sitepress->get_default_language();
1729
+		$el_details = $sitepress->get_element_language_details($el_id, $el_type);
1730
+
1731
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1732
+			if (!$el_details->source_language_code) {
1733
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1734
+				$sitepress->icl_translations_cache->clear();
1735
+			}
1736
+		}
1737
+	}
1738 1738
 }
1739 1739
 
1740 1740
 /**
@@ -1749,44 +1749,44 @@  discard block
 block discarded – undo
1749 1749
  */
1750 1750
 function geodir_widget_listings_get_order($query_args)
1751 1751
 {
1752
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1753
-
1754
-    $query_args = $gd_query_args_widgets;
1755
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1756
-        return $wpdb->posts . ".post_date DESC, ";
1757
-    }
1758
-
1759
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1760
-    $table = $plugin_prefix . $post_type . '_detail';
1761
-
1762
-    $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1763
-
1764
-    switch ($sort_by) {
1765
-        case 'latest':
1766
-        case 'newest':
1767
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1768
-            break;
1769
-        case 'featured':
1770
-            $orderby = $table . ".is_featured ASC, ";
1771
-            break;
1772
-        case 'az':
1773
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1774
-            break;
1775
-        case 'high_review':
1776
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1777
-            break;
1778
-        case 'high_rating':
1779
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1780
-            break;
1781
-        case 'random':
1782
-            $orderby = "RAND(), ";
1783
-            break;
1784
-        default:
1785
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1786
-            break;
1787
-    }
1788
-
1789
-    return $orderby;
1752
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1753
+
1754
+	$query_args = $gd_query_args_widgets;
1755
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1756
+		return $wpdb->posts . ".post_date DESC, ";
1757
+	}
1758
+
1759
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1760
+	$table = $plugin_prefix . $post_type . '_detail';
1761
+
1762
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1763
+
1764
+	switch ($sort_by) {
1765
+		case 'latest':
1766
+		case 'newest':
1767
+			$orderby = $wpdb->posts . ".post_date DESC, ";
1768
+			break;
1769
+		case 'featured':
1770
+			$orderby = $table . ".is_featured ASC, ";
1771
+			break;
1772
+		case 'az':
1773
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1774
+			break;
1775
+		case 'high_review':
1776
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1777
+			break;
1778
+		case 'high_rating':
1779
+			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
1780
+			break;
1781
+		case 'random':
1782
+			$orderby = "RAND(), ";
1783
+			break;
1784
+		default:
1785
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1786
+			break;
1787
+	}
1788
+
1789
+	return $orderby;
1790 1790
 }
1791 1791
 
1792 1792
 /**
@@ -1804,127 +1804,127 @@  discard block
 block discarded – undo
1804 1804
  */
1805 1805
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
1806 1806
 {
1807
-    global $wpdb, $plugin_prefix, $table_prefix;
1808
-    $GLOBALS['gd_query_args_widgets'] = $query_args;
1809
-    $gd_query_args_widgets = $query_args;
1810
-
1811
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1812
-    $table = $plugin_prefix . $post_type . '_detail';
1813
-
1814
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1815
-    /**
1816
-     * Filter widget listing fields string part that is being used for query.
1817
-     *
1818
-     * @since 1.0.0
1819
-     * @param string $fields Fields string.
1820
-     * @param string $table Table name.
1821
-     * @param string $post_type Post type.
1822
-     */
1823
-    $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1824
-
1825
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1826
-
1827
-    ########### WPML ###########
1828
-
1829
-    if (function_exists('icl_object_id')) {
1830
-        global $sitepress;
1831
-        $lang_code = ICL_LANGUAGE_CODE;
1832
-        $default_lang_code = $sitepress->get_default_language();
1833
-        if ($lang_code) {
1834
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1835
-        }
1836
-    }
1837
-
1838
-    ########### WPML ###########
1807
+	global $wpdb, $plugin_prefix, $table_prefix;
1808
+	$GLOBALS['gd_query_args_widgets'] = $query_args;
1809
+	$gd_query_args_widgets = $query_args;
1810
+
1811
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1812
+	$table = $plugin_prefix . $post_type . '_detail';
1813
+
1814
+	$fields = $wpdb->posts . ".*, " . $table . ".*";
1815
+	/**
1816
+	 * Filter widget listing fields string part that is being used for query.
1817
+	 *
1818
+	 * @since 1.0.0
1819
+	 * @param string $fields Fields string.
1820
+	 * @param string $table Table name.
1821
+	 * @param string $post_type Post type.
1822
+	 */
1823
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1824
+
1825
+	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1826
+
1827
+	########### WPML ###########
1828
+
1829
+	if (function_exists('icl_object_id')) {
1830
+		global $sitepress;
1831
+		$lang_code = ICL_LANGUAGE_CODE;
1832
+		$default_lang_code = $sitepress->get_default_language();
1833
+		if ($lang_code) {
1834
+			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1835
+		}
1836
+	}
1839 1837
 
1840
-    /**
1841
-     * Filter widget listing join clause string part that is being used for query.
1842
-     *
1843
-     * @since 1.0.0
1844
-     * @param string $join Join clause string.
1845
-     * @param string $post_type Post type.
1846
-     */
1847
-    $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1838
+	########### WPML ###########
1848 1839
 
1849
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1840
+	/**
1841
+	 * Filter widget listing join clause string part that is being used for query.
1842
+	 *
1843
+	 * @since 1.0.0
1844
+	 * @param string $join Join clause string.
1845
+	 * @param string $post_type Post type.
1846
+	 */
1847
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1850 1848
 
1851
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
1849
+	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1852 1850
 
1853
-    ########### WPML ###########
1854
-    if (function_exists('icl_object_id')) {
1855
-        if ($lang_code) {
1856
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
1857
-        }
1858
-    }
1859
-    ########### WPML ###########
1860
-    /**
1861
-     * Filter widget listing where clause string part that is being used for query.
1862
-     *
1863
-     * @since 1.0.0
1864
-     * @param string $where Where clause string.
1865
-     * @param string $post_type Post type.
1866
-     */
1867
-    $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
1868
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
1869
-
1870
-    $groupby = " GROUP BY $wpdb->posts.ID ";
1871
-    /**
1872
-     * Filter widget listing groupby clause string part that is being used for query.
1873
-     *
1874
-     * @since 1.0.0
1875
-     * @param string $groupby Group by clause string.
1876
-     * @param string $post_type Post type.
1877
-     */
1878
-    $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
1851
+	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
1879 1852
 
1880
-    if ($count_only) {
1881
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1853
+	########### WPML ###########
1854
+	if (function_exists('icl_object_id')) {
1855
+		if ($lang_code) {
1856
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
1857
+		}
1858
+	}
1859
+	########### WPML ###########
1860
+	/**
1861
+	 * Filter widget listing where clause string part that is being used for query.
1862
+	 *
1863
+	 * @since 1.0.0
1864
+	 * @param string $where Where clause string.
1865
+	 * @param string $post_type Post type.
1866
+	 */
1867
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
1868
+	$where = $where != '' ? " WHERE 1=1 " . $where : '';
1869
+
1870
+	$groupby = " GROUP BY $wpdb->posts.ID ";
1871
+	/**
1872
+	 * Filter widget listing groupby clause string part that is being used for query.
1873
+	 *
1874
+	 * @since 1.0.0
1875
+	 * @param string $groupby Group by clause string.
1876
+	 * @param string $post_type Post type.
1877
+	 */
1878
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
1879
+
1880
+	if ($count_only) {
1881
+		$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1882 1882
 			" . $join . "
1883 1883
 			" . $where;
1884
-        $rows = (int)$wpdb->get_var($sql);
1885
-    } else {
1886
-        $orderby = geodir_widget_listings_get_order($query_args);
1887
-        /**
1888
-         * Filter widget listing orderby clause string part that is being used for query.
1889
-         *
1890
-         * @since 1.0.0
1891
-         * @param string $orderby Order by clause string.
1892
-         * @param string $table Table name.
1893
-         * @param string $post_type Post type.
1894
-         */
1895
-        $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
1896
-        $orderby .= $wpdb->posts . ".post_title ASC";
1897
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
1898
-
1899
-        $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
1900
-        /**
1901
-         * Filter widget listing limit that is being used for query.
1902
-         *
1903
-         * @since 1.0.0
1904
-         * @param int $limit Query results limit.
1905
-         * @param string $post_type Post type.
1906
-         */
1907
-        $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1908
-
1909
-        $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1910
-        if ( !$page )
1911
-            $page = 1;
1912
-
1913
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1914
-
1915
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
1884
+		$rows = (int)$wpdb->get_var($sql);
1885
+	} else {
1886
+		$orderby = geodir_widget_listings_get_order($query_args);
1887
+		/**
1888
+		 * Filter widget listing orderby clause string part that is being used for query.
1889
+		 *
1890
+		 * @since 1.0.0
1891
+		 * @param string $orderby Order by clause string.
1892
+		 * @param string $table Table name.
1893
+		 * @param string $post_type Post type.
1894
+		 */
1895
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
1896
+		$orderby .= $wpdb->posts . ".post_title ASC";
1897
+		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
1898
+
1899
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
1900
+		/**
1901
+		 * Filter widget listing limit that is being used for query.
1902
+		 *
1903
+		 * @since 1.0.0
1904
+		 * @param int $limit Query results limit.
1905
+		 * @param string $post_type Post type.
1906
+		 */
1907
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1908
+
1909
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1910
+		if ( !$page )
1911
+			$page = 1;
1912
+
1913
+		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1914
+
1915
+		$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
1916 1916
 			" . $join . "
1917 1917
 			" . $where . "
1918 1918
 			" . $groupby . "
1919 1919
 			" . $orderby . "
1920 1920
 			" . $limit;
1921
-        $rows = $wpdb->get_results($sql);
1922
-    }
1921
+		$rows = $wpdb->get_results($sql);
1922
+	}
1923 1923
 
1924
-    unset($GLOBALS['gd_query_args_widgets']);
1925
-    unset($gd_query_args_widgets);
1924
+	unset($GLOBALS['gd_query_args_widgets']);
1925
+	unset($gd_query_args_widgets);
1926 1926
 
1927
-    return $rows;
1927
+	return $rows;
1928 1928
 }
1929 1929
 
1930 1930
 /**
@@ -1939,21 +1939,21 @@  discard block
 block discarded – undo
1939 1939
  */
1940 1940
 function geodir_function_widget_listings_fields($fields)
1941 1941
 {
1942
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1942
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1943 1943
 
1944
-    $query_args = $gd_query_args_widgets;
1945
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1946
-        return $fields;
1947
-    }
1948
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1949
-    $table = $plugin_prefix . $post_type . '_detail';
1944
+	$query_args = $gd_query_args_widgets;
1945
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1946
+		return $fields;
1947
+	}
1948
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1949
+	$table = $plugin_prefix . $post_type . '_detail';
1950 1950
 
1951
-    /*
1951
+	/*
1952 1952
 	if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
1953 1953
 		$fields .= $fields != '' ? ", " . EVENT_SCHEDULE . ".*" : EVENT_SCHEDULE . ".*";
1954 1954
 	}
1955 1955
 	*/
1956
-    return $fields;
1956
+	return $fields;
1957 1957
 }
1958 1958
 
1959 1959
 /**
@@ -1968,34 +1968,34 @@  discard block
 block discarded – undo
1968 1968
  */
1969 1969
 function geodir_function_widget_listings_join($join)
1970 1970
 {
1971
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1971
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1972 1972
 
1973
-    $query_args = $gd_query_args_widgets;
1974
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1975
-        return $where;
1976
-    }
1973
+	$query_args = $gd_query_args_widgets;
1974
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1975
+		return $where;
1976
+	}
1977 1977
 
1978
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1979
-    $table = $plugin_prefix . $post_type . '_detail';
1978
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1979
+	$table = $plugin_prefix . $post_type . '_detail';
1980 1980
 
1981
-    if (!empty($query_args['with_pics_only'])) {
1982
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
1983
-    }
1981
+	if (!empty($query_args['with_pics_only'])) {
1982
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
1983
+	}
1984 1984
 
1985
-    /*
1985
+	/*
1986 1986
 	if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
1987 1987
 		$join .= " INNER JOIN " . EVENT_SCHEDULE ." ON (" . EVENT_SCHEDULE .".event_id = " . $wpdb->posts . ".ID)";
1988 1988
 	}
1989 1989
 	*/
1990 1990
 
1991
-    if (!empty($query_args['tax_query'])) {
1992
-        $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
1993
-        if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
1994
-            $join .= $tax_queries['join'];
1995
-        }
1996
-    }
1991
+	if (!empty($query_args['tax_query'])) {
1992
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
1993
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
1994
+			$join .= $tax_queries['join'];
1995
+		}
1996
+	}
1997 1997
 
1998
-    return $join;
1998
+	return $join;
1999 1999
 }
2000 2000
 
2001 2001
 /**
@@ -2010,50 +2010,50 @@  discard block
 block discarded – undo
2010 2010
  */
2011 2011
 function geodir_function_widget_listings_where($where)
2012 2012
 {
2013
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2014
-
2015
-    $query_args = $gd_query_args_widgets;
2016
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2017
-        return $where;
2018
-    }
2019
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2020
-    $table = $plugin_prefix . $post_type . '_detail';
2021
-
2022
-    if (!empty($query_args)) {
2023
-        if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2024
-            $where = geodir_default_location_where($where, $table);
2025
-        }
2013
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2026 2014
 
2027
-        if (!empty($query_args['show_featured_only'])) {
2028
-            $where .= " AND " . $table . ".is_featured = '1'";
2029
-        }
2015
+	$query_args = $gd_query_args_widgets;
2016
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2017
+		return $where;
2018
+	}
2019
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2020
+	$table = $plugin_prefix . $post_type . '_detail';
2030 2021
 
2031
-        if (!empty($query_args['show_special_only'])) {
2032
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2033
-        }
2022
+	if (!empty($query_args)) {
2023
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2024
+			$where = geodir_default_location_where($where, $table);
2025
+		}
2034 2026
 
2035
-        if (!empty($query_args['with_pics_only'])) {
2036
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2037
-        }
2027
+		if (!empty($query_args['show_featured_only'])) {
2028
+			$where .= " AND " . $table . ".is_featured = '1'";
2029
+		}
2038 2030
 
2039
-        if (!empty($query_args['featured_image_only'])) {
2040
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2041
-        }
2031
+		if (!empty($query_args['show_special_only'])) {
2032
+			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2033
+		}
2042 2034
 
2043
-        if (!empty($query_args['with_videos_only'])) {
2044
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2045
-        }
2035
+		if (!empty($query_args['with_pics_only'])) {
2036
+			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2037
+		}
2046 2038
 
2047
-        if (!empty($query_args['tax_query'])) {
2048
-            $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2039
+		if (!empty($query_args['featured_image_only'])) {
2040
+			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2041
+		}
2049 2042
 
2050
-            if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2051
-                $where .= $tax_queries['where'];
2052
-            }
2053
-        }
2054
-    }
2043
+		if (!empty($query_args['with_videos_only'])) {
2044
+			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2045
+		}
2046
+
2047
+		if (!empty($query_args['tax_query'])) {
2048
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2055 2049
 
2056
-    return $where;
2050
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2051
+				$where .= $tax_queries['where'];
2052
+			}
2053
+		}
2054
+	}
2055
+
2056
+	return $where;
2057 2057
 }
2058 2058
 
2059 2059
 /**
@@ -2068,23 +2068,23 @@  discard block
 block discarded – undo
2068 2068
  */
2069 2069
 function geodir_function_widget_listings_orderby($orderby)
2070 2070
 {
2071
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2071
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2072 2072
 
2073
-    $query_args = $gd_query_args_widgets;
2074
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2075
-        return $orderby;
2076
-    }
2073
+	$query_args = $gd_query_args_widgets;
2074
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2075
+		return $orderby;
2076
+	}
2077 2077
 
2078
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2079
-    $table = $plugin_prefix . $post_type . '_detail';
2078
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2079
+	$table = $plugin_prefix . $post_type . '_detail';
2080 2080
 
2081
-    /*
2081
+	/*
2082 2082
 	if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
2083 2083
 		$orderby .= EVENT_SCHEDULE . ".event_date ASC, " . EVENT_SCHEDULE . ".event_starttime ASC , " . $table . ".is_featured ASC, ";
2084 2084
 	}
2085 2085
 	*/
2086 2086
 
2087
-    return $orderby;
2087
+	return $orderby;
2088 2088
 }
2089 2089
 
2090 2090
 /**
@@ -2099,18 +2099,18 @@  discard block
 block discarded – undo
2099 2099
  */
2100 2100
 function geodir_function_widget_listings_limit($limit)
2101 2101
 {
2102
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2102
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2103 2103
 
2104
-    $query_args = $gd_query_args_widgets;
2105
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2106
-        return $limit;
2107
-    }
2104
+	$query_args = $gd_query_args_widgets;
2105
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2106
+		return $limit;
2107
+	}
2108 2108
 
2109
-    if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2110
-        $limit = (int)$query_args['posts_per_page'];
2111
-    }
2109
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2110
+		$limit = (int)$query_args['posts_per_page'];
2111
+	}
2112 2112
 
2113
-    return $limit;
2113
+	return $limit;
2114 2114
 }
2115 2115
 
2116 2116
 /**
@@ -2124,24 +2124,24 @@  discard block
 block discarded – undo
2124 2124
  */
2125 2125
 function geodir_media_image_large_width($default = 800, $params = '')
2126 2126
 {
2127
-    $large_size_w = get_option('large_size_w');
2128
-    $large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2129
-    $large_size_w = absint($large_size_w);
2130
-
2131
-    if (!get_option('geodir_use_wp_media_large_size')) {
2132
-        $large_size_w = 800;
2133
-    }
2134
-
2135
-    /**
2136
-     * Filter large image width.
2137
-     *
2138
-     * @since 1.0.0
2139
-     * @param int $large_size_w Large image width.
2140
-     * @param int $default Default width.
2141
-     * @param string|array $params Image parameters.
2142
-     */
2143
-    $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2144
-    return $large_size_w;
2127
+	$large_size_w = get_option('large_size_w');
2128
+	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2129
+	$large_size_w = absint($large_size_w);
2130
+
2131
+	if (!get_option('geodir_use_wp_media_large_size')) {
2132
+		$large_size_w = 800;
2133
+	}
2134
+
2135
+	/**
2136
+	 * Filter large image width.
2137
+	 *
2138
+	 * @since 1.0.0
2139
+	 * @param int $large_size_w Large image width.
2140
+	 * @param int $default Default width.
2141
+	 * @param string|array $params Image parameters.
2142
+	 */
2143
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2144
+	return $large_size_w;
2145 2145
 }
2146 2146
 
2147 2147
 /**
@@ -2155,25 +2155,25 @@  discard block
 block discarded – undo
2155 2155
  */
2156 2156
 function geodir_media_image_large_height($default = 800, $params = '')
2157 2157
 {
2158
-    $large_size_h = get_option('large_size_h');
2159
-    $large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2160
-    $large_size_h = absint($large_size_h);
2161
-
2162
-    if (!get_option('geodir_use_wp_media_large_size')) {
2163
-        $large_size_h = 800;
2164
-    }
2165
-
2166
-    /**
2167
-     * Filter large image height.
2168
-     *
2169
-     * @since 1.0.0
2170
-     * @param int $large_size_h Large image height.
2171
-     * @param int $default Default height.
2172
-     * @param string|array $params Image parameters.
2173
-     */
2174
-    $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2158
+	$large_size_h = get_option('large_size_h');
2159
+	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2160
+	$large_size_h = absint($large_size_h);
2175 2161
 
2176
-    return $large_size_h;
2162
+	if (!get_option('geodir_use_wp_media_large_size')) {
2163
+		$large_size_h = 800;
2164
+	}
2165
+
2166
+	/**
2167
+	 * Filter large image height.
2168
+	 *
2169
+	 * @since 1.0.0
2170
+	 * @param int $large_size_h Large image height.
2171
+	 * @param int $default Default height.
2172
+	 * @param string|array $params Image parameters.
2173
+	 */
2174
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2175
+
2176
+	return $large_size_h;
2177 2177
 }
2178 2178
 
2179 2179
 /**
@@ -2188,25 +2188,25 @@  discard block
 block discarded – undo
2188 2188
  */
2189 2189
 function geodir_sanitize_location_name($type, $name, $translate = true)
2190 2190
 {
2191
-    if ($name == '') {
2192
-        return NULL;
2193
-    }
2194
-
2195
-    $type = $type == 'gd_country' ? 'country' : $type;
2196
-    $type = $type == 'gd_region' ? 'region' : $type;
2197
-    $type = $type == 'gd_city' ? 'city' : $type;
2198
-
2199
-    $return = $name;
2200
-    if (function_exists('get_actual_location_name')) {
2201
-        $return = get_actual_location_name($type, $name, $translate);
2202
-    } else {
2203
-        $return = preg_replace('/-(\d+)$/', '', $return);
2204
-        $return = preg_replace('/[_-]/', ' ', $return);
2205
-        $return = geodir_ucwords($return);
2206
-        $return = $translate ? __($return, 'geodirectory') : $return;
2207
-    }
2208
-
2209
-    return $return;
2191
+	if ($name == '') {
2192
+		return NULL;
2193
+	}
2194
+
2195
+	$type = $type == 'gd_country' ? 'country' : $type;
2196
+	$type = $type == 'gd_region' ? 'region' : $type;
2197
+	$type = $type == 'gd_city' ? 'city' : $type;
2198
+
2199
+	$return = $name;
2200
+	if (function_exists('get_actual_location_name')) {
2201
+		$return = get_actual_location_name($type, $name, $translate);
2202
+	} else {
2203
+		$return = preg_replace('/-(\d+)$/', '', $return);
2204
+		$return = preg_replace('/[_-]/', ' ', $return);
2205
+		$return = geodir_ucwords($return);
2206
+		$return = $translate ? __($return, 'geodirectory') : $return;
2207
+	}
2208
+
2209
+	return $return;
2210 2210
 }
2211 2211
 
2212 2212
 
@@ -2220,14 +2220,14 @@  discard block
 block discarded – undo
2220 2220
 function geodir_comments_number($number)
2221 2221
 {
2222 2222
 
2223
-    if ($number > 1) {
2224
-        $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2225
-    } elseif ($number == 0 || $number == '') {
2226
-        $output = __('No Reviews', 'geodirectory');
2227
-    } else { // must be one
2228
-        $output = __('1 Review', 'geodirectory');
2229
-    }
2230
-    echo $output;
2223
+	if ($number > 1) {
2224
+		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2225
+	} elseif ($number == 0 || $number == '') {
2226
+		$output = __('No Reviews', 'geodirectory');
2227
+	} else { // must be one
2228
+		$output = __('1 Review', 'geodirectory');
2229
+	}
2230
+	echo $output;
2231 2231
 }
2232 2232
 
2233 2233
 /**
@@ -2240,23 +2240,23 @@  discard block
 block discarded – undo
2240 2240
  */
2241 2241
 function is_page_geodir_home()
2242 2242
 {
2243
-    global $wpdb;
2244
-    $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2245
-    if (function_exists('geodir_location_geo_home_link')) {
2246
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2247
-    }
2248
-    $home_url = home_url('', 'http');
2249
-    if (function_exists('geodir_location_geo_home_link')) {
2250
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2251
-    }
2252
-    $home_url = str_replace("www.", "", $home_url);
2253
-    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')) ) {
2254
-        return true;
2255
-    }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')){
2256
-        return true;
2257
-    } else {
2258
-        return false;
2259
-    }
2243
+	global $wpdb;
2244
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2245
+	if (function_exists('geodir_location_geo_home_link')) {
2246
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2247
+	}
2248
+	$home_url = home_url('', 'http');
2249
+	if (function_exists('geodir_location_geo_home_link')) {
2250
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2251
+	}
2252
+	$home_url = str_replace("www.", "", $home_url);
2253
+	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')) ) {
2254
+		return true;
2255
+	}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')){
2256
+		return true;
2257
+	} else {
2258
+		return false;
2259
+	}
2260 2260
 
2261 2261
 }
2262 2262
 
@@ -2272,13 +2272,13 @@  discard block
 block discarded – undo
2272 2272
  */
2273 2273
 function geodir_wpseo_homepage_canonical($url)
2274 2274
 {
2275
-    global $post;
2275
+	global $post;
2276 2276
 
2277
-    if (is_page_geodir_home()) {
2278
-        return home_url();
2279
-    }
2277
+	if (is_page_geodir_home()) {
2278
+		return home_url();
2279
+	}
2280 2280
 
2281
-    return $url;
2281
+	return $url;
2282 2282
 }
2283 2283
 
2284 2284
 add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
@@ -2295,16 +2295,16 @@  discard block
 block discarded – undo
2295 2295
  */
2296 2296
 function geodir_googlemap_script_extra_details_page($extra)
2297 2297
 {
2298
-    global $post;
2299
-    $add_google_places_api = false;
2300
-    if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2301
-        $add_google_places_api = true;
2302
-    }
2303
-    if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2304
-        $extra .= "&amp;libraries=places";
2305
-    }
2306
-
2307
-    return $extra;
2298
+	global $post;
2299
+	$add_google_places_api = false;
2300
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2301
+		$add_google_places_api = true;
2302
+	}
2303
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2304
+		$extra .= "&amp;libraries=places";
2305
+	}
2306
+
2307
+	return $extra;
2308 2308
 }
2309 2309
 
2310 2310
 add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
@@ -2324,91 +2324,91 @@  discard block
 block discarded – undo
2324 2324
  */
2325 2325
 function geodir_popular_post_category_output($args = '', $instance = '')
2326 2326
 {
2327
-    // prints the widget
2328
-    global $wpdb, $plugin_prefix, $geodir_post_category_str;
2329
-    extract($args, EXTR_SKIP);
2327
+	// prints the widget
2328
+	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2329
+	extract($args, EXTR_SKIP);
2330 2330
 
2331
-    echo $before_widget;
2331
+	echo $before_widget;
2332 2332
 
2333
-    /** This filter is documented in geodirectory_widgets.php */
2334
-    $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2333
+	/** This filter is documented in geodirectory_widgets.php */
2334
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2335 2335
 
2336
-    $gd_post_type = geodir_get_current_posttype();
2336
+	$gd_post_type = geodir_get_current_posttype();
2337 2337
 
2338
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2339
-    $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'] : '');
2338
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2339
+	$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'] : '');
2340 2340
 
2341
-    $taxonomy = array();
2342
-    if (!empty($gd_post_type)) {
2343
-        $taxonomy[] = $gd_post_type . "category";
2344
-    } else {
2345
-        $taxonomy = geodir_get_taxonomies($gd_post_type);
2346
-    }
2341
+	$taxonomy = array();
2342
+	if (!empty($gd_post_type)) {
2343
+		$taxonomy[] = $gd_post_type . "category";
2344
+	} else {
2345
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2346
+	}
2347 2347
 
2348
-    $terms = get_terms($taxonomy);
2349
-    $a_terms = array();
2350
-    $b_terms = array();
2348
+	$terms = get_terms($taxonomy);
2349
+	$a_terms = array();
2350
+	$b_terms = array();
2351 2351
 
2352
-    foreach ($terms as $term) {
2353
-        if ($term->count > 0) {
2354
-            $a_terms[$term->taxonomy][] = $term;
2355
-        }
2356
-    }
2352
+	foreach ($terms as $term) {
2353
+		if ($term->count > 0) {
2354
+			$a_terms[$term->taxonomy][] = $term;
2355
+		}
2356
+	}
2357 2357
 
2358
-    if (!empty($a_terms)) {
2359
-        foreach ($a_terms as $b_key => $b_val) {
2360
-            $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2361
-        }
2358
+	if (!empty($a_terms)) {
2359
+		foreach ($a_terms as $b_key => $b_val) {
2360
+			$b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2361
+		}
2362 2362
 
2363
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2364
-
2365
-        $tax_change_output = '';
2366
-        if (count($b_terms) > 1) {
2367
-            $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2368
-            foreach ($b_terms as $key => $val) {
2369
-                $ptype = get_post_type_object(str_replace("category", "", $key));
2370
-                $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2371
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2372
-            }
2373
-            $tax_change_output .= "</select>";
2374
-        }
2363
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2364
+
2365
+		$tax_change_output = '';
2366
+		if (count($b_terms) > 1) {
2367
+			$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2368
+			foreach ($b_terms as $key => $val) {
2369
+				$ptype = get_post_type_object(str_replace("category", "", $key));
2370
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2371
+				$tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2372
+			}
2373
+			$tax_change_output .= "</select>";
2374
+		}
2375 2375
 
2376
-        if (!empty($b_terms)) {
2377
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2378
-            global $cat_count;//make global so we can change via function
2379
-            $cat_count = 0;
2380
-            ?>
2376
+		if (!empty($b_terms)) {
2377
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2378
+			global $cat_count;//make global so we can change via function
2379
+			$cat_count = 0;
2380
+			?>
2381 2381
             <div class="geodir-category-list-in clearfix">
2382 2382
                 <div class="geodir-cat-list clearfix">
2383 2383
                     <?php
2384
-                    echo $before_title . __($title) . $after_title;
2384
+					echo $before_title . __($title) . $after_title;
2385 2385
 
2386
-                    echo $tax_change_output;
2386
+					echo $tax_change_output;
2387 2387
 
2388
-                    echo '<ul class="geodir-popular-cat-list">';
2388
+					echo '<ul class="geodir-popular-cat-list">';
2389 2389
 
2390
-                    geodir_helper_cat_list_output($terms, $category_limit);
2390
+					geodir_helper_cat_list_output($terms, $category_limit);
2391 2391
 
2392
-                    echo '</ul>';
2393
-                    ?>
2392
+					echo '</ul>';
2393
+					?>
2394 2394
                 </div>
2395 2395
                 <?php
2396
-                $hide = '';
2397
-                if ($cat_count < $category_limit) {
2398
-                    $hide = 'style="display:none;"';
2399
-                }
2400
-                echo "<div class='geodir-cat-list-more' $hide >";
2401
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2402
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2403
-                echo "</div>";
2404
-                /* add scripts */
2405
-                add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2406
-                ?>
2396
+				$hide = '';
2397
+				if ($cat_count < $category_limit) {
2398
+					$hide = 'style="display:none;"';
2399
+				}
2400
+				echo "<div class='geodir-cat-list-more' $hide >";
2401
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2402
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2403
+				echo "</div>";
2404
+				/* add scripts */
2405
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2406
+				?>
2407 2407
             </div>
2408 2408
         <?php
2409
-        }
2410
-    }
2411
-    echo $after_widget;
2409
+		}
2410
+	}
2411
+	echo $after_widget;
2412 2412
 }
2413 2413
 
2414 2414
 /**
@@ -2422,38 +2422,38 @@  discard block
 block discarded – undo
2422 2422
  */
2423 2423
 function geodir_helper_cat_list_output($terms, $category_limit)
2424 2424
 {
2425
-    global $geodir_post_category_str, $cat_count;
2426
-    $term_icons = geodir_get_term_icon();
2425
+	global $geodir_post_category_str, $cat_count;
2426
+	$term_icons = geodir_get_term_icon();
2427 2427
 
2428
-    $geodir_post_category_str = array();
2428
+	$geodir_post_category_str = array();
2429 2429
 
2430 2430
 
2431
-    foreach ($terms as $cat) {
2432
-        $post_type = str_replace("category", "", $cat->taxonomy);
2433
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2431
+	foreach ($terms as $cat) {
2432
+		$post_type = str_replace("category", "", $cat->taxonomy);
2433
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2434 2434
 
2435
-        $cat_count++;
2435
+		$cat_count++;
2436 2436
 
2437
-        $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2437
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2438 2438
 
2439
-        $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2440
-        $total_post = $cat->count;
2439
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2440
+		$total_post = $cat->count;
2441 2441
 
2442
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2443
-        /**
2444
-         * Filer the category term link.
2445
-         *
2446
-         * @since 1.4.5
2447
-         * @param string $term_link The term permalink.
2448
-         * @param int    $cat->term_id The term id.
2449
-         * @param string $post_type Wordpress post type.
2450
-         */
2451
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2442
+		$term_link = get_term_link( $cat, $cat->taxonomy );
2443
+		/**
2444
+		 * Filer the category term link.
2445
+		 *
2446
+		 * @since 1.4.5
2447
+		 * @param string $term_link The term permalink.
2448
+		 * @param int    $cat->term_id The term id.
2449
+		 * @param string $post_type Wordpress post type.
2450
+		 */
2451
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2452 2452
 
2453
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2454
-        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> ';
2455
-        echo '</a></li>';
2456
-    }
2453
+		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2454
+		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> ';
2455
+		echo '</a></li>';
2456
+	}
2457 2457
 }
2458 2458
 
2459 2459
 /**
@@ -2467,108 +2467,108 @@  discard block
 block discarded – undo
2467 2467
  */
2468 2468
 function geodir_listing_slider_widget_output($args = '', $instance = '')
2469 2469
 {
2470
-    // prints the widget
2471
-    extract($args, EXTR_SKIP);
2472
-
2473
-    echo $before_widget;
2474
-
2475
-    /** This filter is documented in geodirectory_widgets.php */
2476
-    $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2477
-    /**
2478
-     * Filter the widget post type.
2479
-     *
2480
-     * @since 1.0.0
2481
-     * @param string $instance['post_type'] Post type of listing.
2482
-     */
2483
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2484
-    /**
2485
-     * Filter the widget's term.
2486
-     *
2487
-     * @since 1.0.0
2488
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2489
-     */
2490
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2491
-    /**
2492
-     * Filter the widget listings limit.
2493
-     *
2494
-     * @since 1.0.0
2495
-     * @param string $instance['post_number'] Number of listings to display.
2496
-     */
2497
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2498
-    /**
2499
-     * Filter the widget listings limit shown at one time.
2500
-     *
2501
-     * @since 1.5.0
2502
-     * @param string $instance['max_show'] Number of listings to display on screen.
2503
-     */
2504
-    $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2505
-    /**
2506
-     * Filter the widget slide width.
2507
-     *
2508
-     * @since 1.5.0
2509
-     * @param string $instance['slide_width'] Width of the slides shown.
2510
-     */
2511
-    $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2512
-    /**
2513
-     * Filter widget's "show title" value.
2514
-     *
2515
-     * @since 1.0.0
2516
-     * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2517
-     */
2518
-    $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2519
-    /**
2520
-     * Filter widget's "slideshow" value.
2521
-     *
2522
-     * @since 1.0.0
2523
-     * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2524
-     */
2525
-    $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2526
-    /**
2527
-     * Filter widget's "animationLoop" value.
2528
-     *
2529
-     * @since 1.0.0
2530
-     * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2531
-     */
2532
-    $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2533
-    /**
2534
-     * Filter widget's "directionNav" value.
2535
-     *
2536
-     * @since 1.0.0
2537
-     * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2538
-     */
2539
-    $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2540
-    /**
2541
-     * Filter widget's "slideshowSpeed" value.
2542
-     *
2543
-     * @since 1.0.0
2544
-     * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2545
-     */
2546
-    $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2547
-    /**
2548
-     * Filter widget's "animationSpeed" value.
2549
-     *
2550
-     * @since 1.0.0
2551
-     * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2552
-     */
2553
-    $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2554
-    /**
2555
-     * Filter widget's "animation" value.
2556
-     *
2557
-     * @since 1.0.0
2558
-     * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2559
-     */
2560
-    $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2561
-    /**
2562
-     * Filter widget's "list_sort" type.
2563
-     *
2564
-     * @since 1.0.0
2565
-     * @param string $instance['list_sort'] Listing sort by type.
2566
-     */
2567
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2568
-    $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2569
-
2570
-    wp_enqueue_script('geodirectory-jquery-flexslider-js');
2571
-    ?>
2470
+	// prints the widget
2471
+	extract($args, EXTR_SKIP);
2472
+
2473
+	echo $before_widget;
2474
+
2475
+	/** This filter is documented in geodirectory_widgets.php */
2476
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2477
+	/**
2478
+	 * Filter the widget post type.
2479
+	 *
2480
+	 * @since 1.0.0
2481
+	 * @param string $instance['post_type'] Post type of listing.
2482
+	 */
2483
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2484
+	/**
2485
+	 * Filter the widget's term.
2486
+	 *
2487
+	 * @since 1.0.0
2488
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2489
+	 */
2490
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2491
+	/**
2492
+	 * Filter the widget listings limit.
2493
+	 *
2494
+	 * @since 1.0.0
2495
+	 * @param string $instance['post_number'] Number of listings to display.
2496
+	 */
2497
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2498
+	/**
2499
+	 * Filter the widget listings limit shown at one time.
2500
+	 *
2501
+	 * @since 1.5.0
2502
+	 * @param string $instance['max_show'] Number of listings to display on screen.
2503
+	 */
2504
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2505
+	/**
2506
+	 * Filter the widget slide width.
2507
+	 *
2508
+	 * @since 1.5.0
2509
+	 * @param string $instance['slide_width'] Width of the slides shown.
2510
+	 */
2511
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2512
+	/**
2513
+	 * Filter widget's "show title" value.
2514
+	 *
2515
+	 * @since 1.0.0
2516
+	 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2517
+	 */
2518
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2519
+	/**
2520
+	 * Filter widget's "slideshow" value.
2521
+	 *
2522
+	 * @since 1.0.0
2523
+	 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2524
+	 */
2525
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2526
+	/**
2527
+	 * Filter widget's "animationLoop" value.
2528
+	 *
2529
+	 * @since 1.0.0
2530
+	 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2531
+	 */
2532
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2533
+	/**
2534
+	 * Filter widget's "directionNav" value.
2535
+	 *
2536
+	 * @since 1.0.0
2537
+	 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2538
+	 */
2539
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2540
+	/**
2541
+	 * Filter widget's "slideshowSpeed" value.
2542
+	 *
2543
+	 * @since 1.0.0
2544
+	 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2545
+	 */
2546
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2547
+	/**
2548
+	 * Filter widget's "animationSpeed" value.
2549
+	 *
2550
+	 * @since 1.0.0
2551
+	 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2552
+	 */
2553
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2554
+	/**
2555
+	 * Filter widget's "animation" value.
2556
+	 *
2557
+	 * @since 1.0.0
2558
+	 * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2559
+	 */
2560
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2561
+	/**
2562
+	 * Filter widget's "list_sort" type.
2563
+	 *
2564
+	 * @since 1.0.0
2565
+	 * @param string $instance['list_sort'] Listing sort by type.
2566
+	 */
2567
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2568
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2569
+
2570
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
2571
+	?>
2572 2572
     <script type="text/javascript">
2573 2573
         jQuery(window).load(function () {
2574 2574
             jQuery('#geodir_widget_carousel').flexslider({
@@ -2608,73 +2608,73 @@  discard block
 block discarded – undo
2608 2608
         });
2609 2609
     </script>
2610 2610
     <?php
2611
-    $query_args = array(
2612
-        'posts_per_page' => $post_number,
2613
-        'is_geodir_loop' => true,
2614
-        'post_type' => $post_type,
2615
-        'order_by' => $list_sort
2616
-    );
2617
-    if ($show_featured_only) {
2618
-        $query_args['show_featured_only'] = 1;
2619
-    }
2620
-
2621
-    if ($category != 0 || $category != '') {
2622
-        $category_taxonomy = geodir_get_taxonomies($post_type);
2623
-        $tax_query = array(
2624
-            'taxonomy' => $category_taxonomy[0],
2625
-            'field' => 'id',
2626
-            'terms' => $category
2627
-        );
2628
-
2629
-        $query_args['tax_query'] = array($tax_query);
2630
-    }
2631
-
2632
-    // we want listings with featured image only
2633
-    $query_args['featured_image_only'] = 1;
2634
-
2635
-    if ($post_type == 'gd_event') {
2636
-        $query_args['gedir_event_listing_filter'] = 'upcoming';
2637
-    }// show only upcomming events
2638
-
2639
-    $widget_listings = geodir_get_widget_listings($query_args);
2640
-    if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2641
-        if ($title) {
2642
-            echo $before_title . $title . $after_title;
2643
-        }
2611
+	$query_args = array(
2612
+		'posts_per_page' => $post_number,
2613
+		'is_geodir_loop' => true,
2614
+		'post_type' => $post_type,
2615
+		'order_by' => $list_sort
2616
+	);
2617
+	if ($show_featured_only) {
2618
+		$query_args['show_featured_only'] = 1;
2619
+	}
2644 2620
 
2645
-        global $post;
2621
+	if ($category != 0 || $category != '') {
2622
+		$category_taxonomy = geodir_get_taxonomies($post_type);
2623
+		$tax_query = array(
2624
+			'taxonomy' => $category_taxonomy[0],
2625
+			'field' => 'id',
2626
+			'terms' => $category
2627
+		);
2646 2628
 
2647
-        $current_post = $post;// keep current post info
2629
+		$query_args['tax_query'] = array($tax_query);
2630
+	}
2648 2631
 
2649
-        $widget_main_slides = '';
2650
-        $nav_slides = '';
2651
-        $widget_slides = 0;
2632
+	// we want listings with featured image only
2633
+	$query_args['featured_image_only'] = 1;
2652 2634
 
2653
-        foreach ($widget_listings as $widget_listing) {
2654
-            global $gd_widget_listing_type;
2655
-            $post = $widget_listing;
2656
-            $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2635
+	if ($post_type == 'gd_event') {
2636
+		$query_args['gedir_event_listing_filter'] = 'upcoming';
2637
+	}// show only upcomming events
2657 2638
 
2658
-            if (!empty($widget_image)) {
2659
-                if ($widget_image->height >= 200) {
2660
-                    $widget_spacer_height = 0;
2661
-                } else {
2662
-                    $widget_spacer_height = ((200 - $widget_image->height) / 2);
2663
-                }
2639
+	$widget_listings = geodir_get_widget_listings($query_args);
2640
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2641
+		if ($title) {
2642
+			echo $before_title . $title . $after_title;
2643
+		}
2664 2644
 
2665
-                $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" />';
2645
+		global $post;
2666 2646
 
2667
-                $title = '';
2668
-                if ($show_title) {
2669
-                    $title = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2670
-                }
2647
+		$current_post = $post;// keep current post info
2671 2648
 
2672
-                $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>';
2673
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2674
-                $widget_slides++;
2675
-            }
2676
-        }
2677
-        ?>
2649
+		$widget_main_slides = '';
2650
+		$nav_slides = '';
2651
+		$widget_slides = 0;
2652
+
2653
+		foreach ($widget_listings as $widget_listing) {
2654
+			global $gd_widget_listing_type;
2655
+			$post = $widget_listing;
2656
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2657
+
2658
+			if (!empty($widget_image)) {
2659
+				if ($widget_image->height >= 200) {
2660
+					$widget_spacer_height = 0;
2661
+				} else {
2662
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
2663
+				}
2664
+
2665
+				$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" />';
2666
+
2667
+				$title = '';
2668
+				if ($show_title) {
2669
+					$title = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2670
+				}
2671
+
2672
+				$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>';
2673
+				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2674
+				$widget_slides++;
2675
+			}
2676
+		}
2677
+		?>
2678 2678
         <div class="flex-container" style="min-height:200px;">
2679 2679
             <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
2680 2680
             <div id="geodir_widget_slider" class="geodir_flexslider">
@@ -2687,10 +2687,10 @@  discard block
 block discarded – undo
2687 2687
             <?php } ?>
2688 2688
         </div>
2689 2689
         <?php
2690
-        $GLOBALS['post'] = $current_post;
2691
-        setup_postdata($current_post);
2692
-    }
2693
-    echo $after_widget;
2690
+		$GLOBALS['post'] = $current_post;
2691
+		setup_postdata($current_post);
2692
+	}
2693
+	echo $after_widget;
2694 2694
 }
2695 2695
 
2696 2696
 
@@ -2705,68 +2705,68 @@  discard block
 block discarded – undo
2705 2705
  */
2706 2706
 function geodir_loginwidget_output($args = '', $instance = '')
2707 2707
 {
2708
-    //print_r($args);
2709
-    //print_r($instance);
2710
-    // prints the widget
2711
-    extract($args, EXTR_SKIP);
2708
+	//print_r($args);
2709
+	//print_r($instance);
2710
+	// prints the widget
2711
+	extract($args, EXTR_SKIP);
2712 2712
 
2713
-    /** This filter is documented in geodirectory_widgets.php */
2714
-    $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2713
+	/** This filter is documented in geodirectory_widgets.php */
2714
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2715 2715
 
2716
-    echo $before_widget;
2717
-    echo $before_title . $title . $after_title;
2716
+	echo $before_widget;
2717
+	echo $before_title . $title . $after_title;
2718 2718
 
2719
-    if (is_user_logged_in()) {
2720
-        global $current_user;
2719
+	if (is_user_logged_in()) {
2720
+		global $current_user;
2721 2721
 
2722
-        $login_url = geodir_login_url();
2723
-        $add_listurl = get_permalink(geodir_add_listing_page_id());
2724
-        $add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place'));
2725
-        $author_link = get_author_posts_url($current_user->data->ID);
2726
-        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2722
+		$login_url = geodir_login_url();
2723
+		$add_listurl = get_permalink(geodir_add_listing_page_id());
2724
+		$add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place'));
2725
+		$author_link = get_author_posts_url($current_user->data->ID);
2726
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2727 2727
 
2728
-        echo '<ul class="geodir-loginbox-list">';
2729
-        ob_start();
2730
-        ?>
2728
+		echo '<ul class="geodir-loginbox-list">';
2729
+		ob_start();
2730
+		?>
2731 2731
         <li><a class="signin"
2732 2732
                href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
2733 2733
         <?php
2734
-        $post_types = geodir_get_posttypes('object');
2735
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2736
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2734
+		$post_types = geodir_get_posttypes('object');
2735
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2736
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2737 2737
 
2738
-        if (!empty($show_add_listing_post_types_main_nav)) {
2739
-            $addlisting_links = '';
2740
-            foreach ($post_types as $key => $postobj) {
2738
+		if (!empty($show_add_listing_post_types_main_nav)) {
2739
+			$addlisting_links = '';
2740
+			foreach ($post_types as $key => $postobj) {
2741 2741
 
2742
-                if (in_array($key, $show_add_listing_post_types_main_nav)) {
2742
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
2743 2743
 
2744
-                    if ($add_link = geodir_get_addlisting_link($key)) {
2744
+					if ($add_link = geodir_get_addlisting_link($key)) {
2745 2745
 
2746
-                        $name = $postobj->labels->name;
2746
+						$name = $postobj->labels->name;
2747 2747
 
2748
-                        $selected = '';
2749
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2750
-                            $selected = 'selected="selected"';
2748
+						$selected = '';
2749
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2750
+							$selected = 'selected="selected"';
2751 2751
 
2752
-                        /**
2753
-                         * Filter add listing link.
2754
-                         *
2755
-                         * @since 1.0.0
2756
-                         * @param string $add_link Add listing link.
2757
-                         * @param string $key Add listing array key.
2758
-                         * @param int $current_user->ID Current user ID.
2759
-                         */
2760
-                        $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2752
+						/**
2753
+						 * Filter add listing link.
2754
+						 *
2755
+						 * @since 1.0.0
2756
+						 * @param string $add_link Add listing link.
2757
+						 * @param string $key Add listing array key.
2758
+						 * @param int $current_user->ID Current user ID.
2759
+						 */
2760
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2761 2761
 
2762
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2762
+						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2763 2763
 
2764
-                    }
2765
-                }
2764
+					}
2765
+				}
2766 2766
 
2767
-            }
2767
+			}
2768 2768
 
2769
-            if ($addlisting_links != '') { ?>
2769
+			if ($addlisting_links != '') { ?>
2770 2770
 
2771 2771
                 <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
2772 2772
                             option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
@@ -2775,42 +2775,42 @@  discard block
 block discarded – undo
2775 2775
                         <?php echo $addlisting_links; ?>
2776 2776
                     </select></li> <?php
2777 2777
 
2778
-            }
2778
+			}
2779
+
2780
+		}
2781
+		// My Favourites in Dashboard
2782
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2783
+		$user_favourite = geodir_user_favourite_listing_count();
2779 2784
 
2780
-        }
2781
-        // My Favourites in Dashboard
2782
-        $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2783
-        $user_favourite = geodir_user_favourite_listing_count();
2784
-
2785
-        if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2786
-            $favourite_links = '';
2787
-
2788
-            foreach ($post_types as $key => $postobj) {
2789
-                if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2790
-                    $name = $postobj->labels->name;
2791
-                    $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2792
-
2793
-                    $selected = '';
2794
-
2795
-                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2796
-                        $selected = 'selected="selected"';
2797
-                    }
2798
-                    /**
2799
-                     * Filter favorite listing link.
2800
-                     *
2801
-                     * @since 1.0.0
2802
-                     * @param string $post_type_link Favorite listing link.
2803
-                     * @param string $key Favorite listing array key.
2804
-                     * @param int $current_user->ID Current user ID.
2805
-                     */
2806
-                    $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2807
-
2808
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2809
-                }
2810
-            }
2811
-
2812
-            if ($favourite_links != '') {
2813
-                ?>
2785
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2786
+			$favourite_links = '';
2787
+
2788
+			foreach ($post_types as $key => $postobj) {
2789
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2790
+					$name = $postobj->labels->name;
2791
+					$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2792
+
2793
+					$selected = '';
2794
+
2795
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2796
+						$selected = 'selected="selected"';
2797
+					}
2798
+					/**
2799
+					 * Filter favorite listing link.
2800
+					 *
2801
+					 * @since 1.0.0
2802
+					 * @param string $post_type_link Favorite listing link.
2803
+					 * @param string $key Favorite listing array key.
2804
+					 * @param int $current_user->ID Current user ID.
2805
+					 */
2806
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2807
+
2808
+					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2809
+				}
2810
+			}
2811
+
2812
+			if ($favourite_links != '') {
2813
+				?>
2814 2814
                 <li>
2815 2815
                     <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
2816 2816
                             option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
@@ -2820,42 +2820,42 @@  discard block
 block discarded – undo
2820 2820
                     </select>
2821 2821
                 </li>
2822 2822
             <?php
2823
-            }
2824
-        }
2825
-
2823
+			}
2824
+		}
2826 2825
 
2827
-        $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2828
-        $user_listing = geodir_user_post_listing_count();
2829 2826
 
2830
-        if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2831
-            $listing_links = '';
2827
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2828
+		$user_listing = geodir_user_post_listing_count();
2832 2829
 
2833
-            foreach ($post_types as $key => $postobj) {
2834
-                if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2835
-                    $name = $postobj->labels->name;
2836
-                    $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2830
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2831
+			$listing_links = '';
2837 2832
 
2838
-                    $selected = '';
2839
-                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2840
-                        $selected = 'selected="selected"';
2841
-                    }
2833
+			foreach ($post_types as $key => $postobj) {
2834
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2835
+					$name = $postobj->labels->name;
2836
+					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2842 2837
 
2843
-                    /**
2844
-                     * Filter my listing link.
2845
-                     *
2846
-                     * @since 1.0.0
2847
-                     * @param string $listing_link My listing link.
2848
-                     * @param string $key My listing array key.
2849
-                     * @param int $current_user->ID Current user ID.
2850
-                     */
2851
-                    $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2838
+					$selected = '';
2839
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2840
+						$selected = 'selected="selected"';
2841
+					}
2852 2842
 
2853
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2854
-                }
2855
-            }
2843
+					/**
2844
+					 * Filter my listing link.
2845
+					 *
2846
+					 * @since 1.0.0
2847
+					 * @param string $listing_link My listing link.
2848
+					 * @param string $key My listing array key.
2849
+					 * @param int $current_user->ID Current user ID.
2850
+					 */
2851
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2852
+
2853
+					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2854
+				}
2855
+			}
2856 2856
 
2857
-            if ($listing_links != '') {
2858
-                ?>
2857
+			if ($listing_links != '') {
2858
+				?>
2859 2859
                 <li>
2860 2860
                     <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
2861 2861
                             option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
@@ -2865,27 +2865,27 @@  discard block
 block discarded – undo
2865 2865
                     </select>
2866 2866
                 </li>
2867 2867
             <?php
2868
-            }
2869
-        }
2868
+			}
2869
+		}
2870 2870
 
2871
-        $dashboard_link = ob_get_clean();
2872
-        /**
2873
-         * Filter dashboard links HTML.
2874
-         *
2875
-         * @since 1.0.0
2876
-         * @param string $dashboard_link Dashboard links HTML.
2877
-         */
2878
-        echo apply_filters('geodir_dashboard_links', $dashboard_link);
2879
-        echo '</ul>';
2880
-    } else {
2881
-        ?>
2871
+		$dashboard_link = ob_get_clean();
2872
+		/**
2873
+		 * Filter dashboard links HTML.
2874
+		 *
2875
+		 * @since 1.0.0
2876
+		 * @param string $dashboard_link Dashboard links HTML.
2877
+		 */
2878
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
2879
+		echo '</ul>';
2880
+	} else {
2881
+		?>
2882 2882
         <?php
2883
-        /**
2884
-         * Filter signup form action link.
2885
-         *
2886
-         * @since 1.0.0
2887
-         */
2888
-        ?>
2883
+		/**
2884
+		 * Filter signup form action link.
2885
+		 *
2886
+		 * @since 1.0.0
2887
+		 */
2888
+		?>
2889 2889
         <form name="loginform" class="loginform1"
2890 2890
               action="<?php echo geodir_login_url(); ?>"
2891 2891
               method="post">
@@ -2905,28 +2905,28 @@  discard block
 block discarded – undo
2905 2905
 
2906 2906
                 <p class="geodir-new-forgot-link">
2907 2907
                     <?php
2908
-                    /**
2909
-                     * Filter signup page register form link.
2910
-                     *
2911
-                     * @since 1.0.0
2912
-                     */
2913
-                    ?>
2908
+					/**
2909
+					 * Filter signup page register form link.
2910
+					 *
2911
+					 * @since 1.0.0
2912
+					 */
2913
+					?>
2914 2914
                     <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
2915 2915
                        class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
2916 2916
 
2917 2917
                     <?php
2918
-                    /**
2919
-                     * Filter signup page forgot password form link.
2920
-                     *
2921
-                     * @since 1.0.0
2922
-                     */
2923
-                    ?>
2918
+					/**
2919
+					 * Filter signup page forgot password form link.
2920
+					 *
2921
+					 * @since 1.0.0
2922
+					 */
2923
+					?>
2924 2924
                     <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
2925 2925
                        class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
2926 2926
         </form>
2927 2927
     <?php }
2928 2928
 
2929
-    echo $after_widget;
2929
+	echo $after_widget;
2930 2930
 }
2931 2931
 
2932 2932
 
@@ -2945,284 +2945,284 @@  discard block
 block discarded – undo
2945 2945
  * @param array|string $instance The settings for the particular instance of the widget.
2946 2946
  */
2947 2947
 function geodir_popular_postview_output($args = '', $instance = '') {
2948
-    global $gd_session;
2948
+	global $gd_session;
2949 2949
 	
2950
-    // prints the widget
2951
-    extract($args, EXTR_SKIP);
2952
-
2953
-    echo $before_widget;
2954
-
2955
-    /** This filter is documented in geodirectory_widgets.php */
2956
-    $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2957
-    /**
2958
-     * Filter the widget post type.
2959
-     *
2960
-     * @since 1.0.0
2961
-     * @param string $instance['post_type'] Post type of listing.
2962
-     */
2963
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2964
-    /**
2965
-     * Filter the widget's term.
2966
-     *
2967
-     * @since 1.0.0
2968
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2969
-     */
2970
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2971
-    /**
2972
-     * Filter the widget listings limit.
2973
-     *
2974
-     * @since 1.0.0
2975
-     * @param string $instance['post_number'] Number of listings to display.
2976
-     */
2977
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2978
-    /**
2979
-     * Filter widget's "layout" type.
2980
-     *
2981
-     * @since 1.0.0
2982
-     * @param string $instance['layout'] Widget layout type.
2983
-     */
2984
-    $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
2985
-    /**
2986
-     * Filter widget's "add_location_filter" value.
2987
-     *
2988
-     * @since 1.0.0
2989
-     * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
2990
-     */
2991
-    $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
2992
-    /**
2993
-     * Filter widget's listing width.
2994
-     *
2995
-     * @since 1.0.0
2996
-     * @param string $instance['listing_width'] Listing width.
2997
-     */
2998
-    $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
2999
-    /**
3000
-     * Filter widget's "list_sort" type.
3001
-     *
3002
-     * @since 1.0.0
3003
-     * @param string $instance['list_sort'] Listing sort by type.
3004
-     */
3005
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3006
-    $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3007
-
3008
-    // set post type to current viewing post type
3009
-    if ($use_viewing_post_type) {
3010
-        $current_post_type = geodir_get_current_posttype();
3011
-        if ($current_post_type != '' && $current_post_type != $post_type) {
3012
-            $post_type = $current_post_type;
3013
-            $category = array(); // old post type category will not work for current changed post type
3014
-        }
3015
-    }
3016
-    // replace widget title dynamically
3017
-    $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3018
-    $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3019
-
3020
-    $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3021
-    $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3022
-
3023
-    if (isset($instance['character_count'])) {
3024
-        /**
3025
-         * Filter the widget's excerpt character count.
3026
-         *
3027
-         * @since 1.0.0
3028
-         * @param int $instance['character_count'] Excerpt character count.
3029
-         */
3030
-        $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3031
-    } else {
3032
-        $character_count = '';
3033
-    }
3034
-
3035
-    if (empty($title) || $title == 'All') {
3036
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3037
-    }
3038
-
3039
-    $location_url = array();
3040
-    $city = get_query_var('gd_city');
3041
-    if (!empty($city)) {
3042
-        $country = get_query_var('gd_country');
3043
-        $region = get_query_var('gd_region');
3044
-
3045
-        $geodir_show_location_url = get_option('geodir_show_location_url');
3046
-
3047
-        if ($geodir_show_location_url == 'all') {
3048
-            if ($country != '') {
3049
-                $location_url[] = $country;
3050
-            }
3051
-
3052
-            if ($region != '') {
3053
-                $location_url[] = $region;
3054
-            }
3055
-        } else if ($geodir_show_location_url == 'country_city') {
3056
-            if ($country != '') {
3057
-                $location_url[] = $country;
3058
-            }
3059
-        } else if ($geodir_show_location_url == 'region_city') {
3060
-            if ($region != '') {
3061
-                $location_url[] = $region;
3062
-            }
3063
-        }
2950
+	// prints the widget
2951
+	extract($args, EXTR_SKIP);
2952
+
2953
+	echo $before_widget;
2954
+
2955
+	/** This filter is documented in geodirectory_widgets.php */
2956
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2957
+	/**
2958
+	 * Filter the widget post type.
2959
+	 *
2960
+	 * @since 1.0.0
2961
+	 * @param string $instance['post_type'] Post type of listing.
2962
+	 */
2963
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2964
+	/**
2965
+	 * Filter the widget's term.
2966
+	 *
2967
+	 * @since 1.0.0
2968
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2969
+	 */
2970
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2971
+	/**
2972
+	 * Filter the widget listings limit.
2973
+	 *
2974
+	 * @since 1.0.0
2975
+	 * @param string $instance['post_number'] Number of listings to display.
2976
+	 */
2977
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2978
+	/**
2979
+	 * Filter widget's "layout" type.
2980
+	 *
2981
+	 * @since 1.0.0
2982
+	 * @param string $instance['layout'] Widget layout type.
2983
+	 */
2984
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
2985
+	/**
2986
+	 * Filter widget's "add_location_filter" value.
2987
+	 *
2988
+	 * @since 1.0.0
2989
+	 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
2990
+	 */
2991
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
2992
+	/**
2993
+	 * Filter widget's listing width.
2994
+	 *
2995
+	 * @since 1.0.0
2996
+	 * @param string $instance['listing_width'] Listing width.
2997
+	 */
2998
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
2999
+	/**
3000
+	 * Filter widget's "list_sort" type.
3001
+	 *
3002
+	 * @since 1.0.0
3003
+	 * @param string $instance['list_sort'] Listing sort by type.
3004
+	 */
3005
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3006
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3007
+
3008
+	// set post type to current viewing post type
3009
+	if ($use_viewing_post_type) {
3010
+		$current_post_type = geodir_get_current_posttype();
3011
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3012
+			$post_type = $current_post_type;
3013
+			$category = array(); // old post type category will not work for current changed post type
3014
+		}
3015
+	}
3016
+	// replace widget title dynamically
3017
+	$posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3018
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3019
+
3020
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3021
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3022
+
3023
+	if (isset($instance['character_count'])) {
3024
+		/**
3025
+		 * Filter the widget's excerpt character count.
3026
+		 *
3027
+		 * @since 1.0.0
3028
+		 * @param int $instance['character_count'] Excerpt character count.
3029
+		 */
3030
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3031
+	} else {
3032
+		$character_count = '';
3033
+	}
3064 3034
 
3065
-        $location_url[] = $city;
3066
-    }
3035
+	if (empty($title) || $title == 'All') {
3036
+		$title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3037
+	}
3067 3038
 
3068
-    $location_url = implode('/', $location_url);
3069
-    $skip_location = false;
3070
-    if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3071
-        $skip_location = true;
3072
-        $gd_session->un_set('gd_multi_location');
3073
-    }
3039
+	$location_url = array();
3040
+	$city = get_query_var('gd_city');
3041
+	if (!empty($city)) {
3042
+		$country = get_query_var('gd_country');
3043
+		$region = get_query_var('gd_region');
3074 3044
 
3075
-    if (get_option('permalink_structure')) {
3076
-        $viewall_url = get_post_type_archive_link($post_type);
3077
-    } else {
3078
-        $viewall_url = get_post_type_archive_link($post_type);
3079
-    }
3045
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3080 3046
 
3081
-    if (!empty($category) && $category[0] != '0') {
3082
-        global $geodir_add_location_url;
3047
+		if ($geodir_show_location_url == 'all') {
3048
+			if ($country != '') {
3049
+				$location_url[] = $country;
3050
+			}
3083 3051
 
3084
-        $geodir_add_location_url = '0';
3052
+			if ($region != '') {
3053
+				$location_url[] = $region;
3054
+			}
3055
+		} else if ($geodir_show_location_url == 'country_city') {
3056
+			if ($country != '') {
3057
+				$location_url[] = $country;
3058
+			}
3059
+		} else if ($geodir_show_location_url == 'region_city') {
3060
+			if ($region != '') {
3061
+				$location_url[] = $region;
3062
+			}
3063
+		}
3085 3064
 
3086
-        if ($add_location_filter != '0') {
3087
-            $geodir_add_location_url = '1';
3088
-        }
3065
+		$location_url[] = $city;
3066
+	}
3089 3067
 
3090
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3068
+	$location_url = implode('/', $location_url);
3069
+	$skip_location = false;
3070
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3071
+		$skip_location = true;
3072
+		$gd_session->un_set('gd_multi_location');
3073
+	}
3074
+
3075
+	if (get_option('permalink_structure')) {
3076
+		$viewall_url = get_post_type_archive_link($post_type);
3077
+	} else {
3078
+		$viewall_url = get_post_type_archive_link($post_type);
3079
+	}
3091 3080
 
3092
-        $geodir_add_location_url = NULL;
3093
-    }
3094
-    if ($skip_location) {
3095
-        $gd_session->set('gd_multi_location', 1);
3096
-    }
3081
+	if (!empty($category) && $category[0] != '0') {
3082
+		global $geodir_add_location_url;
3097 3083
 
3098
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3084
+		$geodir_add_location_url = '0';
3085
+
3086
+		if ($add_location_filter != '0') {
3087
+			$geodir_add_location_url = '1';
3088
+		}
3099 3089
 
3100
-    $query_args = array(
3101
-        'posts_per_page' => $post_number,
3102
-        'is_geodir_loop' => true,
3103
-        'gd_location' => $add_location_filter ? true : false,
3104
-        'post_type' => $post_type,
3105
-        'order_by' => $list_sort
3106
-    );
3090
+		$viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3107 3091
 
3108
-    if ($character_count) {
3109
-        $query_args['excerpt_length'] = $character_count;
3110
-    }
3092
+		$geodir_add_location_url = NULL;
3093
+	}
3094
+	if ($skip_location) {
3095
+		$gd_session->set('gd_multi_location', 1);
3096
+	}
3111 3097
 
3112
-    if (!empty($instance['show_featured_only'])) {
3113
-        $query_args['show_featured_only'] = 1;
3114
-    }
3098
+	if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3115 3099
 
3116
-    if (!empty($instance['show_special_only'])) {
3117
-        $query_args['show_special_only'] = 1;
3118
-    }
3100
+	$query_args = array(
3101
+		'posts_per_page' => $post_number,
3102
+		'is_geodir_loop' => true,
3103
+		'gd_location' => $add_location_filter ? true : false,
3104
+		'post_type' => $post_type,
3105
+		'order_by' => $list_sort
3106
+	);
3119 3107
 
3120
-    if (!empty($instance['with_pics_only'])) {
3121
-        $query_args['with_pics_only'] = 0;
3122
-        $query_args['featured_image_only'] = 1;
3123
-    }
3108
+	if ($character_count) {
3109
+		$query_args['excerpt_length'] = $character_count;
3110
+	}
3124 3111
 
3125
-    if (!empty($instance['with_videos_only'])) {
3126
-        $query_args['with_videos_only'] = 1;
3127
-    }
3128
-    $with_no_results = !empty($instance['without_no_results']) ? false : true;
3112
+	if (!empty($instance['show_featured_only'])) {
3113
+		$query_args['show_featured_only'] = 1;
3114
+	}
3129 3115
 
3130
-    if (!empty($category) && $category[0] != '0') {
3131
-        $category_taxonomy = geodir_get_taxonomies($post_type);
3116
+	if (!empty($instance['show_special_only'])) {
3117
+		$query_args['show_special_only'] = 1;
3118
+	}
3132 3119
 
3133
-        ######### WPML #########
3134
-        if (function_exists('icl_object_id')) {
3135
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
3136
-        }
3137
-        ######### WPML #########
3120
+	if (!empty($instance['with_pics_only'])) {
3121
+		$query_args['with_pics_only'] = 0;
3122
+		$query_args['featured_image_only'] = 1;
3123
+	}
3138 3124
 
3139
-        $tax_query = array(
3140
-            'taxonomy' => $category_taxonomy[0],
3141
-            'field' => 'id',
3142
-            'terms' => $category
3143
-        );
3125
+	if (!empty($instance['with_videos_only'])) {
3126
+		$query_args['with_videos_only'] = 1;
3127
+	}
3128
+	$with_no_results = !empty($instance['without_no_results']) ? false : true;
3144 3129
 
3145
-        $query_args['tax_query'] = array($tax_query);
3146
-    }
3130
+	if (!empty($category) && $category[0] != '0') {
3131
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3147 3132
 
3148
-    global $gridview_columns_widget, $geodir_is_widget_listing;
3133
+		######### WPML #########
3134
+		if (function_exists('icl_object_id')) {
3135
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3136
+		}
3137
+		######### WPML #########
3149 3138
 
3150
-    $widget_listings = geodir_get_widget_listings($query_args);
3139
+		$tax_query = array(
3140
+			'taxonomy' => $category_taxonomy[0],
3141
+			'field' => 'id',
3142
+			'terms' => $category
3143
+		);
3151 3144
 
3152
-    if (!empty($widget_listings) || $with_no_results) {
3153
-        ?>
3145
+		$query_args['tax_query'] = array($tax_query);
3146
+	}
3147
+
3148
+	global $gridview_columns_widget, $geodir_is_widget_listing;
3149
+
3150
+	$widget_listings = geodir_get_widget_listings($query_args);
3151
+
3152
+	if (!empty($widget_listings) || $with_no_results) {
3153
+		?>
3154 3154
         <div class="geodir_locations geodir_location_listing">
3155 3155
 
3156 3156
             <?php
3157
-            /**
3158
-             * Called before the div containing the title and view all link in popular post view widget.
3159
-             *
3160
-             * @since 1.0.0
3161
-             */
3162
-            do_action('geodir_before_view_all_link_in_widget'); ?>
3157
+			/**
3158
+			 * Called before the div containing the title and view all link in popular post view widget.
3159
+			 *
3160
+			 * @since 1.0.0
3161
+			 */
3162
+			do_action('geodir_before_view_all_link_in_widget'); ?>
3163 3163
             <div class="geodir_list_heading clearfix">
3164 3164
                 <?php echo $before_title . $title . $after_title; ?>
3165 3165
                 <a href="<?php echo $viewall_url; ?>"
3166 3166
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3167 3167
             </div>
3168 3168
             <?php
3169
-            /**
3170
-             * Called after the div containing the title and view all link in popular post view widget.
3171
-             *
3172
-             * @since 1.0.0
3173
-             */
3174
-            do_action('geodir_after_view_all_link_in_widget'); ?>
3169
+			/**
3170
+			 * Called after the div containing the title and view all link in popular post view widget.
3171
+			 *
3172
+			 * @since 1.0.0
3173
+			 */
3174
+			do_action('geodir_after_view_all_link_in_widget'); ?>
3175 3175
             <?php
3176
-            if (strstr($layout, 'gridview')) {
3177
-                $listing_view_exp = explode('_', $layout);
3178
-                $gridview_columns_widget = $layout;
3179
-                $layout = $listing_view_exp[0];
3180
-            } else {
3181
-                $gridview_columns_widget = '';
3182
-            }
3183
-
3184
-            /**
3185
-             * Filter the widget listing listview template path.
3186
-             *
3187
-             * @since 1.0.0
3188
-             */
3189
-            $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3190
-            if (!isset($character_count)) {
3191
-                /**
3192
-                 * Filter the widget's excerpt character count.
3193
-                 *
3194
-                 * @since 1.0.0
3195
-                 * @param int $instance['character_count'] Excerpt character count.
3196
-                 */
3197
-                $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3198
-            }
3199
-
3200
-            global $post, $map_jason, $map_canvas_arr;
3201
-
3202
-            $current_post = $post;
3203
-            $current_map_jason = $map_jason;
3204
-            $current_map_canvas_arr = $map_canvas_arr;
3205
-            $geodir_is_widget_listing = true;
3206
-
3207
-            /**
3208
-             * Includes related listing listview template.
3209
-             *
3210
-             * @since 1.0.0
3211
-             */
3212
-            include($template);
3213
-
3214
-            $geodir_is_widget_listing = false;
3215
-
3216
-            $GLOBALS['post'] = $current_post;
3217
-            if (!empty($current_post))
3218
-                setup_postdata($current_post);
3219
-            $map_jason = $current_map_jason;
3220
-            $map_canvas_arr = $current_map_canvas_arr;
3221
-            ?>
3176
+			if (strstr($layout, 'gridview')) {
3177
+				$listing_view_exp = explode('_', $layout);
3178
+				$gridview_columns_widget = $layout;
3179
+				$layout = $listing_view_exp[0];
3180
+			} else {
3181
+				$gridview_columns_widget = '';
3182
+			}
3183
+
3184
+			/**
3185
+			 * Filter the widget listing listview template path.
3186
+			 *
3187
+			 * @since 1.0.0
3188
+			 */
3189
+			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3190
+			if (!isset($character_count)) {
3191
+				/**
3192
+				 * Filter the widget's excerpt character count.
3193
+				 *
3194
+				 * @since 1.0.0
3195
+				 * @param int $instance['character_count'] Excerpt character count.
3196
+				 */
3197
+				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3198
+			}
3199
+
3200
+			global $post, $map_jason, $map_canvas_arr;
3201
+
3202
+			$current_post = $post;
3203
+			$current_map_jason = $map_jason;
3204
+			$current_map_canvas_arr = $map_canvas_arr;
3205
+			$geodir_is_widget_listing = true;
3206
+
3207
+			/**
3208
+			 * Includes related listing listview template.
3209
+			 *
3210
+			 * @since 1.0.0
3211
+			 */
3212
+			include($template);
3213
+
3214
+			$geodir_is_widget_listing = false;
3215
+
3216
+			$GLOBALS['post'] = $current_post;
3217
+			if (!empty($current_post))
3218
+				setup_postdata($current_post);
3219
+			$map_jason = $current_map_jason;
3220
+			$map_canvas_arr = $current_map_canvas_arr;
3221
+			?>
3222 3222
         </div>
3223 3223
     <?php
3224
-    }
3225
-    echo $after_widget;
3224
+	}
3225
+	echo $after_widget;
3226 3226
 
3227 3227
 }
3228 3228
 
@@ -3245,26 +3245,26 @@  discard block
 block discarded – undo
3245 3245
  */
3246 3246
 function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type)
3247 3247
 {
3248
-    global $wpdb, $plugin_prefix;
3248
+	global $wpdb, $plugin_prefix;
3249 3249
 
3250
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3250
+	$detail_table = $plugin_prefix . $post_type . '_detail';
3251 3251
 
3252
-    $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 . ")";
3252
+	$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 . ")";
3253 3253
 
3254
-    /**
3255
-     * Filter count review sql query.
3256
-     *
3257
-     * @since 1.5.1
3258
-     * @param string $sql Database sql query..
3259
-     * @param int $term_id The term ID.
3260
-     * @param int $taxonomy The taxonomy Id.
3261
-     * @param string $post_type The post type.
3262
-     */
3263
-    $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3254
+	/**
3255
+	 * Filter count review sql query.
3256
+	 *
3257
+	 * @since 1.5.1
3258
+	 * @param string $sql Database sql query..
3259
+	 * @param int $term_id The term ID.
3260
+	 * @param int $taxonomy The taxonomy Id.
3261
+	 * @param string $post_type The post type.
3262
+	 */
3263
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3264 3264
 
3265
-    $count = $wpdb->get_var($sql);
3265
+	$count = $wpdb->get_var($sql);
3266 3266
 
3267
-    return $count;
3267
+	return $count;
3268 3268
 }
3269 3269
 
3270 3270
 /**
@@ -3277,53 +3277,53 @@  discard block
 block discarded – undo
3277 3277
  */
3278 3278
 function geodir_count_reviews_by_terms($force_update = false)
3279 3279
 {
3280
-    /**
3281
-     * Filter review count option data.
3282
-     *
3283
-     * @since 1.0.0
3284
-     * @param bool $force_update Force update option value?. Default.false.
3285
-     */
3286
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update);
3287
-    if (!empty($option_data)) {
3288
-        return $option_data;
3289
-    }
3280
+	/**
3281
+	 * Filter review count option data.
3282
+	 *
3283
+	 * @since 1.0.0
3284
+	 * @param bool $force_update Force update option value?. Default.false.
3285
+	 */
3286
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update);
3287
+	if (!empty($option_data)) {
3288
+		return $option_data;
3289
+	}
3290 3290
 
3291
-    $option_data = get_option('geodir_global_review_count');
3291
+	$option_data = get_option('geodir_global_review_count');
3292 3292
 
3293
-    if (!$option_data OR $force_update) {
3294
-        $post_types = geodir_get_posttypes();
3295
-        $term_array = array();
3296
-        foreach ($post_types as $post_type) {
3293
+	if (!$option_data OR $force_update) {
3294
+		$post_types = geodir_get_posttypes();
3295
+		$term_array = array();
3296
+		foreach ($post_types as $post_type) {
3297 3297
 
3298
-            $taxonomy = geodir_get_taxonomies($post_type);
3299
-            $taxonomy = $taxonomy[0];
3298
+			$taxonomy = geodir_get_taxonomies($post_type);
3299
+			$taxonomy = $taxonomy[0];
3300 3300
 
3301
-            $args = array(
3302
-                'hide_empty' => false
3303
-            );
3301
+			$args = array(
3302
+				'hide_empty' => false
3303
+			);
3304 3304
 
3305
-            $terms = get_terms($taxonomy, $args);
3305
+			$terms = get_terms($taxonomy, $args);
3306 3306
 
3307
-            foreach ($terms as $term) {
3308
-                $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3309
-                $children = get_term_children($term->term_id, $taxonomy);
3310
-                /*if ( is_array( $children ) ) {
3307
+			foreach ($terms as $term) {
3308
+				$count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3309
+				$children = get_term_children($term->term_id, $taxonomy);
3310
+				/*if ( is_array( $children ) ) {
3311 3311
 					foreach ( $children as $child_id ) {
3312 3312
 						$child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
3313 3313
 						$count = $count + $child_count;
3314 3314
 					}
3315 3315
 				}*/
3316
-                $term_array[$term->term_id] = $count;
3317
-            }
3318
-        }
3316
+				$term_array[$term->term_id] = $count;
3317
+			}
3318
+		}
3319 3319
 
3320
-        update_option('geodir_global_review_count', $term_array);
3321
-        //clear cache
3322
-        wp_cache_delete('geodir_global_review_count');
3323
-        return $term_array;
3324
-    } else {
3325
-        return $option_data;
3326
-    }
3320
+		update_option('geodir_global_review_count', $term_array);
3321
+		//clear cache
3322
+		wp_cache_delete('geodir_global_review_count');
3323
+		return $term_array;
3324
+	} else {
3325
+		return $option_data;
3326
+	}
3327 3327
 }
3328 3328
 
3329 3329
 /**
@@ -3335,15 +3335,15 @@  discard block
 block discarded – undo
3335 3335
  */
3336 3336
 function geodir_term_review_count_force_update($new_status, $old_status='', $post='')
3337 3337
 {
3338
-    if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
3339
-
3340
-    if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
3341
-        return;
3342
-    }
3343
-    if($new_status!=$old_status) {
3344
-        geodir_count_reviews_by_terms(true);
3345
-    }
3346
-    return true;
3338
+	if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
3339
+
3340
+	if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
3341
+		return;
3342
+	}
3343
+	if($new_status!=$old_status) {
3344
+		geodir_count_reviews_by_terms(true);
3345
+	}
3346
+	return true;
3347 3347
 }
3348 3348
 
3349 3349
 
@@ -3362,15 +3362,15 @@  discard block
 block discarded – undo
3362 3362
 function geodir_count_posts_by_term($data, $term)
3363 3363
 {
3364 3364
 
3365
-    if ($data) {
3366
-        if (isset($data[$term->term_id])) {
3367
-            return $data[$term->term_id];
3368
-        } else {
3369
-            return 0;
3370
-        }
3371
-    } else {
3372
-        return $term->count;
3373
-    }
3365
+	if ($data) {
3366
+		if (isset($data[$term->term_id])) {
3367
+			return $data[$term->term_id];
3368
+		} else {
3369
+			return 0;
3370
+		}
3371
+	} else {
3372
+		return $term->count;
3373
+	}
3374 3374
 }
3375 3375
 
3376 3376
 /**
@@ -3383,8 +3383,8 @@  discard block
 block discarded – undo
3383 3383
  */
3384 3384
 function geodir_sort_terms_by_count($terms)
3385 3385
 {
3386
-    usort($terms, "geodir_sort_by_count_obj");
3387
-    return $terms;
3386
+	usort($terms, "geodir_sort_by_count_obj");
3387
+	return $terms;
3388 3388
 }
3389 3389
 
3390 3390
 /**
@@ -3397,8 +3397,8 @@  discard block
 block discarded – undo
3397 3397
  */
3398 3398
 function geodir_sort_terms_by_review_count($terms)
3399 3399
 {
3400
-    usort($terms, "geodir_sort_by_review_count_obj");
3401
-    return $terms;
3400
+	usort($terms, "geodir_sort_by_review_count_obj");
3401
+	return $terms;
3402 3402
 }
3403 3403
 
3404 3404
 /**
@@ -3412,12 +3412,12 @@  discard block
 block discarded – undo
3412 3412
  */
3413 3413
 function geodir_sort_terms($terms, $sort = 'count')
3414 3414
 {
3415
-    if ($sort == 'count') {
3416
-        return geodir_sort_terms_by_count($terms);
3417
-    }
3418
-    if ($sort == 'review_count') {
3419
-        return geodir_sort_terms_by_review_count($terms);
3420
-    }
3415
+	if ($sort == 'count') {
3416
+		return geodir_sort_terms_by_count($terms);
3417
+	}
3418
+	if ($sort == 'review_count') {
3419
+		return geodir_sort_terms_by_review_count($terms);
3420
+	}
3421 3421
 }
3422 3422
 
3423 3423
 /*-----------------------------------------------------------------------------------*/
@@ -3434,7 +3434,7 @@  discard block
 block discarded – undo
3434 3434
  */
3435 3435
 function geodir_sort_by_count($a, $b)
3436 3436
 {
3437
-    return $a['count'] < $b['count'];
3437
+	return $a['count'] < $b['count'];
3438 3438
 }
3439 3439
 
3440 3440
 /**
@@ -3448,7 +3448,7 @@  discard block
 block discarded – undo
3448 3448
  */
3449 3449
 function geodir_sort_by_count_obj($a, $b)
3450 3450
 {
3451
-    return $a->count < $b->count;
3451
+	return $a->count < $b->count;
3452 3452
 }
3453 3453
 
3454 3454
 /**
@@ -3462,7 +3462,7 @@  discard block
 block discarded – undo
3462 3462
  */
3463 3463
 function geodir_sort_by_review_count_obj($a, $b)
3464 3464
 {
3465
-    return $a->review_count < $b->review_count;
3465
+	return $a->review_count < $b->review_count;
3466 3466
 }
3467 3467
 
3468 3468
 /**
@@ -3472,43 +3472,43 @@  discard block
 block discarded – undo
3472 3472
  * @package GeoDirectory
3473 3473
  */
3474 3474
 function geodir_load_textdomain() {
3475
-    /**
3476
-     * Filter the plugin locale.
3477
-     *
3478
-     * @since 1.4.2
3479
-     * @package GeoDirectory
3480
-     */
3481
-    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3482
-
3483
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3484
-    load_plugin_textdomain('geodirectory', false, dirname(plugin_basename(__FILE__)) . '/geodirectory-languages');
3475
+	/**
3476
+	 * Filter the plugin locale.
3477
+	 *
3478
+	 * @since 1.4.2
3479
+	 * @package GeoDirectory
3480
+	 */
3481
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3482
+
3483
+	load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3484
+	load_plugin_textdomain('geodirectory', false, dirname(plugin_basename(__FILE__)) . '/geodirectory-languages');
3485
+
3486
+	/**
3487
+	 * Define language constants.
3488
+	 *
3489
+	 * @since 1.0.0
3490
+	 */
3491
+	require_once(geodir_plugin_path() . '/language.php');
3492
+
3493
+	$language_file = geodir_plugin_path() . '/db-language.php';
3494
+
3495
+	// Load language string file if not created yet
3496
+	if (!file_exists($language_file)) {
3497
+		geodirectory_load_db_language();
3498
+	}
3485 3499
 
3486
-    /**
3487
-     * Define language constants.
3488
-     *
3489
-     * @since 1.0.0
3490
-     */
3491
-    require_once(geodir_plugin_path() . '/language.php');
3492
-
3493
-    $language_file = geodir_plugin_path() . '/db-language.php';
3494
-
3495
-    // Load language string file if not created yet
3496
-    if (!file_exists($language_file)) {
3497
-        geodirectory_load_db_language();
3498
-    }
3499
-
3500
-    if (file_exists($language_file)) {
3501
-        /**
3502
-         * Language strings from database.
3503
-         *
3504
-         * @since 1.4.2
3505
-         */
3506
-        try {
3507
-            require_once($language_file);
3508
-        } catch(Exception $e) {
3509
-            error_log('Language Error: ' . $e->getMessage());
3510
-        }
3511
-    }
3500
+	if (file_exists($language_file)) {
3501
+		/**
3502
+		 * Language strings from database.
3503
+		 *
3504
+		 * @since 1.4.2
3505
+		 */
3506
+		try {
3507
+			require_once($language_file);
3508
+		} catch(Exception $e) {
3509
+			error_log('Language Error: ' . $e->getMessage());
3510
+		}
3511
+	}
3512 3512
 }
3513 3513
 
3514 3514
 /**
@@ -3522,66 +3522,66 @@  discard block
 block discarded – undo
3522 3522
  * @return bool True if file created otherwise false
3523 3523
  */
3524 3524
 function geodirectory_load_db_language() {
3525
-    global $wp_filesystem;
3526
-    if( empty( $wp_filesystem ) ) {
3527
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3528
-        WP_Filesystem();
3529
-        global $wp_filesystem;
3530
-    }
3531
-
3532
-    $language_file = geodir_plugin_path() . '/db-language.php';
3533
-
3534
-    if(is_file($language_file) && !is_writable($language_file))
3535
-        return false; // Not possible to create.
3536
-
3537
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3538
-        return false; // Not possible to create.
3539
-
3540
-    $contents_strings = array();
3525
+	global $wp_filesystem;
3526
+	if( empty( $wp_filesystem ) ) {
3527
+		require_once( ABSPATH .'/wp-admin/includes/file.php' );
3528
+		WP_Filesystem();
3529
+		global $wp_filesystem;
3530
+	}
3541 3531
 
3542
-    /**
3543
-     * Filter the language string from database to translate via po editor
3544
-     *
3545
-     * @since 1.4.2
3546
-     *
3547
-     * @param array $contents_strings Array of strings.
3548
-     */
3549
-    $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3550
-
3551
-    $contents_strings = array_unique($contents_strings);
3552
-
3553
-    $contents_head = array();
3554
-    $contents_head[] = "<?php";
3555
-    $contents_head[] = "/**";
3556
-    $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3557
-    $contents_head[] = " *";
3558
-    $contents_head[] = " * @package GeoDirectory";
3559
-    $contents_head[] = " * @since 1.4.2";
3560
-    $contents_head[] = " */";
3561
-    $contents_head[] = "";
3562
-    $contents_head[] = "// Language keys";
3563
-
3564
-    $contents_foot = array();
3565
-    $contents_foot[] = "";
3566
-    $contents_foot[] = "";
3567
-
3568
-    $contents = implode(PHP_EOL, $contents_head);
3569
-
3570
-    if (!empty($contents_strings)) {
3571
-        foreach ( $contents_strings as $string ) {
3572
-            if (is_scalar($string) && $string != '') {
3573
-                $string = str_replace("'", "\'", $string);
3574
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3575
-            }
3576
-        }
3577
-    }
3532
+	$language_file = geodir_plugin_path() . '/db-language.php';
3533
+
3534
+	if(is_file($language_file) && !is_writable($language_file))
3535
+		return false; // Not possible to create.
3536
+
3537
+	if(!is_file($language_file) && !is_writable(dirname($language_file)))
3538
+		return false; // Not possible to create.
3539
+
3540
+	$contents_strings = array();
3541
+
3542
+	/**
3543
+	 * Filter the language string from database to translate via po editor
3544
+	 *
3545
+	 * @since 1.4.2
3546
+	 *
3547
+	 * @param array $contents_strings Array of strings.
3548
+	 */
3549
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3550
+
3551
+	$contents_strings = array_unique($contents_strings);
3552
+
3553
+	$contents_head = array();
3554
+	$contents_head[] = "<?php";
3555
+	$contents_head[] = "/**";
3556
+	$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3557
+	$contents_head[] = " *";
3558
+	$contents_head[] = " * @package GeoDirectory";
3559
+	$contents_head[] = " * @since 1.4.2";
3560
+	$contents_head[] = " */";
3561
+	$contents_head[] = "";
3562
+	$contents_head[] = "// Language keys";
3563
+
3564
+	$contents_foot = array();
3565
+	$contents_foot[] = "";
3566
+	$contents_foot[] = "";
3567
+
3568
+	$contents = implode(PHP_EOL, $contents_head);
3569
+
3570
+	if (!empty($contents_strings)) {
3571
+		foreach ( $contents_strings as $string ) {
3572
+			if (is_scalar($string) && $string != '') {
3573
+				$string = str_replace("'", "\'", $string);
3574
+				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3575
+			}
3576
+		}
3577
+	}
3578 3578
 
3579
-    $contents .= implode(PHP_EOL, $contents_foot);
3579
+	$contents .= implode(PHP_EOL, $contents_foot);
3580 3580
 
3581
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3582
-        return false; // Failure; could not write file.
3581
+	if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3582
+		return false; // Failure; could not write file.
3583 3583
 
3584
-    return true;
3584
+	return true;
3585 3585
 }
3586 3586
 
3587 3587
 /**
@@ -3597,31 +3597,31 @@  discard block
 block discarded – undo
3597 3597
  * @return array Translation texts.
3598 3598
  */
3599 3599
 function geodir_load_custom_field_translation($translation_texts = array()) {
3600
-    global $wpdb;
3600
+	global $wpdb;
3601 3601
 
3602
-    // Custom fields table
3603
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3604
-    $rows = $wpdb->get_results($sql);
3602
+	// Custom fields table
3603
+	$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3604
+	$rows = $wpdb->get_results($sql);
3605 3605
 
3606
-    if (!empty($rows)) {
3607
-        foreach($rows as $row) {
3608
-            if (!empty($row->admin_title))
3609
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3606
+	if (!empty($rows)) {
3607
+		foreach($rows as $row) {
3608
+			if (!empty($row->admin_title))
3609
+				$translation_texts[] = stripslashes_deep($row->admin_title);
3610 3610
 			
3611
-            if (!empty($row->admin_desc))
3612
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3611
+			if (!empty($row->admin_desc))
3612
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
3613 3613
 
3614
-            if (!empty($row->site_title))
3615
-                $translation_texts[] = stripslashes_deep($row->site_title);
3614
+			if (!empty($row->site_title))
3615
+				$translation_texts[] = stripslashes_deep($row->site_title);
3616 3616
 
3617
-            if (!empty($row->clabels))
3618
-                $translation_texts[] = stripslashes_deep($row->clabels);
3617
+			if (!empty($row->clabels))
3618
+				$translation_texts[] = stripslashes_deep($row->clabels);
3619 3619
 
3620
-            if (!empty($row->required_msg))
3621
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3620
+			if (!empty($row->required_msg))
3621
+				$translation_texts[] = stripslashes_deep($row->required_msg);
3622 3622
 			
3623 3623
 			if (!empty($row->default_value))
3624
-                $translation_texts[] = stripslashes_deep($row->default_value);
3624
+				$translation_texts[] = stripslashes_deep($row->default_value);
3625 3625
 			
3626 3626
 			if (!empty($row->option_values)) {
3627 3627
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3634,25 +3634,25 @@  discard block
 block discarded – undo
3634 3634
 					}
3635 3635
 				}
3636 3636
 			}
3637
-        }
3638
-    }
3637
+		}
3638
+	}
3639 3639
 	
3640
-    // Custom sorting fields table
3641
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3642
-    $rows = $wpdb->get_results($sql);
3640
+	// Custom sorting fields table
3641
+	$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3642
+	$rows = $wpdb->get_results($sql);
3643 3643
 
3644
-    if (!empty($rows)) {
3645
-        foreach($rows as $row) {
3646
-            if (!empty($row->site_title))
3647
-                $translation_texts[] = stripslashes_deep($row->site_title);
3644
+	if (!empty($rows)) {
3645
+		foreach($rows as $row) {
3646
+			if (!empty($row->site_title))
3647
+				$translation_texts[] = stripslashes_deep($row->site_title);
3648 3648
 
3649
-            if (!empty($row->asc_title))
3650
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3649
+			if (!empty($row->asc_title))
3650
+				$translation_texts[] = stripslashes_deep($row->asc_title);
3651 3651
 
3652
-            if (!empty($row->desc_title))
3653
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3654
-        }
3655
-    }
3652
+			if (!empty($row->desc_title))
3653
+				$translation_texts[] = stripslashes_deep($row->desc_title);
3654
+		}
3655
+	}
3656 3656
 	
3657 3657
 	// Advance search filter fields table
3658 3658
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
@@ -3673,9 +3673,9 @@  discard block
 block discarded – undo
3673 3673
 		}
3674 3674
 	}
3675 3675
 
3676
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3676
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3677 3677
 
3678
-    return $translation_texts;
3678
+	return $translation_texts;
3679 3679
 }
3680 3680
 
3681 3681
 /**
@@ -3687,71 +3687,71 @@  discard block
 block discarded – undo
3687 3687
  * @return array Array of mime types.
3688 3688
  */
3689 3689
 function geodir_allowed_mime_types() {
3690
-    /**
3691
-     * Filter the list of mime types and file extensions allowed for file upload.
3692
-     *
3693
-     * @since 1.4.7
3694
-     * @package GeoDirectory
3695
-     *
3696
-     * @param array $geodir_allowed_mime_types and file extensions.
3697
-     */
3698
-    return apply_filters( 'geodir_allowed_mime_types', array(
3699
-            'Image' => array( // Image formats.
3700
-                'jpg' => 'image/jpeg',
3701
-                'jpe' => 'image/jpeg',
3702
-                'jpeg' => 'image/jpeg',
3703
-                'gif' => 'image/gif',
3704
-                'png' => 'image/png',
3705
-                'bmp' => 'image/bmp',
3706
-                'ico' => 'image/x-icon',
3707
-            ),
3708
-            'Video' => array( // Video formats.
3709
-                'asf' => 'video/x-ms-asf',
3710
-                'avi' => 'video/avi',
3711
-                'flv' => 'video/x-flv',
3712
-                'mkv' => 'video/x-matroska',
3713
-                'mp4' => 'video/mp4',
3714
-                'mpeg' => 'video/mpeg',
3715
-                'mpg' => 'video/mpeg',
3716
-                'wmv' => 'video/x-ms-wmv',
3717
-                '3gp' => 'video/3gpp',
3718
-            ),
3719
-            'Audio' => array( // Audio formats.
3720
-                'ogg' => 'audio/ogg',
3721
-                'mp3' => 'audio/mpeg',
3722
-                'wav' => 'audio/wav',
3723
-                'wma' => 'audio/x-ms-wma',
3724
-            ),
3725
-            'Text' => array( // Text formats.
3726
-                'css' => 'text/css',
3727
-                'csv' => 'text/csv',
3728
-                'htm' => 'text/html',
3729
-                'html' => 'text/html',
3730
-                'txt' => 'text/plain',
3731
-                'rtx' => 'text/richtext',
3732
-                'vtt' => 'text/vtt',
3733
-            ),
3734
-            'Application' => array( // Application formats.
3735
-                'doc' => 'application/msword',
3736
-                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3737
-                'exe' => 'application/x-msdownload',
3738
-                'js' => 'application/javascript',
3739
-                'odt' => 'application/vnd.oasis.opendocument.text',
3740
-                'pdf' => 'application/pdf',
3741
-                'pot' => 'application/vnd.ms-powerpoint',
3742
-                'ppt' => 'application/vnd.ms-powerpoint',
3743
-                'pptx' => 'application/vnd.ms-powerpoint',
3744
-                'psd' => 'application/octet-stream',
3745
-                'rar' => 'application/rar',
3746
-                'rtf' => 'application/rtf',
3747
-                'swf' => 'application/x-shockwave-flash',
3748
-                'tar' => 'application/x-tar',
3749
-                'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3750
-                'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3751
-                'zip' => 'application/zip',
3752
-            )
3753
-        )
3754
-    );
3690
+	/**
3691
+	 * Filter the list of mime types and file extensions allowed for file upload.
3692
+	 *
3693
+	 * @since 1.4.7
3694
+	 * @package GeoDirectory
3695
+	 *
3696
+	 * @param array $geodir_allowed_mime_types and file extensions.
3697
+	 */
3698
+	return apply_filters( 'geodir_allowed_mime_types', array(
3699
+			'Image' => array( // Image formats.
3700
+				'jpg' => 'image/jpeg',
3701
+				'jpe' => 'image/jpeg',
3702
+				'jpeg' => 'image/jpeg',
3703
+				'gif' => 'image/gif',
3704
+				'png' => 'image/png',
3705
+				'bmp' => 'image/bmp',
3706
+				'ico' => 'image/x-icon',
3707
+			),
3708
+			'Video' => array( // Video formats.
3709
+				'asf' => 'video/x-ms-asf',
3710
+				'avi' => 'video/avi',
3711
+				'flv' => 'video/x-flv',
3712
+				'mkv' => 'video/x-matroska',
3713
+				'mp4' => 'video/mp4',
3714
+				'mpeg' => 'video/mpeg',
3715
+				'mpg' => 'video/mpeg',
3716
+				'wmv' => 'video/x-ms-wmv',
3717
+				'3gp' => 'video/3gpp',
3718
+			),
3719
+			'Audio' => array( // Audio formats.
3720
+				'ogg' => 'audio/ogg',
3721
+				'mp3' => 'audio/mpeg',
3722
+				'wav' => 'audio/wav',
3723
+				'wma' => 'audio/x-ms-wma',
3724
+			),
3725
+			'Text' => array( // Text formats.
3726
+				'css' => 'text/css',
3727
+				'csv' => 'text/csv',
3728
+				'htm' => 'text/html',
3729
+				'html' => 'text/html',
3730
+				'txt' => 'text/plain',
3731
+				'rtx' => 'text/richtext',
3732
+				'vtt' => 'text/vtt',
3733
+			),
3734
+			'Application' => array( // Application formats.
3735
+				'doc' => 'application/msword',
3736
+				'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3737
+				'exe' => 'application/x-msdownload',
3738
+				'js' => 'application/javascript',
3739
+				'odt' => 'application/vnd.oasis.opendocument.text',
3740
+				'pdf' => 'application/pdf',
3741
+				'pot' => 'application/vnd.ms-powerpoint',
3742
+				'ppt' => 'application/vnd.ms-powerpoint',
3743
+				'pptx' => 'application/vnd.ms-powerpoint',
3744
+				'psd' => 'application/octet-stream',
3745
+				'rar' => 'application/rar',
3746
+				'rtf' => 'application/rtf',
3747
+				'swf' => 'application/x-shockwave-flash',
3748
+				'tar' => 'application/x-tar',
3749
+				'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3750
+				'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3751
+				'zip' => 'application/zip',
3752
+			)
3753
+		)
3754
+	);
3755 3755
 }
3756 3756
 
3757 3757
 /**
@@ -3763,21 +3763,21 @@  discard block
 block discarded – undo
3763 3763
  * @return string User display name.
3764 3764
  */
3765 3765
 function geodir_get_client_name($user_id) {
3766
-    $client_name = '';
3766
+	$client_name = '';
3767 3767
 
3768
-    $user_data = get_userdata($user_id);
3768
+	$user_data = get_userdata($user_id);
3769 3769
 
3770
-    if (!empty($user_data)) {
3771
-        if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3772
-            $client_name = trim($user_data->display_name);
3773
-        } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3774
-            $client_name = trim($user_data->user_nicename);
3775
-        } else {
3776
-            $client_name = trim($user_data->user_login);
3777
-        }
3778
-    }
3770
+	if (!empty($user_data)) {
3771
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3772
+			$client_name = trim($user_data->display_name);
3773
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3774
+			$client_name = trim($user_data->user_nicename);
3775
+		} else {
3776
+			$client_name = trim($user_data->user_login);
3777
+		}
3778
+	}
3779 3779
 
3780
-    return $client_name;
3780
+	return $client_name;
3781 3781
 }
3782 3782
 
3783 3783
 
@@ -3792,125 +3792,125 @@  discard block
 block discarded – undo
3792 3792
  */
3793 3793
 function geodir_wpseo_replacements($vars){
3794 3794
 
3795
-    global $wp;
3796
-    $title = '';
3797
-    // location variables
3798
-    $gd_post_type = geodir_get_current_posttype();
3799
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3800
-    /**
3801
-     * Filter the title variables location variables array
3802
-     *
3803
-     * @since 1.5.5
3804
-     * @package GeoDirectory
3805
-     * @param array $location_array The array of location variables.
3806
-     * @param array $vars The page title variables.
3807
-     */
3808
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
3809
-    $location_titles = array();
3810
-    if(get_query_var( 'gd_country_full' )){
3811
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
3812
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
3813
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
3814
-    }
3815
-    $location_single = '';
3816
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
3817
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
3818
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
3819
-
3820
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
3821
-
3822
-    if (function_exists('get_actual_location_name')) {
3823
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
3824
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
3825
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
3826
-    }
3827
-
3828
-    if ($gd_city != '') {
3829
-        if ($gd_city_actual != '') {
3830
-            $gd_city = $gd_city_actual;
3831
-        } else {
3832
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
3833
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
3834
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
3835
-        }
3836
-        $location_single = $gd_city;
3837
-
3838
-    } else if ($gd_region != '') {
3839
-        if ($gd_region_actual != '') {
3840
-            $gd_region = $gd_region_actual;
3841
-        } else {
3842
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
3843
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
3844
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
3845
-        }
3795
+	global $wp;
3796
+	$title = '';
3797
+	// location variables
3798
+	$gd_post_type = geodir_get_current_posttype();
3799
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3800
+	/**
3801
+	 * Filter the title variables location variables array
3802
+	 *
3803
+	 * @since 1.5.5
3804
+	 * @package GeoDirectory
3805
+	 * @param array $location_array The array of location variables.
3806
+	 * @param array $vars The page title variables.
3807
+	 */
3808
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
3809
+	$location_titles = array();
3810
+	if(get_query_var( 'gd_country_full' )){
3811
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
3812
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
3813
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
3814
+	}
3815
+	$location_single = '';
3816
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
3817
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
3818
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
3846 3819
 
3847
-        $location_single = $gd_region;
3848
-    } else if ($gd_country != '') {
3849
-        if ($gd_country_actual != '') {
3850
-            $gd_country = $gd_country_actual;
3851
-        } else {
3852
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
3853
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
3854
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
3855
-        }
3820
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
3856 3821
 
3857
-        $location_single = $gd_country;
3858
-    }
3822
+	if (function_exists('get_actual_location_name')) {
3823
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
3824
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
3825
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
3826
+	}
3827
+
3828
+	if ($gd_city != '') {
3829
+		if ($gd_city_actual != '') {
3830
+			$gd_city = $gd_city_actual;
3831
+		} else {
3832
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
3833
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
3834
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
3835
+		}
3836
+		$location_single = $gd_city;
3837
+
3838
+	} else if ($gd_region != '') {
3839
+		if ($gd_region_actual != '') {
3840
+			$gd_region = $gd_region_actual;
3841
+		} else {
3842
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
3843
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
3844
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
3845
+		}
3846
+
3847
+		$location_single = $gd_region;
3848
+	} else if ($gd_country != '') {
3849
+		if ($gd_country_actual != '') {
3850
+			$gd_country = $gd_country_actual;
3851
+		} else {
3852
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
3853
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
3854
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
3855
+		}
3859 3856
 
3860
-    if (!empty($location_array)) {
3857
+		$location_single = $gd_country;
3858
+	}
3861 3859
 
3862
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
3863
-        $location_array = array_reverse($location_array);
3860
+	if (!empty($location_array)) {
3864 3861
 
3865
-        foreach ($location_array as $location_type => $location) {
3866
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
3867
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
3862
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
3863
+		$location_array = array_reverse($location_array);
3868 3864
 
3869
-            $location_name = geodir_ucwords($gd_location_link_text);
3870
-            $location_name = __($location_name, 'geodirectory');
3865
+		foreach ($location_array as $location_type => $location) {
3866
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
3867
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
3871 3868
 
3872
-            if ($actual_location_name) {
3873
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
3874
-                $location_name = get_actual_location_name($location_type, $location, true);
3875
-            }
3869
+			$location_name = geodir_ucwords($gd_location_link_text);
3870
+			$location_name = __($location_name, 'geodirectory');
3876 3871
 
3877
-            $location_titles[] = $location_name;
3878
-        }
3879
-        if (!empty($location_titles)) {
3880
-            $location_titles = array_unique($location_titles);
3881
-        }
3882
-    }
3872
+			if ($actual_location_name) {
3873
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
3874
+				$location_name = get_actual_location_name($location_type, $location, true);
3875
+			}
3883 3876
 
3877
+			$location_titles[] = $location_name;
3878
+		}
3879
+		if (!empty($location_titles)) {
3880
+			$location_titles = array_unique($location_titles);
3881
+		}
3882
+	}
3884 3883
 
3885
-    if(!empty($location_titles)) {
3886
-        $vars['%%location%%'] = implode(", ", $location_titles);
3887
-    }
3884
+
3885
+	if(!empty($location_titles)) {
3886
+		$vars['%%location%%'] = implode(", ", $location_titles);
3887
+	}
3888 3888
 
3889 3889
 
3890
-    if(!empty($location_titles)) {
3891
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
3892
-    }
3890
+	if(!empty($location_titles)) {
3891
+		$vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
3892
+	}
3893 3893
 
3894 3894
 
3895 3895
 
3896
-    if($location_single) {
3897
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
3898
-    }
3896
+	if($location_single) {
3897
+		$vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
3898
+	}
3899 3899
 
3900 3900
 
3901
-    if($location_single) {
3902
-        $vars['%%location_single%%'] = $location_single;
3903
-    }
3901
+	if($location_single) {
3902
+		$vars['%%location_single%%'] = $location_single;
3903
+	}
3904 3904
 
3905
-    /**
3906
-     * Filter the title variables after standard ones have been filtered for wpseo.
3907
-     *
3908
-     * @since 1.5.7
3909
-     * @package GeoDirectory
3910
-     * @param string $vars The title with variables.
3911
-     * @param array $location_array The array of location variables.
3912
-     */
3913
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3905
+	/**
3906
+	 * Filter the title variables after standard ones have been filtered for wpseo.
3907
+	 *
3908
+	 * @since 1.5.7
3909
+	 * @package GeoDirectory
3910
+	 * @param string $vars The title with variables.
3911
+	 * @param array $location_array The array of location variables.
3912
+	 */
3913
+	return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3914 3914
 }
3915 3915
 
3916 3916
 
@@ -3920,10 +3920,10 @@  discard block
 block discarded – undo
3920 3920
 function geodir_filter_title_variables($title, $gd_page, $sep=''){
3921 3921
 
3922 3922
 
3923
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
3924
-    global $post;
3925
-    //print_r($post);
3926
-    /*
3923
+	if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
3924
+	global $post;
3925
+	//print_r($post);
3926
+	/*
3927 3927
     %%date%%	                Replaced with the date of the post/page
3928 3928
     %%title%%	                Replaced with the title of the post/page
3929 3929
     %%sitename%%	            The site's name
@@ -3950,134 +3950,134 @@  discard block
 block discarded – undo
3950 3950
     %%pagenumber%%	            Replaced with the current page number
3951 3951
      */
3952 3952
 
3953
-    if ($sep == '') {
3954
-        /**
3955
-         * Filter the page title separator.
3956
-         *
3957
-         * @since 1.0.0
3958
-         * @package GeoDirectory
3959
-         * @param string $sep The separator, default: `|`.
3960
-         */
3961
-        $sep = apply_filters('geodir_page_title_separator', '|');
3962
-    }
3963
-
3964
-
3965
-    if(strpos($title,'%%title%%') !== false){
3966
-        $title = str_replace("%%title%%",$post->post_title,$title);
3967
-    }
3968
-
3969
-    if(strpos($title,'%%sitename%%') !== false){
3970
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
3971
-    }
3972
-
3973
-    if(strpos($title,'%%sitedesc%%') !== false){
3974
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
3975
-    }
3976
-
3977
-    if(strpos($title,'%%excerpt%%') !== false){
3978
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
3979
-    }
3980
-
3981
-    if(strpos($title,'%%pt_single%%') !== false){
3982
-        $single_name = '';
3983
-        if($gd_page=='search' || $gd_page=='author'){
3984
-            $geodir_post_types = get_option('geodir_post_types');
3985
-            $spt = esc_attr($_REQUEST['stype']);
3986
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3987
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3988
-            }
3989
-        }elseif($gd_page=='add-listing'){
3990
-            $geodir_post_types = get_option('geodir_post_types');
3991
-            $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
3992
-            if(!$spt && isset($_REQUEST['pid'])){
3993
-                $spt = get_post_type( $_REQUEST['pid'] );
3994
-            }
3995
-            if(!$spt){$spt='gd_place';}
3996
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3997
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3998
-            }
3999
-        }
4000
-        elseif($post->post_type){
4001
-            $geodir_post_types = get_option('geodir_post_types');
4002
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4003
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4004
-            }
3953
+	if ($sep == '') {
3954
+		/**
3955
+		 * Filter the page title separator.
3956
+		 *
3957
+		 * @since 1.0.0
3958
+		 * @package GeoDirectory
3959
+		 * @param string $sep The separator, default: `|`.
3960
+		 */
3961
+		$sep = apply_filters('geodir_page_title_separator', '|');
3962
+	}
4005 3963
 
4006 3964
 
4007
-        }
4008
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4009
-    }
4010
-
4011
-    if(strpos($title,'%%pt_plural%%') !== false){
4012
-        $plural_name = '';
4013
-        if($gd_page=='search' || $gd_page=='author'){
4014
-            $geodir_post_types = get_option('geodir_post_types');
4015
-            $spt = esc_attr($_REQUEST['stype']);
4016
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4017
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4018
-            }
4019
-        }elseif($gd_page=='add-listing'){
4020
-            $geodir_post_types = get_option('geodir_post_types');
4021
-            $spt = sanitize_text_field($_REQUEST['listing_type']);
4022
-            if(!$spt){$spt='gd_place';}
4023
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4024
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4025
-            }
4026
-        }
4027
-        elseif(isset($post->post_type) && $post->post_type){
4028
-            $geodir_post_types = get_option('geodir_post_types');
4029
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4030
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4031
-            }
3965
+	if(strpos($title,'%%title%%') !== false){
3966
+		$title = str_replace("%%title%%",$post->post_title,$title);
3967
+	}
4032 3968
 
4033
-        }
4034
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4035
-    }
3969
+	if(strpos($title,'%%sitename%%') !== false){
3970
+		$title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
3971
+	}
4036 3972
 
3973
+	if(strpos($title,'%%sitedesc%%') !== false){
3974
+		$title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
3975
+	}
4037 3976
 
3977
+	if(strpos($title,'%%excerpt%%') !== false){
3978
+		$title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
3979
+	}
4038 3980
 
4039
-    if(strpos($title,'%%category%%') !== false){
4040
-        $cat_name = '';
3981
+	if(strpos($title,'%%pt_single%%') !== false){
3982
+		$single_name = '';
3983
+		if($gd_page=='search' || $gd_page=='author'){
3984
+			$geodir_post_types = get_option('geodir_post_types');
3985
+			$spt = esc_attr($_REQUEST['stype']);
3986
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3987
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3988
+			}
3989
+		}elseif($gd_page=='add-listing'){
3990
+			$geodir_post_types = get_option('geodir_post_types');
3991
+			$spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
3992
+			if(!$spt && isset($_REQUEST['pid'])){
3993
+				$spt = get_post_type( $_REQUEST['pid'] );
3994
+			}
3995
+			if(!$spt){$spt='gd_place';}
3996
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3997
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3998
+			}
3999
+		}
4000
+		elseif($post->post_type){
4001
+			$geodir_post_types = get_option('geodir_post_types');
4002
+			if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4003
+				$single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4004
+			}
4041 4005
 
4042
-        if($gd_page=='detail') {
4043
-            if ($post->default_category) {
4044
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4045
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4046
-            }
4047
-        }elseif($gd_page=='listing'){
4048
-            $queried_object = get_queried_object();
4049
-            if(isset($queried_object->name)){
4050
-                $cat_name = $queried_object->name;
4051
-            }
4052
-        }
4053
-        $title = str_replace("%%category%%",$cat_name,$title);
4054
-    }
4055
-
4056
-    if(strpos($title,'%%tag%%') !== false){
4057
-        $cat_name = '';
4058
-
4059
-        if($gd_page=='detail') {
4060
-            if ($post->default_category) {
4061
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4062
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4063
-            }
4064
-        }elseif($gd_page=='listing'){
4065
-            $queried_object = get_queried_object();
4066
-            if(isset($queried_object->name)){
4067
-                $cat_name = $queried_object->name;
4068
-            }
4069
-        }
4070
-        $title = str_replace("%%tag%%",$cat_name,$title);
4071
-    }
4072 4006
 
4007
+		}
4008
+		$title = str_replace("%%pt_single%%",$single_name,$title);
4009
+	}
4010
+
4011
+	if(strpos($title,'%%pt_plural%%') !== false){
4012
+		$plural_name = '';
4013
+		if($gd_page=='search' || $gd_page=='author'){
4014
+			$geodir_post_types = get_option('geodir_post_types');
4015
+			$spt = esc_attr($_REQUEST['stype']);
4016
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4017
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4018
+			}
4019
+		}elseif($gd_page=='add-listing'){
4020
+			$geodir_post_types = get_option('geodir_post_types');
4021
+			$spt = sanitize_text_field($_REQUEST['listing_type']);
4022
+			if(!$spt){$spt='gd_place';}
4023
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4024
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4025
+			}
4026
+		}
4027
+		elseif(isset($post->post_type) && $post->post_type){
4028
+			$geodir_post_types = get_option('geodir_post_types');
4029
+			if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4030
+				$plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4031
+			}
4032
+
4033
+		}
4034
+		$title = str_replace("%%pt_plural%%",$plural_name,$title);
4035
+	}
4036
+
4037
+
4038
+
4039
+	if(strpos($title,'%%category%%') !== false){
4040
+		$cat_name = '';
4041
+
4042
+		if($gd_page=='detail') {
4043
+			if ($post->default_category) {
4044
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4045
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4046
+			}
4047
+		}elseif($gd_page=='listing'){
4048
+			$queried_object = get_queried_object();
4049
+			if(isset($queried_object->name)){
4050
+				$cat_name = $queried_object->name;
4051
+			}
4052
+		}
4053
+		$title = str_replace("%%category%%",$cat_name,$title);
4054
+	}
4055
+
4056
+	if(strpos($title,'%%tag%%') !== false){
4057
+		$cat_name = '';
4058
+
4059
+		if($gd_page=='detail') {
4060
+			if ($post->default_category) {
4061
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4062
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4063
+			}
4064
+		}elseif($gd_page=='listing'){
4065
+			$queried_object = get_queried_object();
4066
+			if(isset($queried_object->name)){
4067
+				$cat_name = $queried_object->name;
4068
+			}
4069
+		}
4070
+		$title = str_replace("%%tag%%",$cat_name,$title);
4071
+	}
4073 4072
 
4074 4073
 
4075
-    if(strpos($title,'%%id%%') !== false){
4076
-        $ID = (isset($post->ID)) ? $post->ID : '';
4077
-        $title = str_replace("%%id%%",$ID,$title);
4078
-    }
4079 4074
 
4080
-    /*
4075
+	if(strpos($title,'%%id%%') !== false){
4076
+		$ID = (isset($post->ID)) ? $post->ID : '';
4077
+		$title = str_replace("%%id%%",$ID,$title);
4078
+	}
4079
+
4080
+	/*
4081 4081
         if(strpos($title,'') !== false){
4082 4082
             $title = str_replace("",,$title);
4083 4083
         }
@@ -4087,174 +4087,174 @@  discard block
 block discarded – undo
4087 4087
         }
4088 4088
     */
4089 4089
 
4090
-    if(strpos($title,'%%sep%%') !== false){
4091
-        $title = str_replace("%%sep%%",$sep,$title);
4092
-    }
4093
-
4094
-
4095
-    global $wp;
4096
-    // location variables
4097
-    $gd_post_type = geodir_get_current_posttype();
4098
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4099
-    /**
4100
-     * Filter the title variables location variables array
4101
-     *
4102
-     * @since 1.5.5
4103
-     * @package GeoDirectory
4104
-     * @param array $location_array The array of location variables.
4105
-     * @param string $title The title with variables..
4106
-     * @param string $gd_page The page being filtered.
4107
-     * @param string $sep The separator, default: `|`.
4108
-     */
4109
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4110
-    $location_titles = array();
4111
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4112
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4113
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4114
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4115
-    }
4116
-    $location_single = '';
4117
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4118
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4119
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4120
-
4121
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4122
-
4123
-    if (function_exists('get_actual_location_name')) {
4124
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4125
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4126
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4127
-    }
4128
-
4129
-    if ($gd_city != '') {
4130
-        if ($gd_city_actual != '') {
4131
-            $gd_city = $gd_city_actual;
4132
-        } else {
4133
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4134
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4135
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4136
-        }
4137
-        $location_single = $gd_city;
4138
-
4139
-    } else if ($gd_region != '') {
4140
-        if ($gd_region_actual != '') {
4141
-            $gd_region = $gd_region_actual;
4142
-        } else {
4143
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4144
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4145
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4146
-        }
4090
+	if(strpos($title,'%%sep%%') !== false){
4091
+		$title = str_replace("%%sep%%",$sep,$title);
4092
+	}
4147 4093
 
4148
-        $location_single = $gd_region;
4149
-    } else if ($gd_country != '') {
4150
-        if ($gd_country_actual != '') {
4151
-            $gd_country = $gd_country_actual;
4152
-        } else {
4153
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4154
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4155
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4156
-        }
4157 4094
 
4158
-        $location_single = $gd_country;
4159
-    }
4095
+	global $wp;
4096
+	// location variables
4097
+	$gd_post_type = geodir_get_current_posttype();
4098
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4099
+	/**
4100
+	 * Filter the title variables location variables array
4101
+	 *
4102
+	 * @since 1.5.5
4103
+	 * @package GeoDirectory
4104
+	 * @param array $location_array The array of location variables.
4105
+	 * @param string $title The title with variables..
4106
+	 * @param string $gd_page The page being filtered.
4107
+	 * @param string $sep The separator, default: `|`.
4108
+	 */
4109
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4110
+	$location_titles = array();
4111
+	if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4112
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4113
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4114
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4115
+	}
4116
+	$location_single = '';
4117
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4118
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4119
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4160 4120
 
4161
-    if (!empty($location_array)) {
4121
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4162 4122
 
4163
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4164
-        $location_array = array_reverse($location_array);
4123
+	if (function_exists('get_actual_location_name')) {
4124
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4125
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4126
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4127
+	}
4165 4128
 
4166
-        foreach ($location_array as $location_type => $location) {
4167
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4168
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4129
+	if ($gd_city != '') {
4130
+		if ($gd_city_actual != '') {
4131
+			$gd_city = $gd_city_actual;
4132
+		} else {
4133
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4134
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4135
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4136
+		}
4137
+		$location_single = $gd_city;
4138
+
4139
+	} else if ($gd_region != '') {
4140
+		if ($gd_region_actual != '') {
4141
+			$gd_region = $gd_region_actual;
4142
+		} else {
4143
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4144
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4145
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4146
+		}
4169 4147
 
4170
-            $location_name = geodir_ucwords($gd_location_link_text);
4171
-            $location_name = __($location_name, 'geodirectory');
4148
+		$location_single = $gd_region;
4149
+	} else if ($gd_country != '') {
4150
+		if ($gd_country_actual != '') {
4151
+			$gd_country = $gd_country_actual;
4152
+		} else {
4153
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4154
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4155
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4156
+		}
4172 4157
 
4173
-            if ($actual_location_name) {
4174
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4175
-                $location_name = get_actual_location_name($location_type, $location, true);
4176
-            }
4158
+		$location_single = $gd_country;
4159
+	}
4177 4160
 
4178
-            $location_titles[] = $location_name;
4179
-        }
4180
-        if (!empty($location_titles)) {
4181
-            $location_titles = array_unique($location_titles);
4182
-        }
4183
-    }
4161
+	if (!empty($location_array)) {
4184 4162
 
4163
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4164
+		$location_array = array_reverse($location_array);
4185 4165
 
4186
-    if(strpos($title,'%%location%%') !== false){
4187
-        $location = '';
4188
-        if($location_titles) {
4189
-            $location = implode(", ", $location_titles);
4190
-        }
4191
-        $title = str_replace("%%location%%",$location,$title);
4192
-    }
4166
+		foreach ($location_array as $location_type => $location) {
4167
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4168
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4193 4169
 
4194
-    if(strpos($title,'%%in_location%%') !== false){
4195
-        $location = '';
4196
-        if($location_titles) {
4197
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4198
-        }
4199
-        $title = str_replace("%%in_location%%",$location,$title);
4200
-    }
4170
+			$location_name = geodir_ucwords($gd_location_link_text);
4171
+			$location_name = __($location_name, 'geodirectory');
4201 4172
 
4202
-    if(strpos($title,'%%in_location_single%%') !== false){
4203
-        if($location_single) {
4204
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4205
-        }
4206
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4207
-    }
4173
+			if ($actual_location_name) {
4174
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4175
+				$location_name = get_actual_location_name($location_type, $location, true);
4176
+			}
4208 4177
 
4209
-    if(strpos($title,'%%location_single%%') !== false){
4210
-        $title = str_replace("%%location_single%%",$location_single,$title);
4211
-    }
4178
+			$location_titles[] = $location_name;
4179
+		}
4180
+		if (!empty($location_titles)) {
4181
+			$location_titles = array_unique($location_titles);
4182
+		}
4183
+	}
4212 4184
 
4213 4185
 
4214
-    if(strpos($title,'%%search_term%%') !== false){
4215
-        $search_term = '';
4216
-        if(isset($_REQUEST['s'])){
4217
-            $search_term = esc_attr($_REQUEST['s']);
4218
-        }
4219
-        $title = str_replace("%%search_term%%",$search_term,$title);
4220
-    }
4186
+	if(strpos($title,'%%location%%') !== false){
4187
+		$location = '';
4188
+		if($location_titles) {
4189
+			$location = implode(", ", $location_titles);
4190
+		}
4191
+		$title = str_replace("%%location%%",$location,$title);
4192
+	}
4221 4193
 
4222
-    if(strpos($title,'%%search_near%%') !== false){
4223
-        $search_term = '';
4224
-        if(isset($_REQUEST['snear'])){
4225
-            $search_term = esc_attr($_REQUEST['snear']);
4226
-        }
4227
-        $title = str_replace("%%search_near%%",$search_term,$title);
4228
-    }
4229
-
4230
-    if(strpos($title,'%%name%%') !== false){
4231
-        $author_name = '';
4232
-        if($author_name = get_the_author()){}
4233
-        else{
4234
-            $queried_object = get_queried_object();
4235
-            if(isset($queried_object->data->user_nicename)){
4236
-                $author_name = $queried_object->data->user_nicename;
4237
-            }
4238
-        }
4239
-        $title = str_replace("%%name%%",$author_name,$title);
4240
-    }
4241
-
4242
-    $title = wptexturize( $title );
4243
-    $title = convert_chars( $title );
4244
-    $title = esc_html( $title );
4245
-
4246
-    /**
4247
-     * Filter the title variables after standard ones have been filtered.
4248
-     *
4249
-     * @since 1.5.7
4250
-     * @package GeoDirectory
4251
-     * @param string $title The title with variables.
4252
-     * @param array $location_array The array of location variables.
4253
-     * @param string $gd_page The page being filtered.
4254
-     * @param string $sep The separator, default: `|`.
4255
-     */
4194
+	if(strpos($title,'%%in_location%%') !== false){
4195
+		$location = '';
4196
+		if($location_titles) {
4197
+			$location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4198
+		}
4199
+		$title = str_replace("%%in_location%%",$location,$title);
4200
+	}
4201
+
4202
+	if(strpos($title,'%%in_location_single%%') !== false){
4203
+		if($location_single) {
4204
+			$location_single = __('in', 'geodirectory') . ' ' .$location_single;
4205
+		}
4206
+		$title = str_replace("%%in_location_single%%",$location_single,$title);
4207
+	}
4208
+
4209
+	if(strpos($title,'%%location_single%%') !== false){
4210
+		$title = str_replace("%%location_single%%",$location_single,$title);
4211
+	}
4212
+
4213
+
4214
+	if(strpos($title,'%%search_term%%') !== false){
4215
+		$search_term = '';
4216
+		if(isset($_REQUEST['s'])){
4217
+			$search_term = esc_attr($_REQUEST['s']);
4218
+		}
4219
+		$title = str_replace("%%search_term%%",$search_term,$title);
4220
+	}
4256 4221
 
4257
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4222
+	if(strpos($title,'%%search_near%%') !== false){
4223
+		$search_term = '';
4224
+		if(isset($_REQUEST['snear'])){
4225
+			$search_term = esc_attr($_REQUEST['snear']);
4226
+		}
4227
+		$title = str_replace("%%search_near%%",$search_term,$title);
4228
+	}
4229
+
4230
+	if(strpos($title,'%%name%%') !== false){
4231
+		$author_name = '';
4232
+		if($author_name = get_the_author()){}
4233
+		else{
4234
+			$queried_object = get_queried_object();
4235
+			if(isset($queried_object->data->user_nicename)){
4236
+				$author_name = $queried_object->data->user_nicename;
4237
+			}
4238
+		}
4239
+		$title = str_replace("%%name%%",$author_name,$title);
4240
+	}
4241
+
4242
+	$title = wptexturize( $title );
4243
+	$title = convert_chars( $title );
4244
+	$title = esc_html( $title );
4245
+
4246
+	/**
4247
+	 * Filter the title variables after standard ones have been filtered.
4248
+	 *
4249
+	 * @since 1.5.7
4250
+	 * @package GeoDirectory
4251
+	 * @param string $title The title with variables.
4252
+	 * @param array $location_array The array of location variables.
4253
+	 * @param string $gd_page The page being filtered.
4254
+	 * @param string $sep The separator, default: `|`.
4255
+	 */
4256
+
4257
+	return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4258 4258
 }
4259 4259
 
4260 4260
 /**
@@ -4267,65 +4267,65 @@  discard block
 block discarded – undo
4267 4267
  * @return array Translation texts.
4268 4268
  */
4269 4269
 function geodir_load_cpt_text_translation($translation_texts = array()) {
4270
-    $gd_post_types = geodir_get_posttypes('array');
4271
-
4272
-    if (!empty($gd_post_types)) {
4273
-        foreach ($gd_post_types as $post_type => $cpt_info) {
4274
-            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4275
-            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4276
-            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4277
-
4278
-            if (!empty($labels)) {
4279
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4280
-                    $translation_texts[] = $labels['name'];
4281
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4282
-                    $translation_texts[] = $labels['singular_name'];
4283
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4284
-                    $translation_texts[] = $labels['add_new'];
4285
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4286
-                    $translation_texts[] = $labels['add_new_item'];
4287
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4288
-                    $translation_texts[] = $labels['edit_item'];
4289
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4290
-                    $translation_texts[] = $labels['new_item'];
4291
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4292
-                    $translation_texts[] = $labels['view_item'];
4293
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4294
-                    $translation_texts[] = $labels['search_items'];
4295
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4296
-                    $translation_texts[] = $labels['not_found'];
4297
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4298
-                    $translation_texts[] = $labels['not_found_in_trash'];
4299
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4300
-                    $translation_texts[] = $labels['label_post_profile'];
4301
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4302
-                    $translation_texts[] = $labels['label_post_info'];
4303
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4304
-                    $translation_texts[] = $labels['label_post_images'];
4305
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4306
-                    $translation_texts[] = $labels['label_post_map'];
4307
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4308
-                    $translation_texts[] = $labels['label_reviews'];
4309
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4310
-                    $translation_texts[] = $labels['label_related_listing'];
4311
-            }
4312
-
4313
-            if ($description != '' && !in_array($description, $translation_texts)) {
4314
-                $translation_texts[] = normalize_whitespace($description);
4315
-            }
4316
-
4317
-            if (!empty($seo)) {
4318
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4319
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4320
-
4321
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4322
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4323
-            }
4324
-        }
4325
-    }
4326
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4270
+	$gd_post_types = geodir_get_posttypes('array');
4271
+
4272
+	if (!empty($gd_post_types)) {
4273
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4274
+			$labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4275
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4276
+			$seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4277
+
4278
+			if (!empty($labels)) {
4279
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4280
+					$translation_texts[] = $labels['name'];
4281
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4282
+					$translation_texts[] = $labels['singular_name'];
4283
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4284
+					$translation_texts[] = $labels['add_new'];
4285
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4286
+					$translation_texts[] = $labels['add_new_item'];
4287
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4288
+					$translation_texts[] = $labels['edit_item'];
4289
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4290
+					$translation_texts[] = $labels['new_item'];
4291
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4292
+					$translation_texts[] = $labels['view_item'];
4293
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4294
+					$translation_texts[] = $labels['search_items'];
4295
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4296
+					$translation_texts[] = $labels['not_found'];
4297
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4298
+					$translation_texts[] = $labels['not_found_in_trash'];
4299
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4300
+					$translation_texts[] = $labels['label_post_profile'];
4301
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4302
+					$translation_texts[] = $labels['label_post_info'];
4303
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4304
+					$translation_texts[] = $labels['label_post_images'];
4305
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4306
+					$translation_texts[] = $labels['label_post_map'];
4307
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4308
+					$translation_texts[] = $labels['label_reviews'];
4309
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4310
+					$translation_texts[] = $labels['label_related_listing'];
4311
+			}
4327 4312
 
4328
-    return $translation_texts;
4313
+			if ($description != '' && !in_array($description, $translation_texts)) {
4314
+				$translation_texts[] = normalize_whitespace($description);
4315
+			}
4316
+
4317
+			if (!empty($seo)) {
4318
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4319
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4320
+
4321
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4322
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4323
+			}
4324
+		}
4325
+	}
4326
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4327
+
4328
+	return $translation_texts;
4329 4329
 }
4330 4330
 
4331 4331
 /**
@@ -4338,25 +4338,25 @@  discard block
 block discarded – undo
4338 4338
  * @return array Location terms.
4339 4339
  */
4340 4340
 function geodir_remove_location_terms($location_terms = array()) {
4341
-    $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4342
-
4343
-    if (!empty($location_terms) && $location_manager) {
4344
-        $hide_country_part = get_option('geodir_location_hide_country_part');
4345
-        $hide_region_part = get_option('geodir_location_hide_region_part');
4346
-
4347
-        if ($hide_region_part && $hide_country_part) {
4348
-            if (isset($location_terms['gd_country']))
4349
-                unset($location_terms['gd_country']);
4350
-            if (isset($location_terms['gd_region']))
4351
-                unset($location_terms['gd_region']);
4352
-        } else if ($hide_region_part && !$hide_country_part) {
4353
-            if (isset($location_terms['gd_region']))
4354
-                unset($location_terms['gd_region']);
4355
-        } else if (!$hide_region_part && $hide_country_part) {
4356
-            if (isset($location_terms['gd_country']))
4357
-                unset($location_terms['gd_country']);
4358
-        }
4359
-    }
4341
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4342
+
4343
+	if (!empty($location_terms) && $location_manager) {
4344
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4345
+		$hide_region_part = get_option('geodir_location_hide_region_part');
4346
+
4347
+		if ($hide_region_part && $hide_country_part) {
4348
+			if (isset($location_terms['gd_country']))
4349
+				unset($location_terms['gd_country']);
4350
+			if (isset($location_terms['gd_region']))
4351
+				unset($location_terms['gd_region']);
4352
+		} else if ($hide_region_part && !$hide_country_part) {
4353
+			if (isset($location_terms['gd_region']))
4354
+				unset($location_terms['gd_region']);
4355
+		} else if (!$hide_region_part && $hide_country_part) {
4356
+			if (isset($location_terms['gd_country']))
4357
+				unset($location_terms['gd_country']);
4358
+		}
4359
+	}
4360 4360
 
4361
-    return $location_terms;
4361
+	return $location_terms;
4362 4362
 }
4363 4363
\ 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.