Passed
Pull Request — master (#261)
by Viruthagiri
09:40
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.
Braces   +231 added lines, -127 removed lines patch added patch discarded remove patch
@@ -202,8 +202,9 @@  discard block
 block discarded – undo
202 202
 
203 203
         $thumb_img_arr = array();
204 204
 
205
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
206
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
205
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
206
+                    $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
207
+        }
207 208
 
208 209
         $totImg = '';
209 210
         $image_limit = '';
@@ -254,7 +255,9 @@  discard block
 block discarded – undo
254 255
     {
255 256
         global $menu, $geodirectory;
256 257
 
257
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
258
+        if (current_user_can('manage_options')) {
259
+        	$menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
260
+        }
258 261
 
259 262
         add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
260 263
 
@@ -318,7 +321,9 @@  discard block
 block discarded – undo
318 321
      */
319 322
     function geodir_admin_custom_menu_order()
320 323
     {
321
-        if (!current_user_can('manage_options')) return false;
324
+        if (!current_user_can('manage_options')) {
325
+        	return false;
326
+        }
322 327
         return true;
323 328
     }
324 329
 }
@@ -349,10 +354,11 @@  discard block
 block discarded – undo
349 354
 			case 'fail':
350 355
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
351 356
 				
352
-				if ($gderr == 21)
353
-			    	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>';
354
-				else
355
-					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
357
+				if ($gderr == 21) {
358
+							    	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>';
359
+				} else {
360
+									echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
361
+				}
356 362
                 break;
357 363
         }
358 364
     }
@@ -389,8 +395,12 @@  discard block
 block discarded – undo
389 395
         include_once('option-pages/' . $current_tab . '_array.php');
390 396
     }
391 397
     if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
392
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
393
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
398
+        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) {
399
+        	die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
400
+        }
401
+        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) {
402
+        	die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
403
+        }
394 404
 		
395 405
 		/**
396 406
 		 * Fires before updating geodirectory admin settings.
@@ -402,8 +412,9 @@  discard block
 block discarded – undo
402 412
 		 */
403 413
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
404 414
 		
405
-        if (!empty($geodir_settings[$current_tab]))
406
-            geodir_update_options($geodir_settings[$current_tab]);
415
+        if (!empty($geodir_settings[$current_tab])) {
416
+                    geodir_update_options($geodir_settings[$current_tab]);
417
+        }
407 418
 
408 419
         /**
409 420
          * Called after GeoDirectory options settings are updated.
@@ -471,8 +482,9 @@  discard block
 block discarded – undo
471 482
                 $options_list = '';
472 483
                 for ($option = 1; $option <= 30; $option++) {
473 484
                     $selected = '';
474
-                    if ($option == 10)
475
-                        $selected = 'selected="selected"';
485
+                    if ($option == 10) {
486
+                                            $selected = 'selected="selected"';
487
+                    }
476 488
 
477 489
                     $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
478 490
                 }
@@ -672,10 +684,11 @@  discard block
 block discarded – undo
672 684
                     }
673 685
 
674 686
 
675
-                    if (geodir_dummy_folder_exists())
676
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
677
-                    else
678
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
687
+                    if (geodir_dummy_folder_exists()) {
688
+                                            $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
689
+                    } else {
690
+                                            $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
691
+                    }
679 692
 
680 693
                     $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
681 694
 
@@ -716,10 +729,11 @@  discard block
 block discarded – undo
716 729
             if (!term_exists($catname, 'gd_placecategory')) {
717 730
                 $last_catid = wp_insert_term($catname, 'gd_placecategory');
718 731
 
719
-                if (geodir_dummy_folder_exists())
720
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
721
-                else
722
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
732
+                if (geodir_dummy_folder_exists()) {
733
+                                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
734
+                } else {
735
+                                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
736
+                }
723 737
 
724 738
                 $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
725 739
 
@@ -771,11 +785,14 @@  discard block
 block discarded – undo
771 785
  * @return bool Returns true if saved.
772 786
  */
773 787
 function geodir_update_options($options, $dummy = false) {
774
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
788
+    if ((!isset($_POST) || !$_POST) && !$dummy) {
789
+    	return false;
790
+    }
775 791
 
776 792
     foreach ($options as $value) {
777
-        if ($dummy && isset($value['std']))
778
-            $_POST[$value['id']] = $value['std'];
793
+        if ($dummy && isset($value['std'])) {
794
+                    $_POST[$value['id']] = $value['std'];
795
+        }
779 796
 
780 797
 
781 798
         if (isset($value['type']) && $value['type'] == 'checkbox') :
@@ -784,25 +801,23 @@  discard block
 block discarded – undo
784 801
                 update_option($value['id'], $_POST[$value['id']]);
785 802
             } else {
786 803
                 update_option($value['id'], 0);
787
-            }
788
-
789
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
804
+            } elseif (isset($value['type']) && $value['type'] == 'image_width') :
790 805
 
791 806
             if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
792 807
                 update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
793 808
                 update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
794 809
                 if (isset($_POST[$value['id'] . '_crop'])) :
795 810
                     update_option($value['id'] . '_crop', 1);
796
-                else :
797
-                    update_option($value['id'] . '_crop', 0);
811
+                else {
812
+                	:
813
+                    update_option($value['id'] . '_crop', 0);
814
+                }
798 815
                 endif;
799 816
             } else {
800 817
                 update_option($value['id'] . '_width', $value['std']);
801 818
                 update_option($value['id'] . '_height', $value['std']);
802 819
                 update_option($value['id'] . '_crop', 1);
803
-            }
804
-
805
-        elseif (isset($value['type']) && $value['type'] == 'map') :
820
+            } elseif (isset($value['type']) && $value['type'] == 'map') :
806 821
             $post_types = array();
807 822
             $categories = array();
808 823
 
@@ -847,8 +862,9 @@  discard block
 block discarded – undo
847 862
                     $image_name_arr = explode('/', get_option($value['id']));
848 863
                     $noimg_name = end($image_name_arr);
849 864
                     $img_path = $uploads['path'] . '/' . $noimg_name;
850
-                    if (file_exists($img_path))
851
-                        unlink($img_path);
865
+                    if (file_exists($img_path)) {
866
+                                            unlink($img_path);
867
+                    }
852 868
                 }
853 869
 
854 870
                 update_option($value['id'], '');
@@ -864,8 +880,10 @@  discard block
 block discarded – undo
864 880
                 foreach ($uploadedfile as $key => $uplaod):
865 881
                     if ($key == 'name'):
866 882
                         $uplaods[$key] = $filename;
867
-                    else :
868
-                        $uplaods[$key] = $uplaod;
883
+                    else {
884
+                    	:
885
+                        $uplaods[$key] = $uplaod;
886
+                    }
869 887
                     endif;
870 888
                 endforeach;
871 889
 
@@ -875,8 +893,9 @@  discard block
 block discarded – undo
875 893
                     $image_name_arr = explode('/', get_option($value['id']));
876 894
                     $noimg_name = end($image_name_arr);
877 895
                     $img_path = $uploads['path'] . '/' . $noimg_name;
878
-                    if (file_exists($img_path))
879
-                        unlink($img_path);
896
+                    if (file_exists($img_path)) {
897
+                                            unlink($img_path);
898
+                    }
880 899
                 }
881 900
 
882 901
                 $upload_overrides = array('test_form' => false);
@@ -891,10 +910,12 @@  discard block
 block discarded – undo
891 910
             endif;
892 911
 
893 912
 
894
-        else :
913
+        else {
914
+        	:
895 915
             // same menu setting per theme.
896 916
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
897
-                $theme = wp_get_theme();
917
+                $theme = wp_get_theme();
918
+        }
898 919
                 update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
899 920
             }
900 921
 
@@ -906,8 +927,9 @@  discard block
 block discarded – undo
906 927
 
907 928
         endif;
908 929
     }
909
-    if ($dummy)
910
-        $_POST = array();
930
+    if ($dummy) {
931
+            $_POST = array();
932
+    }
911 933
     return true;
912 934
 
913 935
 }
@@ -1052,9 +1074,12 @@  discard block
 block discarded – undo
1052 1074
         $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1053 1075
             'categorys' => __('Categories', 'geodirectory'));
1054 1076
 
1055
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1077
+        if (($offset = array_search('author', array_keys($columns))) === false) {
1078
+        	// if the key doesn't exist
1056 1079
         {
1057
-            $offset = 0; // should we prepend $array with $data?
1080
+            $offset = 0;
1081
+        }
1082
+        // should we prepend $array with $data?
1058 1083
             $offset = count($columns); // or should we append $array with $data? lets pick this one...
1059 1084
         }
1060 1085
 
@@ -1114,11 +1139,13 @@  discard block
 block discarded – undo
1114 1139
                     $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1115 1140
                 }
1116 1141
                 /* If no expire_date is found, output a default message. */
1117
-                if (empty($expire_date))
1118
-                    echo __('Unknown', 'geodirectory');
1142
+                if (empty($expire_date)) {
1143
+                                    echo __('Unknown', 'geodirectory');
1144
+                }
1119 1145
                 /* If there is a expire_date, append 'days left' to the text string. */
1120
-                else
1121
-                    echo $expire_date . $date_diff_text;
1146
+                else {
1147
+                                    echo $expire_date . $date_diff_text;
1148
+                }
1122 1149
                 break;
1123 1150
 
1124 1151
             /* If displaying the 'categorys' column. */
@@ -1191,21 +1218,26 @@  discard block
 block discarded – undo
1191 1218
 
1192 1219
     $geodir_posttypes = geodir_get_posttypes();
1193 1220
 
1194
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1195
-        return;
1221
+    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1222
+            return;
1223
+    }
1196 1224
 
1197 1225
     if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1198
-        if (isset($_REQUEST['_status']))
1199
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1226
+        if (isset($_REQUEST['_status'])) {
1227
+                    geodir_change_post_status($post_id, $_REQUEST['_status']);
1228
+        }
1200 1229
 
1201
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1202
-            return;
1230
+        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) {
1231
+                    return;
1232
+        }
1203 1233
 
1204
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1205
-            return;
1234
+        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) {
1235
+                    return;
1236
+        }
1206 1237
 
1207
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1208
-            return;
1238
+        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) {
1239
+                    return;
1240
+        }
1209 1241
 
1210 1242
         geodir_save_listing($_REQUEST);
1211 1243
     }
@@ -1230,10 +1262,18 @@  discard block
 block discarded – undo
1230 1262
     $tab_id = '';
1231 1263
     $i = 0;
1232 1264
     foreach ($options as $value) :
1233
-        if (!isset($value['name'])) $value['name'] = '';
1234
-        if (!isset($value['class'])) $value['class'] = '';
1235
-        if (!isset($value['css'])) $value['css'] = '';
1236
-        if (!isset($value['std'])) $value['std'] = '';
1265
+        if (!isset($value['name'])) {
1266
+        	$value['name'] = '';
1267
+        }
1268
+        if (!isset($value['class'])) {
1269
+        	$value['class'] = '';
1270
+        }
1271
+        if (!isset($value['css'])) {
1272
+        	$value['css'] = '';
1273
+        }
1274
+        if (!isset($value['std'])) {
1275
+        	$value['std'] = '';
1276
+        }
1237 1277
         $desc = '';
1238 1278
         switch ($value['type']) :
1239 1279
             case 'dummy_installer':
@@ -1249,11 +1289,13 @@  discard block
 block discarded – undo
1249 1289
 
1250 1290
                 $i++;
1251 1291
 
1252
-                if (isset($value['id']) && $value['id'])
1253
-                    $tab_id = $value['id'];
1292
+                if (isset($value['id']) && $value['id']) {
1293
+                                    $tab_id = $value['id'];
1294
+                }
1254 1295
 
1255
-                if (isset($value['desc']) && $value['desc'])
1256
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1296
+                if (isset($value['desc']) && $value['desc']) {
1297
+                                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1298
+                }
1257 1299
 
1258 1300
                 if (isset($value['name']) && $value['name']) {
1259 1301
                     if ($first_title === true) {
@@ -1284,10 +1326,12 @@  discard block
 block discarded – undo
1284 1326
                 break;
1285 1327
 
1286 1328
             case 'sectionstart':
1287
-                if (isset($value['desc']) && $value['desc'])
1288
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1289
-                if (isset($value['name']) && $value['name'])
1290
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1329
+                if (isset($value['desc']) && $value['desc']) {
1330
+                                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1331
+                }
1332
+                if (isset($value['name']) && $value['name']) {
1333
+                                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1334
+                }
1291 1335
                 /**
1292 1336
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1293 1337
                  *
@@ -1295,7 +1339,9 @@  discard block
 block discarded – undo
1295 1339
                  *
1296 1340
                  * @since 1.0.0
1297 1341
                  */
1298
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1342
+                if (isset($value['id']) && $value['id']) {
1343
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1344
+                }
1299 1345
                 echo '<table class="form-table">' . "\n\n";
1300 1346
 
1301 1347
                 break;
@@ -1307,7 +1353,9 @@  discard block
 block discarded – undo
1307 1353
                  *
1308 1354
                  * @since 1.0.0
1309 1355
                  */
1310
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1356
+                if (isset($value['id']) && $value['id']) {
1357
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1358
+                }
1311 1359
                 echo '</table>';
1312 1360
                 /**
1313 1361
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -1316,7 +1364,9 @@  discard block
 block discarded – undo
1316 1364
                  *
1317 1365
                  * @since 1.0.0
1318 1366
                  */
1319
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1367
+                if (isset($value['id']) && $value['id']) {
1368
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1369
+                }
1320 1370
                 break;
1321 1371
             case 'text':
1322 1372
                 ?>
@@ -1388,17 +1438,32 @@  discard block
 block discarded – undo
1388 1438
                     <?php _e('Width', 'geodirectory'); ?> <input
1389 1439
                         name="<?php echo esc_attr($value['id']); ?>_width"
1390 1440
                         id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3"
1391
-                        value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1441
+                        value="<?php if ($size = get_option($value['id'] . '_width')) {
1442
+	echo stripslashes($size);
1443
+} else {
1444
+	echo $value['std'];
1445
+}
1446
+?>"/>
1392 1447
 
1393 1448
                     <?php _e('Height', 'geodirectory'); ?> <input
1394 1449
                         name="<?php echo esc_attr($value['id']); ?>_height"
1395 1450
                         id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3"
1396
-                        value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1451
+                        value="<?php if ($size = get_option($value['id'] . '_height')) {
1452
+	echo stripslashes($size);
1453
+} else {
1454
+	echo $value['std'];
1455
+}
1456
+?>"/>
1397 1457
 
1398 1458
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
1399 1459
                             name="<?php echo esc_attr($value['id']); ?>_crop"
1400 1460
                             id="<?php echo esc_attr($value['id']); ?>_crop"
1401
-                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label>
1461
+                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') {
1462
+	checked(get_option($value['id'] . '_crop'), 1);
1463
+} else {
1464
+	checked(1);
1465
+}
1466
+?> /></label>
1402 1467
 
1403 1468
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1404 1469
                 </tr><?php
@@ -1412,17 +1477,22 @@  discard block
 block discarded – undo
1412 1477
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
1413 1478
                                             id="<?php echo esc_attr($value['id']); ?>"
1414 1479
                                             style="<?php echo esc_attr($value['css']); ?>"
1415
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1480
+                                            class="<?php if (isset($value['class'])) {
1481
+	echo $value['class'];
1482
+}
1483
+?>"
1416 1484
                                             option-ajaxchosen="false">
1417 1485
                         <?php
1418 1486
                         foreach ($value['options'] as $key => $val) {
1419 1487
                             $geodir_select_value = '';
1420 1488
                             if ($option_value != '') {
1421
-                                if ($option_value != '' && $option_value == $key)
1422
-                                    $geodir_select_value = ' selected="selected" ';
1489
+                                if ($option_value != '' && $option_value == $key) {
1490
+                                                                    $geodir_select_value = ' selected="selected" ';
1491
+                                }
1423 1492
                             } else {
1424
-                                if ($value['std'] == $key)
1425
-                                    $geodir_select_value = ' selected="selected" ';
1493
+                                if ($value['std'] == $key) {
1494
+                                                                    $geodir_select_value = ' selected="selected" ';
1495
+                                }
1426 1496
                             }
1427 1497
                             ?>
1428 1498
                             <option
@@ -1447,8 +1517,14 @@  discard block
 block discarded – undo
1447 1517
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
1448 1518
                                             id="<?php echo esc_attr($value['id']); ?>"
1449 1519
                                             style="<?php echo esc_attr($value['css']); ?>"
1450
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1451
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1520
+                                            class="<?php if (isset($value['class'])) {
1521
+	echo $value['class'];
1522
+}
1523
+?>"
1524
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) {
1525
+	echo $value['placeholder_text'];
1526
+}
1527
+?>"
1452 1528
                                             option-ajaxchosen="false">
1453 1529
                         <?php
1454 1530
                         foreach ($value['options'] as $key => $val) {
@@ -1475,7 +1551,10 @@  discard block
 block discarded – undo
1475 1551
                 <td class="forminp">
1476 1552
                     <input type="file" name="<?php echo esc_attr($value['id']); ?>"
1477 1553
                            id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>"
1478
-                           class="<?php if (isset($value['class'])) echo $value['class']; ?>"/>
1554
+                           class="<?php if (isset($value['class'])) {
1555
+	echo $value['class'];
1556
+}
1557
+?>"/>
1479 1558
                     <?php if (get_option($value['id'])) { ?>
1480 1559
                         <input type="hidden" name="<?php echo esc_attr($value['id']); ?>_remove"
1481 1560
                                id="<?php echo esc_attr($value['id']); ?>_remove" value="0">
@@ -1556,13 +1635,15 @@  discard block
 block discarded – undo
1556 1635
                                 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1557 1636
                             );
1558 1637
                             $geodir_default_map_language = get_option('geodir_default_map_language');
1559
-                            if (empty($geodir_default_map_language))
1560
-                                $geodir_default_map_language = 'en';
1638
+                            if (empty($geodir_default_map_language)) {
1639
+                                                            $geodir_default_map_language = 'en';
1640
+                            }
1561 1641
                             foreach ($arr_map_langages as $language_key => $language_txt) {
1562
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1563
-                                    $geodir_default_language_selected = "selected='selected'";
1564
-                                else
1565
-                                    $geodir_default_language_selected = '';
1642
+                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) {
1643
+                                                                    $geodir_default_language_selected = "selected='selected'";
1644
+                                } else {
1645
+                                                                    $geodir_default_language_selected = '';
1646
+                                }
1566 1647
 
1567 1648
                                 ?>
1568 1649
                                 <option
@@ -1582,14 +1663,16 @@  discard block
 block discarded – undo
1582 1663
                             <?php
1583 1664
                             $post_types = geodir_get_posttypes('array');
1584 1665
                             $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1585
-                            if (empty($geodir_default_map_search_pt))
1586
-                                $geodir_default_map_search_pt = 'gd_place';
1666
+                            if (empty($geodir_default_map_search_pt)) {
1667
+                                                            $geodir_default_map_search_pt = 'gd_place';
1668
+                            }
1587 1669
                             if (is_array($post_types)) {
1588 1670
                                 foreach ($post_types as $key => $post_types_obj) {
1589
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1590
-                                        $geodir_search_pt_selected = "selected='selected'";
1591
-                                    else
1592
-                                        $geodir_search_pt_selected = '';
1671
+                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) {
1672
+                                                                            $geodir_search_pt_selected = "selected='selected'";
1673
+                                    } else {
1674
+                                                                            $geodir_search_pt_selected = '';
1675
+                                    }
1593 1676
 
1594 1677
                                     ?>
1595 1678
                                     <option
@@ -1709,7 +1792,7 @@  discard block
 block discarded – undo
1709 1792
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1710 1793
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1711 1794
                             echo 'checked="checked"';
1712
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1795
+                        } elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1713 1796
                         <?php echo $value['desc']; ?></label><br>
1714 1797
                 </fieldset>
1715 1798
                 <?php
@@ -1729,10 +1812,18 @@  discard block
 block discarded – undo
1729 1812
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1730 1813
                 <td class="forminp">
1731 1814
                     <textarea
1732
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1815
+                        <?php if (isset($value['args'])) {
1816
+	echo $value['args'] . ' ';
1817
+}
1818
+?>name="<?php echo esc_attr($value['id']); ?>"
1733 1819
                         id="<?php echo esc_attr($value['id']); ?>"
1734 1820
                         <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1735
-                        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
1821
+                        style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) {
1822
+	echo esc_textarea(stripslashes(get_option($value['id'])));
1823
+} else {
1824
+	echo esc_textarea($value['std']);
1825
+}
1826
+?></textarea><span
1736 1827
                         class="description"><?php echo $value['desc'] ?></span>
1737 1828
 
1738 1829
                 </td>
@@ -1744,10 +1835,11 @@  discard block
 block discarded – undo
1744 1835
                 <tr valign="top">
1745 1836
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1746 1837
                 <td class="forminp"><?php
1747
-                    if (get_option($value['id']))
1748
-                        $content = stripslashes(get_option($value['id']));
1749
-                    else
1750
-                        $content = $value['std'];
1838
+                    if (get_option($value['id'])) {
1839
+                                            $content = stripslashes(get_option($value['id']));
1840
+                    } else {
1841
+                                            $content = $value['std'];
1842
+                    }
1751 1843
 
1752 1844
                     $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1753 1845
 
@@ -1787,7 +1879,9 @@  discard block
 block discarded – undo
1787 1879
                     'echo' => false,
1788 1880
                     'selected' => $page_setting);
1789 1881
 
1790
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1882
+                if (isset($value['args'])) {
1883
+                	$args = wp_parse_args($value['args'], $args);
1884
+                }
1791 1885
 
1792 1886
                 ?>
1793 1887
                 <tr valign="top" class="single_select_page">
@@ -1806,8 +1900,10 @@  discard block
 block discarded – undo
1806 1900
                 if (strstr($country_setting, ':')) :
1807 1901
                     $country = current(explode(':', $country_setting));
1808 1902
                     $state = end(explode(':', $country_setting));
1809
-                else :
1810
-                    $country = $country_setting;
1903
+                else {
1904
+                	:
1905
+                    $country = $country_setting;
1906
+                }
1811 1907
                     $state = '*';
1812 1908
                 endif;
1813 1909
                 ?>
@@ -1834,8 +1930,10 @@  discard block
 block discarded – undo
1834 1930
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1835 1931
                             title="Country" class="chosen_select">
1836 1932
                         <?php
1837
-                        if ($countries) foreach ($countries as $key => $val) :
1838
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1933
+                        if ($countries) {
1934
+                        	foreach ($countries as $key => $val) :
1935
+                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1936
+                        }
1839 1937
                         endforeach;
1840 1938
                         ?>
1841 1939
                     </select>
@@ -2086,8 +2184,9 @@  discard block
 block discarded – undo
2086 2184
         endforeach;
2087 2185
     endif;
2088 2186
 
2089
-    if (!empty($place_img_array))
2090
-        $curImages = implode(',', $place_img_array);
2187
+    if (!empty($place_img_array)) {
2188
+            $curImages = implode(',', $place_img_array);
2189
+    }
2091 2190
 
2092 2191
 
2093 2192
     // adjust values here
@@ -2433,16 +2532,17 @@  discard block
 block discarded – undo
2433 2532
 	global $post, $typenow, $current_screen;
2434 2533
 	
2435 2534
 	$post_type = NULL;
2436
-    if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2437
-		$post_type = get_post_type($_REQUEST['post']);
2438
-    elseif ($post && isset($post->post_type))
2439
-		$post_type = $post->post_type;
2440
-	elseif ($typenow)
2441
-		$post_type = $typenow;
2442
-	elseif ($current_screen && isset($current_screen->post_type))
2443
-		$post_type = $current_screen->post_type;
2444
-	elseif (isset($_REQUEST['post_type']))
2445
-		$post_type = sanitize_key($_REQUEST['post_type']);
2535
+    if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) {
2536
+    		$post_type = get_post_type($_REQUEST['post']);
2537
+    } elseif ($post && isset($post->post_type)) {
2538
+    		$post_type = $post->post_type;
2539
+    } elseif ($typenow) {
2540
+			$post_type = $typenow;
2541
+	} elseif ($current_screen && isset($current_screen->post_type)) {
2542
+			$post_type = $current_screen->post_type;
2543
+	} elseif (isset($_REQUEST['post_type'])) {
2544
+			$post_type = sanitize_key($_REQUEST['post_type']);
2545
+	}
2446 2546
 
2447 2547
 
2448 2548
 	return $post_type;
@@ -2502,9 +2602,10 @@  discard block
 block discarded – undo
2502 2602
 function geodir_hide_admin_preview_button() {
2503 2603
     global $post_type;
2504 2604
     $post_types = geodir_get_posttypes();
2505
-    if(in_array($post_type, $post_types))
2506
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2507
-}
2605
+    if(in_array($post_type, $post_types)) {
2606
+            echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2607
+    }
2608
+    }
2508 2609
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2509 2610
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2510 2611
 
@@ -5615,8 +5716,9 @@  discard block
 block discarded – undo
5615 5716
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5616 5717
     global $wpdb, $plugin_prefix;
5617 5718
 
5618
-    if ( ! post_type_exists( $post_type ) )
5619
-        return new stdClass;
5719
+    if ( ! post_type_exists( $post_type ) ) {
5720
+            return new stdClass;
5721
+    }
5620 5722
         
5621 5723
     $table = $plugin_prefix . $post_type . '_detail';
5622 5724
 
@@ -6438,7 +6540,9 @@  discard block
 block discarded – undo
6438 6540
 
6439 6541
     if ($page_found) :
6440 6542
         // Page exists
6441
-        if (!$option_value) update_option($option, $page_found);
6543
+        if (!$option_value) {
6544
+        	update_option($option, $page_found);
6545
+        }
6442 6546
         return;
6443 6547
     endif;
6444 6548
 
Please login to merge, or discard this patch.
Indentation   +2911 added lines, -2911 removed lines patch added patch discarded remove patch
@@ -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,125 +32,125 @@  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('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
-        wp_enqueue_style('font-awesome');
89
+		wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
+		wp_enqueue_style('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
-    {
107
-        $geodir_map_name = geodir_map_name();
99
+	/**
100
+	 * Enqueue Admin Scripts.
101
+	 *
102
+	 * @since 1.0.0
103
+	 * @package GeoDirectory
104
+	 */
105
+	function geodir_admin_scripts()
106
+	{
107
+		$geodir_map_name = geodir_map_name();
108 108
         
109
-        wp_enqueue_script('jquery');
109
+		wp_enqueue_script('jquery');
110 110
 
111
-        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
+		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);
112 112
 
113
-        wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
114
-        wp_enqueue_script('chosen');
113
+		wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
114
+		wp_enqueue_script('chosen');
115 115
 
116
-        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
117
-        wp_enqueue_script('geodirectory-choose-ajax');
116
+		wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
117
+		wp_enqueue_script('geodirectory-choose-ajax');
118 118
 
119
-        if (isset($_REQUEST['listing_type'])) {
120
-            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
121
-        }
119
+		if (isset($_REQUEST['listing_type'])) {
120
+			wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
121
+		}
122 122
 
123
-        wp_enqueue_script('geodirectory-custom-fields-script');
124
-        $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
123
+		wp_enqueue_script('geodirectory-custom-fields-script');
124
+		$plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
125 125
 
126
-        wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
126
+		wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
127 127
 
128
-        if (in_array($geodir_map_name, array('auto', 'google'))) {
129
-            $map_lang = "&language=" . geodir_get_map_default_language();
130
-            $map_key = "&key=" . geodir_get_map_api_key();
131
-            /** This filter is documented in geodirectory_template_tags.php */
132
-            $map_extra = apply_filters('geodir_googlemap_script_extra', '');
133
-            wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
134
-        }
128
+		if (in_array($geodir_map_name, array('auto', 'google'))) {
129
+			$map_lang = "&language=" . geodir_get_map_default_language();
130
+			$map_key = "&key=" . geodir_get_map_api_key();
131
+			/** This filter is documented in geodirectory_template_tags.php */
132
+			$map_extra = apply_filters('geodir_googlemap_script_extra', '');
133
+			wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
134
+		}
135 135
         
136
-        if ($geodir_map_name == 'osm') {
137
-            // Leaflet OpenStreetMap
138
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
139
-            wp_enqueue_style('geodirectory-leaflet-style');
136
+		if ($geodir_map_name == 'osm') {
137
+			// Leaflet OpenStreetMap
138
+			wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
139
+			wp_enqueue_style('geodirectory-leaflet-style');
140 140
                 
141
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
142
-            wp_enqueue_script('geodirectory-leaflet-script');
141
+			wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
142
+			wp_enqueue_script('geodirectory-leaflet-script');
143 143
             
144
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
145
-            wp_enqueue_script('geodirectory-leaflet-geo-script');
146
-        }
147
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
144
+			wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
145
+			wp_enqueue_script('geodirectory-leaflet-geo-script');
146
+		}
147
+		wp_enqueue_script( 'jquery-ui-autocomplete' );
148 148
         
149
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
150
-        wp_enqueue_script('geodirectory-goMap-script');
149
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
150
+		wp_enqueue_script('geodirectory-goMap-script');
151 151
 
152
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
153
-        wp_enqueue_script('geodirectory-goMap-script');
152
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
153
+		wp_enqueue_script('geodirectory-goMap-script');
154 154
 
155 155
 		// font awesome rating script
156 156
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
@@ -161,167 +161,167 @@  discard block
 block discarded – undo
161 161
 			wp_enqueue_script('geodir-jRating-js');
162 162
 		}
163 163
 
164
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
165
-        wp_enqueue_script('geodir-on-document-load');
166
-
167
-
168
-        // SCRIPT FOR UPLOAD
169
-        wp_enqueue_script('plupload-all');
170
-        wp_enqueue_script('jquery-ui-sortable');
171
-
172
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
173
-        wp_enqueue_script('geodirectory-plupload-script');
174
-
175
-        // SCRIPT FOR UPLOAD END
176
-
177
-
178
-        // place js config array for plupload
179
-        $plupload_init = array(
180
-            'runtimes' => 'html5,silverlight,flash,html4',
181
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
182
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
183
-            'drop_element' => 'dropbox', // will be adjusted per uploader
184
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
185
-            'multiple_queues' => true,
186
-            'max_file_size' => geodir_max_upload_size(),
187
-            'url' => admin_url('admin-ajax.php'),
188
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
189
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
190
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
191
-            'multipart' => true,
192
-            'urlstream_upload' => true,
193
-            'multi_selection' => false, // will be added per uploader
194
-            // additional post data to send to our ajax hook
195
-            'multipart_params' => array(
196
-                '_ajax_nonce' => "", // will be added per uploader
197
-                'action' => 'plupload_action', // the ajax action name
198
-                'imgid' => 0 // will be added per uploader
199
-            )
200
-        );
201
-        $base_plupload_config = json_encode($plupload_init);
202
-
203
-
204
-        $thumb_img_arr = array();
205
-
206
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
207
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
208
-
209
-        $totImg = '';
210
-        $image_limit = '';
211
-        if (!empty($thumb_img_arr)) {
212
-            $totImg = count($thumb_img_arr);
213
-        }
164
+		wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
165
+		wp_enqueue_script('geodir-on-document-load');
166
+
167
+
168
+		// SCRIPT FOR UPLOAD
169
+		wp_enqueue_script('plupload-all');
170
+		wp_enqueue_script('jquery-ui-sortable');
171
+
172
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
173
+		wp_enqueue_script('geodirectory-plupload-script');
174
+
175
+		// SCRIPT FOR UPLOAD END
176
+
177
+
178
+		// place js config array for plupload
179
+		$plupload_init = array(
180
+			'runtimes' => 'html5,silverlight,flash,html4',
181
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
182
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
183
+			'drop_element' => 'dropbox', // will be adjusted per uploader
184
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
185
+			'multiple_queues' => true,
186
+			'max_file_size' => geodir_max_upload_size(),
187
+			'url' => admin_url('admin-ajax.php'),
188
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
189
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
190
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
191
+			'multipart' => true,
192
+			'urlstream_upload' => true,
193
+			'multi_selection' => false, // will be added per uploader
194
+			// additional post data to send to our ajax hook
195
+			'multipart_params' => array(
196
+				'_ajax_nonce' => "", // will be added per uploader
197
+				'action' => 'plupload_action', // the ajax action name
198
+				'imgid' => 0 // will be added per uploader
199
+			)
200
+		);
201
+		$base_plupload_config = json_encode($plupload_init);
202
+
203
+
204
+		$thumb_img_arr = array();
205
+
206
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
207
+			$thumb_img_arr = geodir_get_images($_REQUEST['pid']);
208
+
209
+		$totImg = '';
210
+		$image_limit = '';
211
+		if (!empty($thumb_img_arr)) {
212
+			$totImg = count($thumb_img_arr);
213
+		}
214 214
 
215
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
216
-            'totalImg' => $totImg,
217
-            'image_limit' => $image_limit,
218
-            'upload_img_size' => geodir_max_upload_size());
215
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
216
+			'totalImg' => $totImg,
217
+			'image_limit' => $image_limit,
218
+			'upload_img_size' => geodir_max_upload_size());
219 219
 
220
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
220
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
221 221
 
222
-        $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
223
-        wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
222
+		$ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
223
+		wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
224 224
 
225 225
 
226
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
227
-        wp_enqueue_script('geodirectory-admin-script');
226
+		wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
227
+		wp_enqueue_script('geodirectory-admin-script');
228 228
 
229
-        wp_enqueue_style('farbtastic');
230
-        wp_enqueue_script('farbtastic');
229
+		wp_enqueue_style('farbtastic');
230
+		wp_enqueue_script('farbtastic');
231 231
 
232
-        $screen = get_current_screen();
233
-        if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
234
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
235
-        }
232
+		$screen = get_current_screen();
233
+		if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
234
+			wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
235
+		}
236 236
 
237
-        $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
238
-        wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
237
+		$ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
238
+		wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
239 239
 
240
-    }
240
+	}
241 241
 }
242 242
 
243 243
 if (!function_exists('geodir_admin_menu')) {
244
-    /**
245
-     * Admin Menus
246
-     *
247
-     * Sets up the admin menus in wordpress.
248
-     *
249
-     * @since 1.0.0
250
-     * @package GeoDirectory
251
-     * @global array $menu Menu array.
252
-     * @global object $geodirectory GeoDirectory plugin object.
253
-     */
254
-    function geodir_admin_menu()
255
-    {
256
-        global $menu, $geodirectory;
244
+	/**
245
+	 * Admin Menus
246
+	 *
247
+	 * Sets up the admin menus in wordpress.
248
+	 *
249
+	 * @since 1.0.0
250
+	 * @package GeoDirectory
251
+	 * @global array $menu Menu array.
252
+	 * @global object $geodirectory GeoDirectory plugin object.
253
+	 */
254
+	function geodir_admin_menu()
255
+	{
256
+		global $menu, $geodirectory;
257 257
 
258
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
258
+		if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
259 259
 
260
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
260
+		add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
261 261
 
262 262
 
263
-    }
263
+	}
264 264
 }
265 265
 
266 266
 if (!function_exists('geodir_admin_menu_order')) {
267
-    /**
268
-     * Order admin menus.
269
-     *
270
-     * @since 1.0.0
271
-     * @package GeoDirectory
272
-     * @param array $menu_order Menu order array.
273
-     * @return array Modified menu order array.
274
-     */
275
-    function geodir_admin_menu_order($menu_order)
276
-    {
277
-
278
-        // Initialize our custom order array
279
-        $geodir_menu_order = array();
280
-
281
-        // Get the index of our custom separator
282
-        $geodir_separator = array_search('separator-geodirectory', $menu_order);
283
-
284
-        // Get index of posttype menu
285
-        $post_types = geodir_get_posttypes();
286
-
287
-        // Loop through menu order and do some rearranging
288
-        foreach ($menu_order as $index => $item) :
289
-
290
-            if ((('geodirectory') == $item)) :
291
-                $geodir_menu_order[] = 'separator-geodirectory';
292
-                if (!empty($post_types)) {
293
-                    foreach ($post_types as $post_type) {
294
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
295
-                    }
296
-                }
297
-                $geodir_menu_order[] = $item;
267
+	/**
268
+	 * Order admin menus.
269
+	 *
270
+	 * @since 1.0.0
271
+	 * @package GeoDirectory
272
+	 * @param array $menu_order Menu order array.
273
+	 * @return array Modified menu order array.
274
+	 */
275
+	function geodir_admin_menu_order($menu_order)
276
+	{
298 277
 
299
-                unset($menu_order[$geodir_separator]);
300
-            //unset( $menu_order[$geodir_places] );
301
-            elseif (!in_array($item, array('separator-geodirectory'))) :
302
-                $geodir_menu_order[] = $item;
303
-            endif;
278
+		// Initialize our custom order array
279
+		$geodir_menu_order = array();
304 280
 
305
-        endforeach;
281
+		// Get the index of our custom separator
282
+		$geodir_separator = array_search('separator-geodirectory', $menu_order);
306 283
 
307
-        // Return order
308
-        return $geodir_menu_order;
309
-    }
284
+		// Get index of posttype menu
285
+		$post_types = geodir_get_posttypes();
286
+
287
+		// Loop through menu order and do some rearranging
288
+		foreach ($menu_order as $index => $item) :
289
+
290
+			if ((('geodirectory') == $item)) :
291
+				$geodir_menu_order[] = 'separator-geodirectory';
292
+				if (!empty($post_types)) {
293
+					foreach ($post_types as $post_type) {
294
+						$geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
295
+					}
296
+				}
297
+				$geodir_menu_order[] = $item;
298
+
299
+				unset($menu_order[$geodir_separator]);
300
+			//unset( $menu_order[$geodir_places] );
301
+			elseif (!in_array($item, array('separator-geodirectory'))) :
302
+				$geodir_menu_order[] = $item;
303
+			endif;
304
+
305
+		endforeach;
306
+
307
+		// Return order
308
+		return $geodir_menu_order;
309
+	}
310 310
 }
311 311
 
312 312
 if (!function_exists('geodir_admin_custom_menu_order')) {
313
-    /**
314
-     * Enables custom menu order.
315
-     *
316
-     * @since 1.0.0
317
-     * @package GeoDirectory
318
-     * @return bool
319
-     */
320
-    function geodir_admin_custom_menu_order()
321
-    {
322
-        if (!current_user_can('manage_options')) return false;
323
-        return true;
324
-    }
313
+	/**
314
+	 * Enables custom menu order.
315
+	 *
316
+	 * @since 1.0.0
317
+	 * @package GeoDirectory
318
+	 * @return bool
319
+	 */
320
+	function geodir_admin_custom_menu_order()
321
+	{
322
+		if (!current_user_can('manage_options')) return false;
323
+		return true;
324
+	}
325 325
 }
326 326
 
327 327
 /**
@@ -332,51 +332,51 @@  discard block
 block discarded – undo
332 332
  */
333 333
 function geodir_before_admin_panel()
334 334
 {
335
-    if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
336
-        echo '<div id="message" class="updated fade">
335
+	if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
336
+		echo '<div id="message" class="updated fade">
337 337
                         <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>
338 338
                         <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
339 339
                 </div>';
340 340
 
341
-    }
341
+	}
342 342
 
343
-    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
344
-        switch ($_REQUEST['msg']) {
345
-            case 'success':
346
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
347
-                flush_rewrite_rules(false);
343
+	if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
344
+		switch ($_REQUEST['msg']) {
345
+			case 'success':
346
+				echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
347
+				flush_rewrite_rules(false);
348 348
 
349
-                break;
349
+				break;
350 350
 			case 'fail':
351 351
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
352 352
 				
353 353
 				if ($gderr == 21)
354
-			    	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>';
354
+					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>';
355 355
 				else
356 356
 					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
357
-                break;
358
-        }
359
-    }
357
+				break;
358
+		}
359
+	}
360 360
 
361
-    $geodir_load_map = get_option('geodir_load_map');
362
-    $need_map_key = false;
363
-    if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
364
-        $need_map_key = true;
365
-    }
361
+	$geodir_load_map = get_option('geodir_load_map');
362
+	$need_map_key = false;
363
+	if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
364
+		$need_map_key = true;
365
+	}
366 366
 
367
-    if (!geodir_get_map_api_key() && $need_map_key) {
368
-        echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
369
-    }
367
+	if (!geodir_get_map_api_key() && $need_map_key) {
368
+		echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
369
+	}
370 370
 
371
-    if (!geodir_is_default_location_set()) {
372
-        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>';
371
+	if (!geodir_is_default_location_set()) {
372
+		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>';
373 373
 
374
-    }
374
+	}
375 375
 
376
-    if (!function_exists('curl_init')) {
377
-        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>';
376
+	if (!function_exists('curl_init')) {
377
+		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>';
378 378
 
379
-    }
379
+	}
380 380
 
381 381
 
382 382
 
@@ -393,19 +393,19 @@  discard block
 block discarded – undo
393 393
  */
394 394
 function geodir_handle_option_form_submit($current_tab)
395 395
 {
396
-    global $geodir_settings;
397
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
398
-        /**
399
-         * Contains settings array for current tab.
400
-         *
401
-         * @since 1.0.0
402
-         * @package GeoDirectory
403
-         */
404
-        include_once('option-pages/' . $current_tab . '_array.php');
405
-    }
406
-    if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
407
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
408
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
396
+	global $geodir_settings;
397
+	if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
398
+		/**
399
+		 * Contains settings array for current tab.
400
+		 *
401
+		 * @since 1.0.0
402
+		 * @package GeoDirectory
403
+		 */
404
+		include_once('option-pages/' . $current_tab . '_array.php');
405
+	}
406
+	if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
407
+		if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
408
+		if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
409 409
 		
410 410
 		/**
411 411
 		 * Fires before updating geodirectory admin settings.
@@ -417,98 +417,98 @@  discard block
 block discarded – undo
417 417
 		 */
418 418
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
419 419
 		
420
-        if (!empty($geodir_settings[$current_tab]))
421
-            geodir_update_options($geodir_settings[$current_tab]);
420
+		if (!empty($geodir_settings[$current_tab]))
421
+			geodir_update_options($geodir_settings[$current_tab]);
422 422
 
423
-        /**
424
-         * Called after GeoDirectory options settings are updated.
425
-         *
426
-         * @since 1.0.0
427
-         * @param array $geodir_settings The array of GeoDirectory settings.
428
-         * @see 'geodir_before_update_options'
429
-         */
430
-        do_action('geodir_update_options', $geodir_settings);
423
+		/**
424
+		 * Called after GeoDirectory options settings are updated.
425
+		 *
426
+		 * @since 1.0.0
427
+		 * @param array $geodir_settings The array of GeoDirectory settings.
428
+		 * @see 'geodir_before_update_options'
429
+		 */
430
+		do_action('geodir_update_options', $geodir_settings);
431 431
 
432
-        /**
433
-         * Called after GeoDirectory options settings are updated.
434
-         *
435
-         * Provides tab specific settings.
436
-         *
437
-         * @since 1.0.0
438
-         * @param string $current_tab The current settings tab name.
439
-         * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
440
-         */
441
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
432
+		/**
433
+		 * Called after GeoDirectory options settings are updated.
434
+		 *
435
+		 * Provides tab specific settings.
436
+		 *
437
+		 * @since 1.0.0
438
+		 * @param string $current_tab The current settings tab name.
439
+		 * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
440
+		 */
441
+		do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
442 442
 
443
-        flush_rewrite_rules(false);
443
+		flush_rewrite_rules(false);
444 444
 
445
-        $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
445
+		$current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
446 446
 
447
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
447
+		$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
448 448
 
449
-        wp_redirect($redirect_url);
450
-        exit();
451
-    endif;
449
+		wp_redirect($redirect_url);
450
+		exit();
451
+	endif;
452 452
 
453 453
 
454 454
 }
455 455
 
456 456
 
457 457
 if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
458
-    /**
459
-     * GeoDirectory dummy data installation.
460
-     *
461
-     * @since 1.0.0
462
-     * @package GeoDirectory
463
-     * @global object $wpdb WordPress Database object.
464
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
465
-     * @param string $post_type The post type.
466
-     */
467
-    function geodir_autoinstall_admin_header($post_type = 'gd_place')
468
-    {
458
+	/**
459
+	 * GeoDirectory dummy data installation.
460
+	 *
461
+	 * @since 1.0.0
462
+	 * @package GeoDirectory
463
+	 * @global object $wpdb WordPress Database object.
464
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
465
+	 * @param string $post_type The post type.
466
+	 */
467
+	function geodir_autoinstall_admin_header($post_type = 'gd_place')
468
+	{
469 469
 
470
-        global $wpdb, $plugin_prefix;
470
+		global $wpdb, $plugin_prefix;
471 471
 
472
-        if (!geodir_is_default_location_set()) {
473
-            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>';
474
-        } else {
472
+		if (!geodir_is_default_location_set()) {
473
+			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>';
474
+		} else {
475 475
 
476
-            $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
476
+			$geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
477 477
 
478
-            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
478
+			$post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
479 479
 
480
-            if ($post_counts > 0) {
481
-                $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
480
+			if ($post_counts > 0) {
481
+				$nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
482 482
 
483
-                $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>';
484
-                $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>';
485
-            } else {
486
-                $options_list = '';
487
-                for ($option = 1; $option <= 30; $option++) {
488
-                    $selected = '';
489
-                    if ($option == 10)
490
-                        $selected = 'selected="selected"';
483
+				$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>';
484
+				$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>';
485
+			} else {
486
+				$options_list = '';
487
+				for ($option = 1; $option <= 30; $option++) {
488
+					$selected = '';
489
+					if ($option == 10)
490
+						$selected = 'selected="selected"';
491 491
 
492
-                    $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
493
-                }
492
+					$options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
493
+				}
494 494
 
495
-                $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
495
+				$nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
496 496
 
497
-                $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>';
498
-                $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>';
497
+				$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>';
498
+				$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>';
499 499
 
500
-            }
501
-            echo $dummy_msg;
502
-            ?>
500
+			}
501
+			echo $dummy_msg;
502
+			?>
503 503
             <script>
504 504
                 <?php
505
-                  $default_location = geodir_get_default_location();
506
-                  $city =  isset($default_location->city) ? $default_location->city : '';
507
-                  $region =isset($default_location->region) ? $default_location->region : '';
508
-                  $country =isset($default_location->country) ? $default_location->country : '';
509
-                  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
510
-                  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
511
-                ?>
505
+				  $default_location = geodir_get_default_location();
506
+				  $city =  isset($default_location->city) ? $default_location->city : '';
507
+				  $region =isset($default_location->region) ? $default_location->region : '';
508
+				  $country =isset($default_location->country) ? $default_location->country : '';
509
+				  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
510
+				  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
511
+				?>
512 512
                 var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null;
513 513
                 var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>';
514 514
                 var bound_lat_lng;
@@ -599,8 +599,8 @@  discard block
 block discarded – undo
599 599
                 }
600 600
             </script>
601 601
         <?php
602
-        }
603
-    }
602
+		}
603
+	}
604 604
 }
605 605
 
606 606
 /**
@@ -613,20 +613,20 @@  discard block
 block discarded – undo
613 613
  */
614 614
 function geodir_insert_dummy_posts()
615 615
 {
616
-    geodir_default_taxonomies();
616
+	geodir_default_taxonomies();
617 617
 
618
-    ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
618
+	ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
619 619
 
620
-    global $wpdb, $current_user;
620
+	global $wpdb, $current_user;
621 621
 
622
-    /**
623
-     * Contains dummy post content.
624
-     *
625
-     * @since 1.0.0
626
-     * @package GeoDirectory
627
-     */
628
-    include_once('place_dummy_post.php');
629
-    delete_transient( 'cached_dummy_images' );
622
+	/**
623
+	 * Contains dummy post content.
624
+	 *
625
+	 * @since 1.0.0
626
+	 * @package GeoDirectory
627
+	 */
628
+	include_once('place_dummy_post.php');
629
+	delete_transient( 'cached_dummy_images' );
630 630
 
631 631
 }
632 632
 
@@ -640,18 +640,18 @@  discard block
 block discarded – undo
640 640
  */
641 641
 function geodir_delete_dummy_posts()
642 642
 {
643
-    global $wpdb, $plugin_prefix;
643
+	global $wpdb, $plugin_prefix;
644 644
 
645 645
 
646
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
646
+	$post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
647 647
 
648 648
 
649
-    foreach ($post_ids as $post_ids_obj) {
650
-        wp_delete_post($post_ids_obj->post_id);
651
-    }
649
+	foreach ($post_ids as $post_ids_obj) {
650
+		wp_delete_post($post_ids_obj->post_id);
651
+	}
652 652
 
653
-    //double check posts are deleted
654
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
653
+	//double check posts are deleted
654
+	$wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
655 655
 }
656 656
 
657 657
 /**
@@ -665,114 +665,114 @@  discard block
 block discarded – undo
665 665
  * @global string $dummy_image_path The dummy image path.
666 666
  */
667 667
 function geodir_default_taxonomies() {
668
-    global $wpdb, $dummy_image_path;
668
+	global $wpdb, $dummy_image_path;
669 669
 
670
-    $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
670
+	$category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
671 671
 
672
-    $last_catid = '';
672
+	$last_catid = '';
673 673
 
674
-    $uploads = wp_upload_dir(); // Array of key => value pairs
674
+	$uploads = wp_upload_dir(); // Array of key => value pairs
675 675
 
676
-    for ($i = 0; $i < count($category_array); $i++) {
677
-        $parent_catid = 0;
678
-        if (is_array($category_array[$i])) {
679
-            $cat_name_arr = $category_array[$i];
680
-            for ($j = 0; $j < count($cat_name_arr); $j++) {
681
-                $catname = $cat_name_arr[$j];
676
+	for ($i = 0; $i < count($category_array); $i++) {
677
+		$parent_catid = 0;
678
+		if (is_array($category_array[$i])) {
679
+			$cat_name_arr = $category_array[$i];
680
+			for ($j = 0; $j < count($cat_name_arr); $j++) {
681
+				$catname = $cat_name_arr[$j];
682 682
 
683
-                if (!term_exists($catname, 'gd_placecategory')) {
684
-                    $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
683
+				if (!term_exists($catname, 'gd_placecategory')) {
684
+					$last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
685 685
 
686
-                    if ($j == 0) {
687
-                        $parent_catid = $last_catid;
688
-                    }
686
+					if ($j == 0) {
687
+						$parent_catid = $last_catid;
688
+					}
689 689
 
690 690
 
691
-                    if (geodir_dummy_folder_exists())
692
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
693
-                    else
694
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
691
+					if (geodir_dummy_folder_exists())
692
+						$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
693
+					else
694
+						$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
695 695
 
696
-                    $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
696
+					$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
697 697
 
698
-                    $catname = str_replace(' ', '_', $catname);
699
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
698
+					$catname = str_replace(' ', '_', $catname);
699
+					$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
700 700
 
701
-                    if (empty($uploaded['error'])) {
702
-                        $new_path = $uploaded['file'];
703
-                        $new_url = $uploaded['url'];
704
-                    }
701
+					if (empty($uploaded['error'])) {
702
+						$new_path = $uploaded['file'];
703
+						$new_url = $uploaded['url'];
704
+					}
705 705
 
706
-                    $wp_filetype = wp_check_filetype(basename($new_path), null);
707
-
708
-                    $attachment = array(
709
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
710
-                        'post_mime_type' => $wp_filetype['type'],
711
-                        'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
712
-                        'post_content' => '',
713
-                        'post_status' => 'inherit'
714
-                    );
715
-                    $attach_id = wp_insert_attachment($attachment, $new_path);
716
-
717
-                    // you must first include the image.php file
718
-                    // for the function wp_generate_attachment_metadata() to work
719
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
720
-                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
721
-                    wp_update_attachment_metadata($attach_id, $attach_data);
722
-
723
-                    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
724
-                        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
725
-                    }
726
-                }
727
-            }
706
+					$wp_filetype = wp_check_filetype(basename($new_path), null);
707
+
708
+					$attachment = array(
709
+						'guid' => $uploads['baseurl'] . '/' . basename($new_path),
710
+						'post_mime_type' => $wp_filetype['type'],
711
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
712
+						'post_content' => '',
713
+						'post_status' => 'inherit'
714
+					);
715
+					$attach_id = wp_insert_attachment($attachment, $new_path);
716
+
717
+					// you must first include the image.php file
718
+					// for the function wp_generate_attachment_metadata() to work
719
+					require_once(ABSPATH . 'wp-admin/includes/image.php');
720
+					$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
721
+					wp_update_attachment_metadata($attach_id, $attach_data);
722
+
723
+					if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
724
+						update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
725
+					}
726
+				}
727
+			}
728 728
 
729
-        } else {
730
-            $catname = $category_array[$i];
729
+		} else {
730
+			$catname = $category_array[$i];
731 731
 
732
-            if (!term_exists($catname, 'gd_placecategory')) {
733
-                $last_catid = wp_insert_term($catname, 'gd_placecategory');
732
+			if (!term_exists($catname, 'gd_placecategory')) {
733
+				$last_catid = wp_insert_term($catname, 'gd_placecategory');
734 734
 
735
-                if (geodir_dummy_folder_exists())
736
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
737
-                else
738
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
735
+				if (geodir_dummy_folder_exists())
736
+					$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
737
+				else
738
+					$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
739 739
 
740
-                $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
740
+				$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
741 741
 
742
-                $catname = str_replace(' ', '_', $catname);
743
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
742
+				$catname = str_replace(' ', '_', $catname);
743
+				$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
744 744
 
745
-                if (empty($uploaded['error'])) {
746
-                    $new_path = $uploaded['file'];
747
-                    $new_url = $uploaded['url'];
748
-                }
745
+				if (empty($uploaded['error'])) {
746
+					$new_path = $uploaded['file'];
747
+					$new_url = $uploaded['url'];
748
+				}
749 749
 
750
-                $wp_filetype = wp_check_filetype(basename($new_path), null);
750
+				$wp_filetype = wp_check_filetype(basename($new_path), null);
751 751
 
752
-                $attachment = array(
753
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
754
-                    'post_mime_type' => $wp_filetype['type'],
755
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
756
-                    'post_content' => '',
757
-                    'post_status' => 'inherit'
758
-                );
752
+				$attachment = array(
753
+					'guid' => $uploads['baseurl'] . '/' . basename($new_path),
754
+					'post_mime_type' => $wp_filetype['type'],
755
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
756
+					'post_content' => '',
757
+					'post_status' => 'inherit'
758
+				);
759 759
 
760
-                $attach_id = wp_insert_attachment($attachment, $new_path);
760
+				$attach_id = wp_insert_attachment($attachment, $new_path);
761 761
 
762 762
 
763
-                // you must first include the image.php file
764
-                // for the function wp_generate_attachment_metadata() to work
765
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
766
-                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
767
-                wp_update_attachment_metadata($attach_id, $attach_data);
763
+				// you must first include the image.php file
764
+				// for the function wp_generate_attachment_metadata() to work
765
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
766
+				$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
767
+				wp_update_attachment_metadata($attach_id, $attach_data);
768 768
 
769
-                if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
770
-                    update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
771
-                }
772
-            }
773
-        }
769
+				if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
770
+					update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
771
+				}
772
+			}
773
+		}
774 774
 
775
-    }
775
+	}
776 776
 }
777 777
 
778 778
 /**
@@ -787,144 +787,144 @@  discard block
 block discarded – undo
787 787
  * @return bool Returns true if saved.
788 788
  */
789 789
 function geodir_update_options($options, $dummy = false) {
790
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
790
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
791 791
 
792
-    foreach ($options as $value) {
793
-        if ($dummy && isset($value['std']))
794
-            $_POST[$value['id']] = $value['std'];
792
+	foreach ($options as $value) {
793
+		if ($dummy && isset($value['std']))
794
+			$_POST[$value['id']] = $value['std'];
795 795
 
796 796
 
797
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
797
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
798 798
 
799
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
800
-                update_option($value['id'], $_POST[$value['id']]);
801
-            } else {
802
-                update_option($value['id'], 0);
803
-            }
799
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
800
+				update_option($value['id'], $_POST[$value['id']]);
801
+			} else {
802
+				update_option($value['id'], 0);
803
+			}
804 804
 
805
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
805
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
806 806
 
807
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
808
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
809
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
810
-                if (isset($_POST[$value['id'] . '_crop'])) :
811
-                    update_option($value['id'] . '_crop', 1);
812
-                else :
813
-                    update_option($value['id'] . '_crop', 0);
814
-                endif;
815
-            } else {
816
-                update_option($value['id'] . '_width', $value['std']);
817
-                update_option($value['id'] . '_height', $value['std']);
818
-                update_option($value['id'] . '_crop', 1);
819
-            }
807
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
808
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
809
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
810
+				if (isset($_POST[$value['id'] . '_crop'])) :
811
+					update_option($value['id'] . '_crop', 1);
812
+				else :
813
+					update_option($value['id'] . '_crop', 0);
814
+				endif;
815
+			} else {
816
+				update_option($value['id'] . '_width', $value['std']);
817
+				update_option($value['id'] . '_height', $value['std']);
818
+				update_option($value['id'] . '_crop', 1);
819
+			}
820 820
 
821
-        elseif (isset($value['type']) && $value['type'] == 'map') :
822
-            $post_types = array();
823
-            $categories = array();
821
+		elseif (isset($value['type']) && $value['type'] == 'map') :
822
+			$post_types = array();
823
+			$categories = array();
824 824
 
825
-            if (!empty($_POST['home_map_post_types'])) :
826
-                foreach ($_POST['home_map_post_types'] as $post_type) :
827
-                    $post_types[] = $post_type;
828
-                endforeach;
829
-            endif;
825
+			if (!empty($_POST['home_map_post_types'])) :
826
+				foreach ($_POST['home_map_post_types'] as $post_type) :
827
+					$post_types[] = $post_type;
828
+				endforeach;
829
+			endif;
830 830
 
831
-            update_option('geodir_exclude_post_type_on_map', $post_types);
831
+			update_option('geodir_exclude_post_type_on_map', $post_types);
832 832
 
833
-            if (!empty($_POST['post_category'])) :
834
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
835
-                    $categories[$texonomy] = array();
836
-                    foreach ($cat_arr as $category) :
837
-                        $categories[$texonomy][] = $category;
838
-                    endforeach;
839
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
840
-                endforeach;
841
-            endif;
842
-            update_option('geodir_exclude_cat_on_map', $categories);
843
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
844
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
833
+			if (!empty($_POST['post_category'])) :
834
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
835
+					$categories[$texonomy] = array();
836
+					foreach ($cat_arr as $category) :
837
+						$categories[$texonomy][] = $category;
838
+					endforeach;
839
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
840
+				endforeach;
841
+			endif;
842
+			update_option('geodir_exclude_cat_on_map', $categories);
843
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
844
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
845 845
 
846 846
 
847
-            if (!empty($_POST['geodir_default_map_language'])):
848
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
849
-            endif;
847
+			if (!empty($_POST['geodir_default_map_language'])):
848
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
849
+			endif;
850 850
 
851 851
 
852
-            if (!empty($_POST['geodir_default_map_search_pt'])):
853
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
854
-            endif;
852
+			if (!empty($_POST['geodir_default_map_search_pt'])):
853
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
854
+			endif;
855 855
 
856 856
 
857
-        elseif (isset($value['type']) && $value['type'] == 'file') :
857
+		elseif (isset($value['type']) && $value['type'] == 'file') :
858 858
 
859 859
 
860
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
860
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
861 861
 
862
-                if (get_option($value['id'])) {
863
-                    $image_name_arr = explode('/', get_option($value['id']));
864
-                    $noimg_name = end($image_name_arr);
865
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
866
-                    if (file_exists($img_path))
867
-                        unlink($img_path);
868
-                }
862
+				if (get_option($value['id'])) {
863
+					$image_name_arr = explode('/', get_option($value['id']));
864
+					$noimg_name = end($image_name_arr);
865
+					$img_path = $uploads['path'] . '/' . $noimg_name;
866
+					if (file_exists($img_path))
867
+						unlink($img_path);
868
+				}
869 869
 
870
-                update_option($value['id'], '');
871
-            }
870
+				update_option($value['id'], '');
871
+			}
872 872
 
873
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
874
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
875
-
876
-            if (!empty($filename)):
877
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
878
-                $uplaods = array();
879
-
880
-                foreach ($uploadedfile as $key => $uplaod):
881
-                    if ($key == 'name'):
882
-                        $uplaods[$key] = $filename;
883
-                    else :
884
-                        $uplaods[$key] = $uplaod;
885
-                    endif;
886
-                endforeach;
887
-
888
-                $uploads = wp_upload_dir();
889
-
890
-                if (get_option($value['id'])) {
891
-                    $image_name_arr = explode('/', get_option($value['id']));
892
-                    $noimg_name = end($image_name_arr);
893
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
894
-                    if (file_exists($img_path))
895
-                        unlink($img_path);
896
-                }
873
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
874
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
875
+
876
+			if (!empty($filename)):
877
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
878
+				$uplaods = array();
879
+
880
+				foreach ($uploadedfile as $key => $uplaod):
881
+					if ($key == 'name'):
882
+						$uplaods[$key] = $filename;
883
+					else :
884
+						$uplaods[$key] = $uplaod;
885
+					endif;
886
+				endforeach;
887
+
888
+				$uploads = wp_upload_dir();
889
+
890
+				if (get_option($value['id'])) {
891
+					$image_name_arr = explode('/', get_option($value['id']));
892
+					$noimg_name = end($image_name_arr);
893
+					$img_path = $uploads['path'] . '/' . $noimg_name;
894
+					if (file_exists($img_path))
895
+						unlink($img_path);
896
+				}
897 897
 
898
-                $upload_overrides = array('test_form' => false);
899
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
898
+				$upload_overrides = array('test_form' => false);
899
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
900 900
 
901
-                update_option($value['id'], $movefile['url']);
901
+				update_option($value['id'], $movefile['url']);
902 902
 
903
-            endif;
903
+			endif;
904 904
 
905
-            if (!get_option($value['id']) && isset($value['value'])):
906
-                update_option($value['id'], $value['value']);
907
-            endif;
905
+			if (!get_option($value['id']) && isset($value['value'])):
906
+				update_option($value['id'], $value['value']);
907
+			endif;
908 908
 
909 909
 
910
-        else :
911
-            // same menu setting per theme.
912
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
913
-                $theme = wp_get_theme();
914
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
915
-            }
910
+		else :
911
+			// same menu setting per theme.
912
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
913
+				$theme = wp_get_theme();
914
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
915
+			}
916 916
 
917
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
918
-                update_option($value['id'], $_POST[$value['id']]);
919
-            } else {
920
-                delete_option($value['id']);
921
-            }
917
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
918
+				update_option($value['id'], $_POST[$value['id']]);
919
+			} else {
920
+				delete_option($value['id']);
921
+			}
922 922
 
923
-        endif;
924
-    }
925
-    if ($dummy)
926
-        $_POST = array();
927
-    return true;
923
+		endif;
924
+	}
925
+	if ($dummy)
926
+		$_POST = array();
927
+	return true;
928 928
 
929 929
 }
930 930
 
@@ -973,33 +973,33 @@  discard block
 block discarded – undo
973 973
 function places_custom_fields_tab($tabs)
974 974
 {
975 975
 
976
-    $geodir_post_types = get_option('geodir_post_types');
976
+	$geodir_post_types = get_option('geodir_post_types');
977 977
 
978
-    if (!empty($geodir_post_types)) {
978
+	if (!empty($geodir_post_types)) {
979 979
 
980
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
980
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
981 981
 
982
-            $listing_slug = $geodir_posttype_info['labels']['singular_name'];
982
+			$listing_slug = $geodir_posttype_info['labels']['singular_name'];
983 983
 
984
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
985
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
986
-                'subtabs' => array(
987
-                    array('subtab' => 'custom_fields',
988
-                        'label' => __('Custom Fields', 'geodirectory'),
989
-                        'request' => array('listing_type' => $geodir_post_type)),
990
-                    array('subtab' => 'sorting_options',
991
-                        'label' => __('Sorting Options', 'geodirectory'),
992
-                        'request' => array('listing_type' => $geodir_post_type)),
993
-                ),
994
-                'tab_index' => 9,
995
-                'request' => array('listing_type' => $geodir_post_type)
996
-            );
984
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
985
+				'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
986
+				'subtabs' => array(
987
+					array('subtab' => 'custom_fields',
988
+						'label' => __('Custom Fields', 'geodirectory'),
989
+						'request' => array('listing_type' => $geodir_post_type)),
990
+					array('subtab' => 'sorting_options',
991
+						'label' => __('Sorting Options', 'geodirectory'),
992
+						'request' => array('listing_type' => $geodir_post_type)),
993
+				),
994
+				'tab_index' => 9,
995
+				'request' => array('listing_type' => $geodir_post_type)
996
+			);
997 997
 
998
-        endforeach;
998
+		endforeach;
999 999
 
1000
-    }
1000
+	}
1001 1001
 
1002
-    return $tabs;
1002
+	return $tabs;
1003 1003
 }
1004 1004
 
1005 1005
 
@@ -1015,9 +1015,9 @@  discard block
 block discarded – undo
1015 1015
  */
1016 1016
 function geodir_tools_setting_tab($tabs)
1017 1017
 {
1018
-    wp_enqueue_script( 'jquery-ui-progressbar' );
1019
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1020
-    return $tabs;
1018
+	wp_enqueue_script( 'jquery-ui-progressbar' );
1019
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1020
+	return $tabs;
1021 1021
 }
1022 1022
 
1023 1023
 /**
@@ -1032,8 +1032,8 @@  discard block
 block discarded – undo
1032 1032
  */
1033 1033
 function geodir_compatibility_setting_tab($tabs)
1034 1034
 {
1035
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1036
-    return $tabs;
1035
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1036
+	return $tabs;
1037 1037
 }
1038 1038
 
1039 1039
 
@@ -1049,144 +1049,144 @@  discard block
 block discarded – undo
1049 1049
  */
1050 1050
 function geodir_extend_geodirectory_setting_tab($tabs)
1051 1051
 {
1052
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1053
-    return $tabs;
1052
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1053
+	return $tabs;
1054 1054
 }
1055 1055
 
1056 1056
 
1057 1057
 if (!function_exists('geodir_edit_post_columns')) {
1058
-    /**
1059
-     * Modify admin post listing page columns.
1060
-     *
1061
-     * @since 1.0.0
1062
-     * @package GeoDirectory
1063
-     * @param array $columns The column array.
1064
-     * @return array Altered column array.
1065
-     */
1066
-    function geodir_edit_post_columns($columns)
1067
-    {
1068
-
1069
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1070
-            'categorys' => __('Categories', 'geodirectory'));
1071
-
1072
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1073
-        {
1074
-            $offset = 0; // should we prepend $array with $data?
1075
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
1076
-        }
1058
+	/**
1059
+	 * Modify admin post listing page columns.
1060
+	 *
1061
+	 * @since 1.0.0
1062
+	 * @package GeoDirectory
1063
+	 * @param array $columns The column array.
1064
+	 * @return array Altered column array.
1065
+	 */
1066
+	function geodir_edit_post_columns($columns)
1067
+	{
1068
+
1069
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1070
+			'categorys' => __('Categories', 'geodirectory'));
1077 1071
 
1078
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1072
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1073
+		{
1074
+			$offset = 0; // should we prepend $array with $data?
1075
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
1076
+		}
1079 1077
 
1080
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1078
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1081 1079
 
1082
-        return $columns;
1083
-    }
1080
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1081
+
1082
+		return $columns;
1083
+	}
1084 1084
 }
1085 1085
 
1086 1086
 
1087 1087
 if (!function_exists('geodir_manage_post_columns')) {
1088
-    /**
1089
-     * Adds content to our custom post listing page columns.
1090
-     *
1091
-     * @since 1.0.0
1092
-     * @package GeoDirectory
1093
-     * @global object $wpdb WordPress Database object.
1094
-     * @global object $post WordPress Post object.
1095
-     * @param string $column The column name.
1096
-     * @param int $post_id The post ID.
1097
-     */
1098
-    function geodir_manage_post_columns($column, $post_id)
1099
-    {
1100
-        global $post, $wpdb;
1101
-
1102
-        switch ($column):
1103
-            /* If displaying the 'city' column. */
1104
-            case 'location' :
1105
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1106
-                $location = geodir_get_location($location_id);
1107
-                /* If no city is found, output a default message. */
1108
-                if (empty($location)) {
1109
-                    _e('Unknown', 'geodirectory');
1110
-                } else {
1111
-                    /* If there is a city id, append 'city name' to the text string. */
1112
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1113
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1114
-                }
1115
-                break;
1116
-
1117
-            /* If displaying the 'expire' column. */
1118
-            case 'expire' :
1119
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1120
-                $d1 = $expire_date; // get expire_date
1121
-                $d2 = date('Y-m-d'); // get current date
1122
-                $state = __('days left', 'geodirectory');
1123
-                $date_diff_text = '';
1124
-                $expire_class = 'expire_left';
1125
-                if ($expire_date != 'Never') {
1126
-                    if (strtotime($d1) < strtotime($d2)) {
1127
-                        $state = __('days overdue', 'geodirectory');
1128
-                        $expire_class = 'expire_over';
1129
-                    }
1130
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1131
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1132
-                }
1133
-                /* If no expire_date is found, output a default message. */
1134
-                if (empty($expire_date))
1135
-                    echo __('Unknown', 'geodirectory');
1136
-                /* If there is a expire_date, append 'days left' to the text string. */
1137
-                else
1138
-                    echo $expire_date . $date_diff_text;
1139
-                break;
1140
-
1141
-            /* If displaying the 'categorys' column. */
1142
-            case 'categorys' :
1143
-
1144
-                /* Get the categorys for the post. */
1145
-
1146
-
1147
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1148
-
1149
-                /* If terms were found. */
1150
-                if (!empty($terms)) {
1151
-                    $out = array();
1152
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
1153
-                    foreach ($terms as $term) {
1154
-                        if (!strstr($term->taxonomy, 'tag')) {
1155
-                            $out[] = sprintf('<a href="%s">%s</a>',
1156
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1157
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1158
-                            );
1159
-                        }
1160
-                    }
1161
-                    /* Join the terms, separating them with a comma. */
1162
-                    echo(join(', ', $out));
1163
-                } /* If no terms were found, output a default message. */
1164
-                else {
1165
-                    _e('No Categories', 'geodirectory');
1166
-                }
1167
-                break;
1088
+	/**
1089
+	 * Adds content to our custom post listing page columns.
1090
+	 *
1091
+	 * @since 1.0.0
1092
+	 * @package GeoDirectory
1093
+	 * @global object $wpdb WordPress Database object.
1094
+	 * @global object $post WordPress Post object.
1095
+	 * @param string $column The column name.
1096
+	 * @param int $post_id The post ID.
1097
+	 */
1098
+	function geodir_manage_post_columns($column, $post_id)
1099
+	{
1100
+		global $post, $wpdb;
1101
+
1102
+		switch ($column):
1103
+			/* If displaying the 'city' column. */
1104
+			case 'location' :
1105
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1106
+				$location = geodir_get_location($location_id);
1107
+				/* If no city is found, output a default message. */
1108
+				if (empty($location)) {
1109
+					_e('Unknown', 'geodirectory');
1110
+				} else {
1111
+					/* If there is a city id, append 'city name' to the text string. */
1112
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1113
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1114
+				}
1115
+				break;
1116
+
1117
+			/* If displaying the 'expire' column. */
1118
+			case 'expire' :
1119
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1120
+				$d1 = $expire_date; // get expire_date
1121
+				$d2 = date('Y-m-d'); // get current date
1122
+				$state = __('days left', 'geodirectory');
1123
+				$date_diff_text = '';
1124
+				$expire_class = 'expire_left';
1125
+				if ($expire_date != 'Never') {
1126
+					if (strtotime($d1) < strtotime($d2)) {
1127
+						$state = __('days overdue', 'geodirectory');
1128
+						$expire_class = 'expire_over';
1129
+					}
1130
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1131
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1132
+				}
1133
+				/* If no expire_date is found, output a default message. */
1134
+				if (empty($expire_date))
1135
+					echo __('Unknown', 'geodirectory');
1136
+				/* If there is a expire_date, append 'days left' to the text string. */
1137
+				else
1138
+					echo $expire_date . $date_diff_text;
1139
+				break;
1168 1140
 
1169
-        endswitch;
1170
-    }
1141
+			/* If displaying the 'categorys' column. */
1142
+			case 'categorys' :
1143
+
1144
+				/* Get the categorys for the post. */
1145
+
1146
+
1147
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1148
+
1149
+				/* If terms were found. */
1150
+				if (!empty($terms)) {
1151
+					$out = array();
1152
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
1153
+					foreach ($terms as $term) {
1154
+						if (!strstr($term->taxonomy, 'tag')) {
1155
+							$out[] = sprintf('<a href="%s">%s</a>',
1156
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1157
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1158
+							);
1159
+						}
1160
+					}
1161
+					/* Join the terms, separating them with a comma. */
1162
+					echo(join(', ', $out));
1163
+				} /* If no terms were found, output a default message. */
1164
+				else {
1165
+					_e('No Categories', 'geodirectory');
1166
+				}
1167
+				break;
1168
+
1169
+		endswitch;
1170
+	}
1171 1171
 }
1172 1172
 
1173 1173
 
1174 1174
 if (!function_exists('geodir_post_sortable_columns')) {
1175
-    /**
1176
-     * Makes admin post listing page columns sortable.
1177
-     *
1178
-     * @since 1.0.0
1179
-     * @package GeoDirectory
1180
-     * @param array $columns The column array.
1181
-     * @return array Altered column array.
1182
-     */
1183
-    function geodir_post_sortable_columns($columns)
1184
-    {
1185
-
1186
-        $columns['expire'] = 'expire';
1187
-
1188
-        return $columns;
1189
-    }
1175
+	/**
1176
+	 * Makes admin post listing page columns sortable.
1177
+	 *
1178
+	 * @since 1.0.0
1179
+	 * @package GeoDirectory
1180
+	 * @param array $columns The column array.
1181
+	 * @return array Altered column array.
1182
+	 */
1183
+	function geodir_post_sortable_columns($columns)
1184
+	{
1185
+
1186
+		$columns['expire'] = 'expire';
1187
+
1188
+		return $columns;
1189
+	}
1190 1190
 }
1191 1191
 
1192 1192
 /**
@@ -1200,32 +1200,32 @@  discard block
 block discarded – undo
1200 1200
  * @param int $post_id The post ID.
1201 1201
  */
1202 1202
 function geodir_post_information_save($post_id, $post) {
1203
-    global $wpdb, $current_user;
1203
+	global $wpdb, $current_user;
1204 1204
 
1205
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1206
-        return;
1207
-    }
1205
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1206
+		return;
1207
+	}
1208 1208
 
1209
-    $geodir_posttypes = geodir_get_posttypes();
1209
+	$geodir_posttypes = geodir_get_posttypes();
1210 1210
 
1211
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1212
-        return;
1211
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1212
+		return;
1213 1213
 
1214
-    if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1215
-        if (isset($_REQUEST['_status']))
1216
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1214
+	if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1215
+		if (isset($_REQUEST['_status']))
1216
+			geodir_change_post_status($post_id, $_REQUEST['_status']);
1217 1217
 
1218
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1219
-            return;
1218
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1219
+			return;
1220 1220
 
1221
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1222
-            return;
1221
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1222
+			return;
1223 1223
 
1224
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1225
-            return;
1224
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1225
+			return;
1226 1226
 
1227
-        geodir_save_listing($_REQUEST);
1228
-    }
1227
+		geodir_save_listing($_REQUEST);
1228
+	}
1229 1229
 }
1230 1230
 
1231 1231
 /**
@@ -1241,102 +1241,102 @@  discard block
 block discarded – undo
1241 1241
  */
1242 1242
 function geodir_admin_fields($options)
1243 1243
 {
1244
-    global $geodirectory;
1245
-
1246
-    $first_title = true;
1247
-    $tab_id = '';
1248
-    $i = 0;
1249
-    foreach ($options as $value) :
1250
-        if (!isset($value['name'])) $value['name'] = '';
1251
-        if (!isset($value['class'])) $value['class'] = '';
1252
-        if (!isset($value['css'])) $value['css'] = '';
1253
-        if (!isset($value['std'])) $value['std'] = '';
1254
-        $desc = '';
1255
-        switch ($value['type']) :
1256
-            case 'dummy_installer':
1257
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1258
-                geodir_autoinstall_admin_header($post_type);
1259
-                break;
1260
-            case 'title':
1261
-
1262
-                if ($i == 0) {
1263
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1264
-                    echo '<div class="inner_content_tab_main">';
1265
-                }
1244
+	global $geodirectory;
1245
+
1246
+	$first_title = true;
1247
+	$tab_id = '';
1248
+	$i = 0;
1249
+	foreach ($options as $value) :
1250
+		if (!isset($value['name'])) $value['name'] = '';
1251
+		if (!isset($value['class'])) $value['class'] = '';
1252
+		if (!isset($value['css'])) $value['css'] = '';
1253
+		if (!isset($value['std'])) $value['std'] = '';
1254
+		$desc = '';
1255
+		switch ($value['type']) :
1256
+			case 'dummy_installer':
1257
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1258
+				geodir_autoinstall_admin_header($post_type);
1259
+				break;
1260
+			case 'title':
1261
+
1262
+				if ($i == 0) {
1263
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1264
+					echo '<div class="inner_content_tab_main">';
1265
+				}
1266 1266
 
1267
-                $i++;
1267
+				$i++;
1268 1268
 
1269
-                if (isset($value['id']) && $value['id'])
1270
-                    $tab_id = $value['id'];
1269
+				if (isset($value['id']) && $value['id'])
1270
+					$tab_id = $value['id'];
1271 1271
 
1272
-                if (isset($value['desc']) && $value['desc'])
1273
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1272
+				if (isset($value['desc']) && $value['desc'])
1273
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1274 1274
 
1275
-                if (isset($value['name']) && $value['name']) {
1276
-                    if ($first_title === true) {
1277
-                        $first_title = false;
1278
-                    } else {
1279
-                        echo '</div>';
1280
-                    }
1281
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1275
+				if (isset($value['name']) && $value['name']) {
1276
+					if ($first_title === true) {
1277
+						$first_title = false;
1278
+					} else {
1279
+						echo '</div>';
1280
+					}
1281
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1282 1282
 
1283
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1284
-                }
1283
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1284
+				}
1285 1285
 
1286
-                /**
1287
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
1288
-                 *
1289
-                 * The action is called dynamically geodir_settings_$value['id'].
1290
-                 *
1291
-                 * @since 1.0.0
1292
-                 */
1293
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1294
-                break;
1295
-
1296
-            case 'no_tabs':
1297
-
1298
-                echo '<div class="inner_content_tab_main">';
1299
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1300
-
1301
-                break;
1302
-
1303
-            case 'sectionstart':
1304
-                if (isset($value['desc']) && $value['desc'])
1305
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1306
-                if (isset($value['name']) && $value['name'])
1307
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1308
-                /**
1309
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1310
-                 *
1311
-                 * The action is called dynamically geodir_settings_$value['id']_start.
1312
-                 *
1313
-                 * @since 1.0.0
1314
-                 */
1315
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1316
-                echo '<table class="form-table">' . "\n\n";
1317
-
1318
-                break;
1319
-            case 'sectionend':
1320
-                /**
1321
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1322
-                 *
1323
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1324
-                 *
1325
-                 * @since 1.0.0
1326
-                 */
1327
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1328
-                echo '</table>';
1329
-                /**
1330
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1331
-                 *
1332
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1333
-                 *
1334
-                 * @since 1.0.0
1335
-                 */
1336
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1337
-                break;
1338
-            case 'text':
1339
-                ?>
1286
+				/**
1287
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
1288
+				 *
1289
+				 * The action is called dynamically geodir_settings_$value['id'].
1290
+				 *
1291
+				 * @since 1.0.0
1292
+				 */
1293
+				do_action('geodir_settings_' . sanitize_title($value['id']));
1294
+				break;
1295
+
1296
+			case 'no_tabs':
1297
+
1298
+				echo '<div class="inner_content_tab_main">';
1299
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1300
+
1301
+				break;
1302
+
1303
+			case 'sectionstart':
1304
+				if (isset($value['desc']) && $value['desc'])
1305
+					$desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1306
+				if (isset($value['name']) && $value['name'])
1307
+					echo '<h3>' . $value['name'] . $desc . '</h3>';
1308
+				/**
1309
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1310
+				 *
1311
+				 * The action is called dynamically geodir_settings_$value['id']_start.
1312
+				 *
1313
+				 * @since 1.0.0
1314
+				 */
1315
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1316
+				echo '<table class="form-table">' . "\n\n";
1317
+
1318
+				break;
1319
+			case 'sectionend':
1320
+				/**
1321
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1322
+				 *
1323
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1324
+				 *
1325
+				 * @since 1.0.0
1326
+				 */
1327
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1328
+				echo '</table>';
1329
+				/**
1330
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1331
+				 *
1332
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1333
+				 *
1334
+				 * @since 1.0.0
1335
+				 */
1336
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1337
+				break;
1338
+			case 'text':
1339
+				?>
1340 1340
                 <tr valign="top">
1341 1341
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1342 1342
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1345,15 +1345,15 @@  discard block
 block discarded – undo
1345 1345
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1346 1346
                                            style=" <?php echo esc_attr($value['css']); ?>"
1347 1347
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1348
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1349
-                                           } else {
1350
-                                               echo esc_attr($value['std']);
1351
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1348
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1349
+										   } else {
1350
+											   echo esc_attr($value['std']);
1351
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1352 1352
                 </tr><?php
1353
-                break;
1353
+				break;
1354 1354
 
1355
-            case 'password':
1356
-                ?>
1355
+			case 'password':
1356
+				?>
1357 1357
                 <tr valign="top">
1358 1358
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1359 1359
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1362,42 +1362,42 @@  discard block
 block discarded – undo
1362 1362
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1363 1363
                                            style="<?php echo esc_attr($value['css']); ?>"
1364 1364
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1365
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1366
-                                           } else {
1367
-                                               echo esc_attr($value['std']);
1368
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1365
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1366
+										   } else {
1367
+											   echo esc_attr($value['std']);
1368
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1369 1369
                 </tr><?php
1370
-                break;
1370
+				break;
1371 1371
 
1372
-            case 'html_content':
1373
-                ?>
1372
+			case 'html_content':
1373
+				?>
1374 1374
                 <tr valign="top">
1375 1375
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1376 1376
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
1377 1377
                 </tr><?php
1378
-                break;
1378
+				break;
1379 1379
 
1380
-            case 'color' :
1381
-                ?>
1380
+			case 'color' :
1381
+				?>
1382 1382
                 <tr valign="top">
1383 1383
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1384 1384
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1385 1385
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
1386 1386
                                            style="<?php echo esc_attr($value['css']); ?>"
1387 1387
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1388
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1389
-                                           } else {
1390
-                                               echo esc_attr($value['std']);
1391
-                                           } ?>" class="colorpick"/> <span
1388
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1389
+										   } else {
1390
+											   echo esc_attr($value['std']);
1391
+										   } ?>" class="colorpick"/> <span
1392 1392
                         class="description"><?php echo $value['desc']; ?></span>
1393 1393
 
1394 1394
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
1395 1395
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
1396 1396
                 </td>
1397 1397
                 </tr><?php
1398
-                break;
1399
-            case 'image_width' :
1400
-                ?>
1398
+				break;
1399
+			case 'image_width' :
1400
+				?>
1401 1401
                 <tr valign="top">
1402 1402
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1403 1403
                 <td class="forminp">
@@ -1419,11 +1419,11 @@  discard block
 block discarded – undo
1419 1419
 
1420 1420
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1421 1421
                 </tr><?php
1422
-                break;
1423
-            case 'select':
1424
-                $option_value = get_option($value['id']);
1425
-                $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1426
-                ?>
1422
+				break;
1423
+			case 'select':
1424
+				$option_value = get_option($value['id']);
1425
+				$option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1426
+				?>
1427 1427
                 <tr valign="top">
1428 1428
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1429 1429
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1432,33 +1432,33 @@  discard block
 block discarded – undo
1432 1432
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1433 1433
                                             option-ajaxchosen="false">
1434 1434
                         <?php
1435
-                        foreach ($value['options'] as $key => $val) {
1436
-                            $geodir_select_value = '';
1437
-                            if ($option_value != '') {
1438
-                                if ($option_value != '' && $option_value == $key)
1439
-                                    $geodir_select_value = ' selected="selected" ';
1440
-                            } else {
1441
-                                if ($value['std'] == $key)
1442
-                                    $geodir_select_value = ' selected="selected" ';
1443
-                            }
1444
-                            ?>
1435
+						foreach ($value['options'] as $key => $val) {
1436
+							$geodir_select_value = '';
1437
+							if ($option_value != '') {
1438
+								if ($option_value != '' && $option_value == $key)
1439
+									$geodir_select_value = ' selected="selected" ';
1440
+							} else {
1441
+								if ($value['std'] == $key)
1442
+									$geodir_select_value = ' selected="selected" ';
1443
+							}
1444
+							?>
1445 1445
                             <option
1446 1446
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option>
1447 1447
                         <?php
1448
-                        }
1449
-                        ?>
1448
+						}
1449
+						?>
1450 1450
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1451 1451
                 </td>
1452 1452
                 </tr><?php
1453
-                break;
1453
+				break;
1454 1454
 
1455
-            case 'multiselect':
1456
-                $option_values = get_option($value['id']);
1457
-                if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1458
-                   $option_values = $value['std'];
1459
-                }
1460
-                $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1461
-                ?>
1455
+			case 'multiselect':
1456
+				$option_values = get_option($value['id']);
1457
+				if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1458
+				   $option_values = $value['std'];
1459
+				}
1460
+				$option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1461
+				?>
1462 1462
                 <tr valign="top">
1463 1463
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1464 1464
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -1468,25 +1468,25 @@  discard block
 block discarded – undo
1468 1468
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1469 1469
                                             option-ajaxchosen="false">
1470 1470
                         <?php
1471
-                        foreach ($value['options'] as $key => $val) {
1472
-                            if (strpos($key, 'optgroup_start-') === 0) {
1473
-                                ?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1474
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
1475
-                                ?></optgroup><?php
1476
-                            } else {
1477
-                                ?>
1471
+						foreach ($value['options'] as $key => $val) {
1472
+							if (strpos($key, 'optgroup_start-') === 0) {
1473
+								?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1474
+							} else if (strpos($key, 'optgroup_end-') === 0) {
1475
+								?></optgroup><?php
1476
+							} else {
1477
+								?>
1478 1478
                                 <option
1479 1479
                                     value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1480 1480
                             <?php
1481
-                            }
1482
-                        }
1483
-                        ?>
1481
+							}
1482
+						}
1483
+						?>
1484 1484
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1485 1485
                 </td>
1486 1486
                 </tr><?php
1487
-                break;
1488
-            case 'file':
1489
-                ?>
1487
+				break;
1488
+			case 'file':
1489
+				?>
1490 1490
                 <tr valign="top">
1491 1491
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1492 1492
                 <td class="forminp">
@@ -1506,87 +1506,87 @@  discard block
 block discarded – undo
1506 1506
                     <?php } ?>
1507 1507
                 </td>
1508 1508
                 </tr><?php
1509
-                break;
1510
-            case 'map_default_settings' :
1511
-                ?>
1509
+				break;
1510
+			case 'map_default_settings' :
1511
+				?>
1512 1512
 
1513 1513
                 <tr valign="top">
1514 1514
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1515 1515
                     <td width="60%">
1516 1516
                         <select name="geodir_default_map_language" style="width:60%">
1517 1517
                             <?php
1518
-                            $arr_map_langages = array(
1519
-                                'ar' => __('ARABIC', 'geodirectory'),
1520
-                                'eu' => __('BASQUE', 'geodirectory'),
1521
-                                'bg' => __('BULGARIAN', 'geodirectory'),
1522
-                                'bn' => __('BENGALI', 'geodirectory'),
1523
-                                'ca' => __('CATALAN', 'geodirectory'),
1524
-                                'cs' => __('CZECH', 'geodirectory'),
1525
-                                'da' => __('DANISH', 'geodirectory'),
1526
-                                'de' => __('GERMAN', 'geodirectory'),
1527
-                                'el' => __('GREEK', 'geodirectory'),
1528
-                                'en' => __('ENGLISH', 'geodirectory'),
1529
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1530
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1531
-                                'es' => __('SPANISH', 'geodirectory'),
1532
-                                'eu' => __('BASQUE', 'geodirectory'),
1533
-                                'fa' => __('FARSI', 'geodirectory'),
1534
-                                'fi' => __('FINNISH', 'geodirectory'),
1535
-                                'fil' => __('FILIPINO', 'geodirectory'),
1536
-                                'fr' => __('FRENCH', 'geodirectory'),
1537
-                                'gl' => __('GALICIAN', 'geodirectory'),
1538
-                                'gu' => __('GUJARATI', 'geodirectory'),
1539
-                                'hi' => __('HINDI', 'geodirectory'),
1540
-                                'hr' => __('CROATIAN', 'geodirectory'),
1541
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
1542
-                                'id' => __('INDONESIAN', 'geodirectory'),
1543
-                                'it' => __('ITALIAN', 'geodirectory'),
1544
-                                'iw' => __('HEBREW', 'geodirectory'),
1545
-                                'ja' => __('JAPANESE', 'geodirectory'),
1546
-                                'kn' => __('KANNADA', 'geodirectory'),
1547
-                                'ko' => __('KOREAN', 'geodirectory'),
1548
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
1549
-                                'lv' => __('LATVIAN', 'geodirectory'),
1550
-                                'ml' => __('MALAYALAM', 'geodirectory'),
1551
-                                'mr' => __('MARATHI', 'geodirectory'),
1552
-                                'nl' => __('DUTCH', 'geodirectory'),
1553
-                                'no' => __('NORWEGIAN', 'geodirectory'),
1554
-                                'pl' => __('POLISH', 'geodirectory'),
1555
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
1556
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1557
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1558
-                                'ro' => __('ROMANIAN', 'geodirectory'),
1559
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1560
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1561
-                                'sk' => __('SLOVAK', 'geodirectory'),
1562
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
1563
-                                'sr' => __('SERBIAN', 'geodirectory'),
1564
-                                'sv' => __('	SWEDISH', 'geodirectory'),
1565
-                                'tl' => __('TAGALOG', 'geodirectory'),
1566
-                                'ta' => __('TAMIL', 'geodirectory'),
1567
-                                'te' => __('TELUGU', 'geodirectory'),
1568
-                                'th' => __('THAI', 'geodirectory'),
1569
-                                'tr' => __('TURKISH', 'geodirectory'),
1570
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
1571
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
1572
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1573
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1574
-                            );
1575
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
1576
-                            if (empty($geodir_default_map_language))
1577
-                                $geodir_default_map_language = 'en';
1578
-                            foreach ($arr_map_langages as $language_key => $language_txt) {
1579
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1580
-                                    $geodir_default_language_selected = "selected='selected'";
1581
-                                else
1582
-                                    $geodir_default_language_selected = '';
1583
-
1584
-                                ?>
1518
+							$arr_map_langages = array(
1519
+								'ar' => __('ARABIC', 'geodirectory'),
1520
+								'eu' => __('BASQUE', 'geodirectory'),
1521
+								'bg' => __('BULGARIAN', 'geodirectory'),
1522
+								'bn' => __('BENGALI', 'geodirectory'),
1523
+								'ca' => __('CATALAN', 'geodirectory'),
1524
+								'cs' => __('CZECH', 'geodirectory'),
1525
+								'da' => __('DANISH', 'geodirectory'),
1526
+								'de' => __('GERMAN', 'geodirectory'),
1527
+								'el' => __('GREEK', 'geodirectory'),
1528
+								'en' => __('ENGLISH', 'geodirectory'),
1529
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1530
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1531
+								'es' => __('SPANISH', 'geodirectory'),
1532
+								'eu' => __('BASQUE', 'geodirectory'),
1533
+								'fa' => __('FARSI', 'geodirectory'),
1534
+								'fi' => __('FINNISH', 'geodirectory'),
1535
+								'fil' => __('FILIPINO', 'geodirectory'),
1536
+								'fr' => __('FRENCH', 'geodirectory'),
1537
+								'gl' => __('GALICIAN', 'geodirectory'),
1538
+								'gu' => __('GUJARATI', 'geodirectory'),
1539
+								'hi' => __('HINDI', 'geodirectory'),
1540
+								'hr' => __('CROATIAN', 'geodirectory'),
1541
+								'hu' => __('HUNGARIAN', 'geodirectory'),
1542
+								'id' => __('INDONESIAN', 'geodirectory'),
1543
+								'it' => __('ITALIAN', 'geodirectory'),
1544
+								'iw' => __('HEBREW', 'geodirectory'),
1545
+								'ja' => __('JAPANESE', 'geodirectory'),
1546
+								'kn' => __('KANNADA', 'geodirectory'),
1547
+								'ko' => __('KOREAN', 'geodirectory'),
1548
+								'lt' => __('LITHUANIAN', 'geodirectory'),
1549
+								'lv' => __('LATVIAN', 'geodirectory'),
1550
+								'ml' => __('MALAYALAM', 'geodirectory'),
1551
+								'mr' => __('MARATHI', 'geodirectory'),
1552
+								'nl' => __('DUTCH', 'geodirectory'),
1553
+								'no' => __('NORWEGIAN', 'geodirectory'),
1554
+								'pl' => __('POLISH', 'geodirectory'),
1555
+								'pt' => __('PORTUGUESE', 'geodirectory'),
1556
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1557
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1558
+								'ro' => __('ROMANIAN', 'geodirectory'),
1559
+								'ru' => __('RUSSIAN', 'geodirectory'),
1560
+								'ru' => __('RUSSIAN', 'geodirectory'),
1561
+								'sk' => __('SLOVAK', 'geodirectory'),
1562
+								'sl' => __('SLOVENIAN', 'geodirectory'),
1563
+								'sr' => __('SERBIAN', 'geodirectory'),
1564
+								'sv' => __('	SWEDISH', 'geodirectory'),
1565
+								'tl' => __('TAGALOG', 'geodirectory'),
1566
+								'ta' => __('TAMIL', 'geodirectory'),
1567
+								'te' => __('TELUGU', 'geodirectory'),
1568
+								'th' => __('THAI', 'geodirectory'),
1569
+								'tr' => __('TURKISH', 'geodirectory'),
1570
+								'uk' => __('UKRAINIAN', 'geodirectory'),
1571
+								'vi' => __('VIETNAMESE', 'geodirectory'),
1572
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1573
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1574
+							);
1575
+							$geodir_default_map_language = get_option('geodir_default_map_language');
1576
+							if (empty($geodir_default_map_language))
1577
+								$geodir_default_map_language = 'en';
1578
+							foreach ($arr_map_langages as $language_key => $language_txt) {
1579
+								if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1580
+									$geodir_default_language_selected = "selected='selected'";
1581
+								else
1582
+									$geodir_default_language_selected = '';
1583
+
1584
+								?>
1585 1585
                                 <option
1586 1586
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
1587 1587
 
1588 1588
                             <?php }
1589
-                            ?>
1589
+							?>
1590 1590
                         </select>
1591 1591
                     </td>
1592 1592
                 </tr>
@@ -1597,46 +1597,46 @@  discard block
 block discarded – undo
1597 1597
                     <td width="60%">
1598 1598
                         <select name="geodir_default_map_search_pt" style="width:60%">
1599 1599
                             <?php
1600
-                            $post_types = geodir_get_posttypes('array');
1601
-                            $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1602
-                            if (empty($geodir_default_map_search_pt))
1603
-                                $geodir_default_map_search_pt = 'gd_place';
1604
-                            if (is_array($post_types)) {
1605
-                                foreach ($post_types as $key => $post_types_obj) {
1606
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1607
-                                        $geodir_search_pt_selected = "selected='selected'";
1608
-                                    else
1609
-                                        $geodir_search_pt_selected = '';
1610
-
1611
-                                    ?>
1600
+							$post_types = geodir_get_posttypes('array');
1601
+							$geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1602
+							if (empty($geodir_default_map_search_pt))
1603
+								$geodir_default_map_search_pt = 'gd_place';
1604
+							if (is_array($post_types)) {
1605
+								foreach ($post_types as $key => $post_types_obj) {
1606
+									if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1607
+										$geodir_search_pt_selected = "selected='selected'";
1608
+									else
1609
+										$geodir_search_pt_selected = '';
1610
+
1611
+									?>
1612 1612
                                     <option
1613 1613
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option>
1614 1614
 
1615 1615
                                 <?php }
1616 1616
 
1617
-                            }
1617
+							}
1618 1618
 
1619
-                            ?>
1619
+							?>
1620 1620
                         </select>
1621 1621
                     </td>
1622 1622
                 </tr>
1623 1623
 
1624 1624
                 <?php
1625
-                break;
1625
+				break;
1626 1626
 
1627
-            case 'map':
1628
-                ?>
1627
+			case 'map':
1628
+				?>
1629 1629
                 <tr valign="top">
1630 1630
                     <td class="forminp">
1631 1631
                         <?php
1632
-                        global $post_cat, $cat_display;
1633
-                        $post_types = geodir_get_posttypes('object');
1634
-                        $cat_display = 'checkbox';
1635
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1636
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
1637
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1638
-                        $count = 1;
1639
-                        ?>
1632
+						global $post_cat, $cat_display;
1633
+						$post_types = geodir_get_posttypes('object');
1634
+						$cat_display = 'checkbox';
1635
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
1636
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
1637
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1638
+						$count = 1;
1639
+						?>
1640 1640
                         <table width="70%" class="widefat">
1641 1641
                             <thead>
1642 1642
                             <tr>
@@ -1645,18 +1645,18 @@  discard block
 block discarded – undo
1645 1645
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
1646 1646
                             </tr>
1647 1647
                             <?php
1648
-                            $gd_categs = $gd_cats;
1649
-                            foreach ($post_types as $key => $post_types_obj) :
1650
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1651
-                                $gd_taxonomy = geodir_get_taxonomies($key);
1652
-                                if ($gd_cats_upgrade) {
1653
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1654
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1655
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1656
-                                }
1657
-                                $post_cat = implode(',', $gd_cats);
1658
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1659
-                                ?>
1648
+							$gd_categs = $gd_cats;
1649
+							foreach ($post_types as $key => $post_types_obj) :
1650
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1651
+								$gd_taxonomy = geodir_get_taxonomies($key);
1652
+								if ($gd_cats_upgrade) {
1653
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1654
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1655
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1656
+								}
1657
+								$post_cat = implode(',', $gd_cats);
1658
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1659
+								?>
1660 1660
                                 <tr>
1661 1661
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
1662 1662
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -1677,19 +1677,19 @@  discard block
 block discarded – undo
1677 1677
                     </td>
1678 1678
                 </tr>
1679 1679
                 <?php
1680
-                break;
1680
+				break;
1681 1681
 
1682
-            case 'checkbox' :
1682
+			case 'checkbox' :
1683 1683
 
1684
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1685
-                    ?>
1684
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1685
+					?>
1686 1686
                     <tr valign="top">
1687 1687
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1688 1688
                     <td class="forminp">
1689 1689
                 <?php
1690
-                endif;
1690
+				endif;
1691 1691
 
1692
-                ?>
1692
+				?>
1693 1693
                 <fieldset>
1694 1694
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1695 1695
                     <label for="<?php echo $value['id'] ?>">
@@ -1699,49 +1699,49 @@  discard block
 block discarded – undo
1699 1699
                 </fieldset>
1700 1700
                 <?php
1701 1701
 
1702
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1703
-                    ?>
1702
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1703
+					?>
1704 1704
                     </td>
1705 1705
                     </tr>
1706 1706
                 <?php
1707
-                endif;
1707
+				endif;
1708 1708
 
1709
-                break;
1709
+				break;
1710 1710
 
1711
-            case 'radio' :
1711
+			case 'radio' :
1712 1712
 
1713
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1714
-                    ?>
1713
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1714
+					?>
1715 1715
                     <tr valign="top">
1716 1716
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1717 1717
                     <td class="forminp">
1718 1718
                 <?php
1719
-                endif;
1719
+				endif;
1720 1720
 
1721
-                ?>
1721
+				?>
1722 1722
                 <fieldset>
1723 1723
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1724 1724
                     <label for="<?php echo $value['id'];?>">
1725 1725
                         <input name="<?php echo esc_attr($value['id']); ?>"
1726 1726
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1727 1727
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1728
-                            echo 'checked="checked"';
1729
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1728
+							echo 'checked="checked"';
1729
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1730 1730
                         <?php echo $value['desc']; ?></label><br>
1731 1731
                 </fieldset>
1732 1732
                 <?php
1733 1733
 
1734
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1735
-                    ?>
1734
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1735
+					?>
1736 1736
                     </td>
1737 1737
                     </tr>
1738 1738
                 <?php
1739
-                endif;
1739
+				endif;
1740 1740
 
1741
-                break;
1741
+				break;
1742 1742
 
1743
-            case 'textarea':
1744
-                ?>
1743
+			case 'textarea':
1744
+				?>
1745 1745
                 <tr valign="top">
1746 1746
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1747 1747
                 <td class="forminp">
@@ -1754,30 +1754,30 @@  discard block
 block discarded – undo
1754 1754
 
1755 1755
                 </td>
1756 1756
                 </tr><?php
1757
-                break;
1757
+				break;
1758 1758
 
1759
-            case 'editor':
1760
-                ?>
1759
+			case 'editor':
1760
+				?>
1761 1761
                 <tr valign="top">
1762 1762
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1763 1763
                 <td class="forminp"><?php
1764
-                    if (get_option($value['id']))
1765
-                        $content = stripslashes(get_option($value['id']));
1766
-                    else
1767
-                        $content = $value['std'];
1764
+					if (get_option($value['id']))
1765
+						$content = stripslashes(get_option($value['id']));
1766
+					else
1767
+						$content = $value['std'];
1768 1768
 
1769
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1769
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1770 1770
 
1771
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
1771
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
1772 1772
 
1773
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
1773
+					?> <span class="description"><?php echo $value['desc'] ?></span>
1774 1774
 
1775 1775
                 </td>
1776 1776
                 </tr><?php
1777
-                break;
1777
+				break;
1778 1778
 
1779
-            case 'single_select_page' :
1780
-                // WPML
1779
+			case 'single_select_page' :
1780
+				// WPML
1781 1781
 				$switch_lang = false;
1782 1782
 				$disabled = '';
1783 1783
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -1795,18 +1795,18 @@  discard block
 block discarded – undo
1795 1795
 				//
1796 1796
 				$page_setting = (int)get_option($value['id']);
1797 1797
 
1798
-                $args = array('name' => $value['id'],
1799
-                    'id' => $value['id'],
1800
-                    'sort_column' => 'menu_order',
1801
-                    'sort_order' => 'ASC',
1802
-                    'show_option_none' => ' ',
1803
-                    'class' => $value['class'],
1804
-                    'echo' => false,
1805
-                    'selected' => $page_setting);
1798
+				$args = array('name' => $value['id'],
1799
+					'id' => $value['id'],
1800
+					'sort_column' => 'menu_order',
1801
+					'sort_order' => 'ASC',
1802
+					'show_option_none' => ' ',
1803
+					'class' => $value['class'],
1804
+					'echo' => false,
1805
+					'selected' => $page_setting);
1806 1806
 
1807
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1807
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1808 1808
 
1809
-                ?>
1809
+				?>
1810 1810
                 <tr valign="top" class="single_select_page">
1811 1811
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1812 1812
                 <td class="forminp">
@@ -1817,17 +1817,17 @@  discard block
 block discarded – undo
1817 1817
 				if ($switch_lang) {
1818 1818
 					$sitepress->switch_lang($switch_lang, true);
1819 1819
 				}
1820
-                break;
1821
-            case 'single_select_country' :
1822
-                $country_setting = (string)get_option($value['id']);
1823
-                if (strstr($country_setting, ':')) :
1824
-                    $country = current(explode(':', $country_setting));
1825
-                    $state = end(explode(':', $country_setting));
1826
-                else :
1827
-                    $country = $country_setting;
1828
-                    $state = '*';
1829
-                endif;
1830
-                ?>
1820
+				break;
1821
+			case 'single_select_country' :
1822
+				$country_setting = (string)get_option($value['id']);
1823
+				if (strstr($country_setting, ':')) :
1824
+					$country = current(explode(':', $country_setting));
1825
+					$state = end(explode(':', $country_setting));
1826
+				else :
1827
+					$country = $country_setting;
1828
+					$state = '*';
1829
+				endif;
1830
+				?>
1831 1831
                 <tr valign="top">
1832 1832
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
1833 1833
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1838,12 +1838,12 @@  discard block
 block discarded – undo
1838 1838
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1839 1839
                 </td>
1840 1840
                 </tr><?php
1841
-                break;
1842
-            case 'multi_select_countries' :
1843
-                $countries = $geodirectory->countries->countries;
1844
-                asort($countries);
1845
-                $selections = (array)get_option($value['id']);
1846
-                ?>
1841
+				break;
1842
+			case 'multi_select_countries' :
1843
+				$countries = $geodirectory->countries->countries;
1844
+				asort($countries);
1845
+				$selections = (array)get_option($value['id']);
1846
+				?>
1847 1847
                 <tr valign="top">
1848 1848
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1849 1849
                 <td class="forminp">
@@ -1851,22 +1851,22 @@  discard block
 block discarded – undo
1851 1851
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1852 1852
                             title="Country" class="chosen_select">
1853 1853
                         <?php
1854
-                        if ($countries) foreach ($countries as $key => $val) :
1855
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1856
-                        endforeach;
1857
-                        ?>
1854
+						if ($countries) foreach ($countries as $key => $val) :
1855
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1856
+						endforeach;
1857
+						?>
1858 1858
                     </select>
1859 1859
                 </td>
1860 1860
                 </tr>
1861 1861
 
1862 1862
                 <?php
1863 1863
 
1864
-                break;
1864
+				break;
1865 1865
 
1866
-            case 'google_analytics' :
1867
-                $selections = (array)get_option($value['id']);
1868
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1869
-                    ?>
1866
+			case 'google_analytics' :
1867
+				$selections = (array)get_option($value['id']);
1868
+				if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1869
+					?>
1870 1870
                     <tr valign="top">
1871 1871
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1872 1872
                         <td class="forminp">
@@ -1874,19 +1874,19 @@  discard block
 block discarded – undo
1874 1874
 
1875 1875
                             <?php
1876 1876
 
1877
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1878
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1879
-                            $state = "&state=123";//any string
1880
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1881
-                            $response_type = "&response_type=code";
1882
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1883
-                            $access_type = "&access_type=offline";
1884
-                            $approval_prompt = "&approval_prompt=force";
1877
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1878
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1879
+							$state = "&state=123";//any string
1880
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1881
+							$response_type = "&response_type=code";
1882
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
1883
+							$access_type = "&access_type=offline";
1884
+							$approval_prompt = "&approval_prompt=force";
1885 1885
 
1886
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1886
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1887 1887
 
1888 1888
 
1889
-                            ?>
1889
+							?>
1890 1890
                             <script>
1891 1891
                                 function gd_ga_popup() {
1892 1892
                                     var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
@@ -1901,47 +1901,47 @@  discard block
 block discarded – undo
1901 1901
                             </script>
1902 1902
 
1903 1903
                             <?php
1904
-                            if (get_option('gd_ga_refresh_token')) {
1905
-                                ?>
1904
+							if (get_option('gd_ga_refresh_token')) {
1905
+								?>
1906 1906
                                 <span class="button-primary"
1907 1907
                                       onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
1908 1908
                                 <span
1909 1909
                                     style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1910 1910
                             <?php
1911
-                            } else {
1912
-                                ?>
1911
+							} else {
1912
+								?>
1913 1913
                                 <span class="button-primary"
1914 1914
                                       onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1915 1915
                             <?php
1916
-                            }
1917
-                            ?>
1916
+							}
1917
+							?>
1918 1918
                         </td>
1919 1919
                     </tr>
1920 1920
 
1921 1921
                 <?php
1922
-                }
1922
+				}
1923 1923
 
1924
-                break;
1924
+				break;
1925 1925
 
1926
-            case 'field_seperator' :
1926
+			case 'field_seperator' :
1927 1927
 
1928
-                ?>
1928
+				?>
1929 1929
                 <tr valign="top">
1930 1930
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
1931 1931
                 </tr>
1932 1932
                 <?php
1933 1933
 
1934
-                break;
1934
+				break;
1935 1935
 
1936
-        endswitch;
1936
+		endswitch;
1937 1937
 
1938
-    endforeach;
1938
+	endforeach;
1939 1939
 
1940
-    if ($first_title === false) {
1941
-        echo "</div>";
1942
-    }
1940
+	if ($first_title === false) {
1941
+		echo "</div>";
1942
+	}
1943 1943
 
1944
-    ?>
1944
+	?>
1945 1945
 
1946 1946
     <script type="text/javascript">
1947 1947
 
@@ -2001,33 +2001,33 @@  discard block
 block discarded – undo
2001 2001
  */
2002 2002
 function geodir_post_info_setting()
2003 2003
 {
2004
-    global $post, $post_id;
2005
-
2006
-    $post_type = get_post_type();
2007
-
2008
-    $package_info = array();
2009
-
2010
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2011
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
2012
-    echo '<div id="geodir_wrapper">';
2013
-    /**
2014
-     * Called before the GD custom fields are output in the wp-admin area.
2015
-     *
2016
-     * @since 1.0.0
2017
-     * @see 'geodir_after_default_field_in_meta_box'
2018
-     */
2019
-    do_action('geodir_before_default_field_in_meta_box');
2020
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2021
-    // to display all fields in one information box
2022
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2023
-    /**
2024
-     * Called after the GD custom fields are output in the wp-admin area.
2025
-     *
2026
-     * @since 1.0.0
2027
-     * @see 'geodir_before_default_field_in_meta_box'
2028
-     */
2029
-    do_action('geodir_after_default_field_in_meta_box');
2030
-    echo '</div>';
2004
+	global $post, $post_id;
2005
+
2006
+	$post_type = get_post_type();
2007
+
2008
+	$package_info = array();
2009
+
2010
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2011
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
2012
+	echo '<div id="geodir_wrapper">';
2013
+	/**
2014
+	 * Called before the GD custom fields are output in the wp-admin area.
2015
+	 *
2016
+	 * @since 1.0.0
2017
+	 * @see 'geodir_after_default_field_in_meta_box'
2018
+	 */
2019
+	do_action('geodir_before_default_field_in_meta_box');
2020
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2021
+	// to display all fields in one information box
2022
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2023
+	/**
2024
+	 * Called after the GD custom fields are output in the wp-admin area.
2025
+	 *
2026
+	 * @since 1.0.0
2027
+	 * @see 'geodir_before_default_field_in_meta_box'
2028
+	 */
2029
+	do_action('geodir_after_default_field_in_meta_box');
2030
+	echo '</div>';
2031 2031
 }
2032 2032
 
2033 2033
 /**
@@ -2040,18 +2040,18 @@  discard block
 block discarded – undo
2040 2040
  */
2041 2041
 function geodir_post_addinfo_setting()
2042 2042
 {
2043
-    global $post, $post_id;
2043
+	global $post, $post_id;
2044 2044
 
2045
-    $post_type = get_post_type();
2045
+	$post_type = get_post_type();
2046 2046
 
2047
-    $package_info = array();
2047
+	$package_info = array();
2048 2048
 
2049
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2049
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2050 2050
 
2051
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2052
-    echo '<div id="geodir_wrapper">';
2053
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2054
-    echo '</div>';
2051
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2052
+	echo '<div id="geodir_wrapper">';
2053
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2054
+	echo '</div>';
2055 2055
 
2056 2056
 }
2057 2057
 
@@ -2065,60 +2065,60 @@  discard block
 block discarded – undo
2065 2065
  */
2066 2066
 function geodir_post_attachments()
2067 2067
 {
2068
-    global $post, $post_id;
2068
+	global $post, $post_id;
2069 2069
 
2070
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2070
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2071 2071
 
2072
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
2073
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2074
-        geodir_show_featured_image($post_id, 'thumbnail');
2075
-    }
2072
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
2073
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2074
+		geodir_show_featured_image($post_id, 'thumbnail');
2075
+	}
2076 2076
 
2077
-    $image_limit = 0;
2077
+	$image_limit = 0;
2078 2078
 
2079
-    ?>
2079
+	?>
2080 2080
 
2081 2081
 
2082 2082
     <h5 class="form_title">
2083 2083
         <?php if ($image_limit != 0 && $image_limit == 1) {
2084
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2085
-        } ?>
2084
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2085
+		} ?>
2086 2086
         <?php if ($image_limit != 0 && $image_limit > 1) {
2087
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2088
-        } ?>
2087
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2088
+		} ?>
2089 2089
         <?php if ($image_limit == 0) {
2090
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2091
-        } ?>
2090
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2091
+		} ?>
2092 2092
     </h5>
2093 2093
 
2094 2094
 
2095 2095
     <?php
2096 2096
 
2097
-    $curImages = geodir_get_images($post_id);
2098
-    $place_img_array = array();
2097
+	$curImages = geodir_get_images($post_id);
2098
+	$place_img_array = array();
2099 2099
 
2100
-    if (!empty($curImages)):
2101
-        foreach ($curImages as $p_img):
2102
-            $place_img_array[] = $p_img->src;
2103
-        endforeach;
2104
-    endif;
2100
+	if (!empty($curImages)):
2101
+		foreach ($curImages as $p_img):
2102
+			$place_img_array[] = $p_img->src;
2103
+		endforeach;
2104
+	endif;
2105 2105
 
2106
-    if (!empty($place_img_array))
2107
-        $curImages = implode(',', $place_img_array);
2106
+	if (!empty($place_img_array))
2107
+		$curImages = implode(',', $place_img_array);
2108 2108
 
2109 2109
 
2110
-    // adjust values here
2111
-    $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
2110
+	// adjust values here
2111
+	$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
2112 2112
 
2113
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
2113
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
2114 2114
 
2115
-    $multiple = true; // allow multiple files upload
2115
+	$multiple = true; // allow multiple files upload
2116 2116
 
2117
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2117
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2118 2118
 
2119
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2119
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2120 2120
 
2121
-    ?>
2121
+	?>
2122 2122
 
2123 2123
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
2124 2124
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -2160,13 +2160,13 @@  discard block
 block discarded – undo
2160 2160
  */
2161 2161
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
2162 2162
 {
2163
-    $post_type = get_post_type($post_ID);
2163
+	$post_type = get_post_type($post_ID);
2164 2164
 
2165
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2166
-        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) {
2167
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2168
-        }
2169
-    }
2165
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2166
+		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) {
2167
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2168
+		}
2169
+	}
2170 2170
 }
2171 2171
 
2172 2172
 /**
@@ -2181,39 +2181,39 @@  discard block
 block discarded – undo
2181 2181
  */
2182 2182
 function geodir_notification_add_bcc_option($settings)
2183 2183
 {
2184
-    if (!empty($settings)) {
2185
-        $new_settings = array();
2186
-        foreach ($settings as $setting) {
2187
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2188
-                $geodir_bcc_listing_published_yes = array(
2189
-                    'name' => __('Listing published', 'geodirectory'),
2190
-                    'desc' => __('Yes', 'geodirectory'),
2191
-                    'id' => 'geodir_bcc_listing_published',
2192
-                    'std' => 'yes',
2193
-                    'type' => 'radio',
2194
-                    'value' => '1',
2195
-                    'radiogroup' => 'start'
2196
-                );
2197
-
2198
-                $geodir_bcc_listing_published_no = array(
2199
-                    'name' => __('Listing published', 'geodirectory'),
2200
-                    'desc' => __('No', 'geodirectory'),
2201
-                    'id' => 'geodir_bcc_listing_published',
2202
-                    'std' => 'yes',
2203
-                    'type' => 'radio',
2204
-                    'value' => '0',
2205
-                    'radiogroup' => 'end'
2206
-                );
2207
-
2208
-                $new_settings[] = $geodir_bcc_listing_published_yes;
2209
-                $new_settings[] = $geodir_bcc_listing_published_no;
2210
-            }
2211
-            $new_settings[] = $setting;
2212
-        }
2213
-        $settings = $new_settings;
2214
-    }
2184
+	if (!empty($settings)) {
2185
+		$new_settings = array();
2186
+		foreach ($settings as $setting) {
2187
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2188
+				$geodir_bcc_listing_published_yes = array(
2189
+					'name' => __('Listing published', 'geodirectory'),
2190
+					'desc' => __('Yes', 'geodirectory'),
2191
+					'id' => 'geodir_bcc_listing_published',
2192
+					'std' => 'yes',
2193
+					'type' => 'radio',
2194
+					'value' => '1',
2195
+					'radiogroup' => 'start'
2196
+				);
2197
+
2198
+				$geodir_bcc_listing_published_no = array(
2199
+					'name' => __('Listing published', 'geodirectory'),
2200
+					'desc' => __('No', 'geodirectory'),
2201
+					'id' => 'geodir_bcc_listing_published',
2202
+					'std' => 'yes',
2203
+					'type' => 'radio',
2204
+					'value' => '0',
2205
+					'radiogroup' => 'end'
2206
+				);
2207
+
2208
+				$new_settings[] = $geodir_bcc_listing_published_yes;
2209
+				$new_settings[] = $geodir_bcc_listing_published_no;
2210
+			}
2211
+			$new_settings[] = $setting;
2212
+		}
2213
+		$settings = $new_settings;
2214
+	}
2215 2215
 
2216
-    return $settings;
2216
+	return $settings;
2217 2217
 }
2218 2218
 
2219 2219
 
@@ -2228,19 +2228,19 @@  discard block
 block discarded – undo
2228 2228
  */
2229 2229
 function get_gd_theme_compat_callback()
2230 2230
 {
2231
-    global $wpdb;
2232
-    $themes = get_option('gd_theme_compats');
2233
-
2234
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2235
-        if (isset($_POST['export'])) {
2236
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2237
-        } else {
2238
-            echo json_encode($themes[$_POST['theme']]);
2239
-        }
2231
+	global $wpdb;
2232
+	$themes = get_option('gd_theme_compats');
2240 2233
 
2241
-    }
2234
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2235
+		if (isset($_POST['export'])) {
2236
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2237
+		} else {
2238
+			echo json_encode($themes[$_POST['theme']]);
2239
+		}
2242 2240
 
2243
-    die();
2241
+	}
2242
+
2243
+	die();
2244 2244
 }
2245 2245
 
2246 2246
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -2254,20 +2254,20 @@  discard block
 block discarded – undo
2254 2254
  */
2255 2255
 function get_gd_theme_compat_import_callback()
2256 2256
 {
2257
-    global $wpdb;
2258
-    $themes = get_option('gd_theme_compats');
2259
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2260
-        $json = json_decode(stripslashes($_POST['theme']), true);
2261
-        if (!empty($json) && is_array($json)) {
2262
-            $key = sanitize_text_field(key($json));
2263
-            $themes[$key] = $json[$key];
2264
-            update_option('gd_theme_compats', $themes);
2265
-            echo $key;
2266
-            die();
2267
-        }
2268
-    }
2269
-    echo '0';
2270
-    die();
2257
+	global $wpdb;
2258
+	$themes = get_option('gd_theme_compats');
2259
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2260
+		$json = json_decode(stripslashes($_POST['theme']), true);
2261
+		if (!empty($json) && is_array($json)) {
2262
+			$key = sanitize_text_field(key($json));
2263
+			$themes[$key] = $json[$key];
2264
+			update_option('gd_theme_compats', $themes);
2265
+			echo $key;
2266
+			die();
2267
+		}
2268
+	}
2269
+	echo '0';
2270
+	die();
2271 2271
 }
2272 2272
 
2273 2273
 
@@ -2280,39 +2280,39 @@  discard block
 block discarded – undo
2280 2280
  */
2281 2281
 function gd_set_theme_compat()
2282 2282
 {
2283
-    global $wpdb;
2284
-    $theme = wp_get_theme();
2283
+	global $wpdb;
2284
+	$theme = wp_get_theme();
2285 2285
 
2286
-    if ($theme->parent()) {
2287
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2288
-    } else {
2289
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
2290
-    }
2286
+	if ($theme->parent()) {
2287
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2288
+	} else {
2289
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
2290
+	}
2291 2291
 
2292
-    $theme_compats = get_option('gd_theme_compats');
2293
-    $current_compat = get_option('gd_theme_compat');
2294
-    $current_compat = str_replace("_custom", "", $current_compat);
2292
+	$theme_compats = get_option('gd_theme_compats');
2293
+	$current_compat = get_option('gd_theme_compat');
2294
+	$current_compat = str_replace("_custom", "", $current_compat);
2295 2295
 
2296
-    if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2297
-        return;
2298
-    }// if already running correct compat then bail
2296
+	if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2297
+		return;
2298
+	}// if already running correct compat then bail
2299 2299
 
2300
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2301
-        update_option('gd_theme_compat', $theme_name);
2302
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2300
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2301
+		update_option('gd_theme_compat', $theme_name);
2302
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2303 2303
 
2304
-        // if there are default options to set then set them
2305
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2304
+		// if there are default options to set then set them
2305
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2306 2306
 
2307
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2308
-                update_option($key, $val);
2309
-            }
2310
-        }
2307
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2308
+				update_option($key, $val);
2309
+			}
2310
+		}
2311 2311
 
2312
-    } else {
2313
-        update_option('gd_theme_compat', '');
2314
-        update_option('theme_compatibility_setting', '');
2315
-    }
2312
+	} else {
2313
+		update_option('gd_theme_compat', '');
2314
+		update_option('theme_compatibility_setting', '');
2315
+	}
2316 2316
 
2317 2317
 
2318 2318
 }
@@ -2327,9 +2327,9 @@  discard block
 block discarded – undo
2327 2327
  */
2328 2328
 function gd_check_avada_compat()
2329 2329
 {
2330
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2331
-        add_action('admin_notices', 'gd_avada_compat_warning');
2332
-    }
2330
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2331
+		add_action('admin_notices', 'gd_avada_compat_warning');
2332
+	}
2333 2333
 }
2334 2334
 
2335 2335
 
@@ -2342,22 +2342,22 @@  discard block
 block discarded – undo
2342 2342
 function gd_avada_compat_warning()
2343 2343
 {
2344 2344
 
2345
-    /*
2345
+	/*
2346 2346
     $msg_type = error
2347 2347
     $msg_type = updated fade
2348 2348
     $msg_type = update-nag
2349 2349
     */
2350 2350
 
2351
-    $plugin = 'avada-nag';
2352
-    $timestamp = 'avada-nag1234';
2353
-    $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');
2354
-    echo '<div id="' . $timestamp . '"  class="error">';
2355
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2356
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2357
-    echo "<p>$message</p>";
2358
-    echo "</div>";
2351
+	$plugin = 'avada-nag';
2352
+	$timestamp = 'avada-nag1234';
2353
+	$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');
2354
+	echo '<div id="' . $timestamp . '"  class="error">';
2355
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2356
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2357
+	echo "<p>$message</p>";
2358
+	echo "</div>";
2359 2359
 
2360
-    ?>
2360
+	?>
2361 2361
     <script>
2362 2362
         function gdRemoveANotification($plugin, $timestamp) {
2363 2363
 
@@ -2425,10 +2425,10 @@  discard block
 block discarded – undo
2425 2425
  */
2426 2426
 function geodir_avada_remove_notification()
2427 2427
 {
2428
-    update_option('avada_nag', TRUE);
2428
+	update_option('avada_nag', TRUE);
2429 2429
 
2430
-    // Always die in functions echoing ajax content
2431
-    die();
2430
+	// Always die in functions echoing ajax content
2431
+	die();
2432 2432
 }
2433 2433
 
2434 2434
 
@@ -2450,9 +2450,9 @@  discard block
 block discarded – undo
2450 2450
 	global $post, $typenow, $current_screen;
2451 2451
 	
2452 2452
 	$post_type = NULL;
2453
-    if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2453
+	if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2454 2454
 		$post_type = get_post_type($_REQUEST['post']);
2455
-    elseif ($post && isset($post->post_type))
2455
+	elseif ($post && isset($post->post_type))
2456 2456
 		$post_type = $post->post_type;
2457 2457
 	elseif ($typenow)
2458 2458
 		$post_type = $typenow;
@@ -2487,7 +2487,7 @@  discard block
 block discarded – undo
2487 2487
 		// Don't allow same slug url for listing and location
2488 2488
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2489 2489
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2490
-        	wp_redirect($redirect_url);
2490
+			wp_redirect($redirect_url);
2491 2491
 			exit;
2492 2492
 		}
2493 2493
 		
@@ -2517,10 +2517,10 @@  discard block
 block discarded – undo
2517 2517
  * @package GeoDirectory
2518 2518
  */
2519 2519
 function geodir_hide_admin_preview_button() {
2520
-    global $post_type;
2521
-    $post_types = geodir_get_posttypes();
2522
-    if(in_array($post_type, $post_types))
2523
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2520
+	global $post_type;
2521
+	$post_types = geodir_get_posttypes();
2522
+	if(in_array($post_type, $post_types))
2523
+		echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2524 2524
 }
2525 2525
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2526 2526
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -2535,7 +2535,7 @@  discard block
 block discarded – undo
2535 2535
  */
2536 2536
 function geodir_import_export_tab( $tabs ) {
2537 2537
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2538
-    return $tabs;
2538
+	return $tabs;
2539 2539
 }
2540 2540
 
2541 2541
 /**
@@ -2550,26 +2550,26 @@  discard block
 block discarded – undo
2550 2550
 function geodir_import_export_page() {
2551 2551
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2552 2552
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2553
-    /**
2554
-     * Filter sample category data csv file url.
2555
-     *
2556
-     * @since 1.0.0
2557
-     * @package GeoDirectory
2558
-     *
2559
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
2560
-     */
2553
+	/**
2554
+	 * Filter sample category data csv file url.
2555
+	 *
2556
+	 * @since 1.0.0
2557
+	 * @package GeoDirectory
2558
+	 *
2559
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
2560
+	 */
2561 2561
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2562 2562
 	
2563 2563
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2564
-    /**
2565
-     * Filter sample post data csv file url.
2566
-     *
2567
-     * @since 1.0.0
2568
-     * @package GeoDirectory
2569
-     *
2570
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
2571
-     */
2572
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2564
+	/**
2565
+	 * Filter sample post data csv file url.
2566
+	 *
2567
+	 * @since 1.0.0
2568
+	 * @package GeoDirectory
2569
+	 *
2570
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
2571
+	 */
2572
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2573 2573
 	
2574 2574
 	$gd_posttypes = geodir_get_posttypes( 'array' );
2575 2575
 	
@@ -2592,14 +2592,14 @@  discard block
 block discarded – undo
2592 2592
 	$gd_chunksize_options[100000] = 100000;
2593 2593
 	 
2594 2594
 	 /**
2595
-     * Filter max entries per export csv file.
2596
-     *
2597
-     * @since 1.5.6
2598
-     * @package GeoDirectory
2599
-     *
2600
-     * @param string $gd_chunksize_options Entries options.
2601
-     */
2602
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2595
+	  * Filter max entries per export csv file.
2596
+	  *
2597
+	  * @since 1.5.6
2598
+	  * @package GeoDirectory
2599
+	  *
2600
+	  * @param string $gd_chunksize_options Entries options.
2601
+	  */
2602
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2603 2603
 	
2604 2604
 	$gd_chunksize_option = '';
2605 2605
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2615,12 +2615,12 @@  discard block
 block discarded – undo
2615 2615
   <div class="gd-content-heading">
2616 2616
 
2617 2617
   <?php
2618
-    ini_set('max_execution_time', 999999);
2619
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2620
-    ini_restore('max_execution_time');
2618
+	ini_set('max_execution_time', 999999);
2619
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2620
+	ini_restore('max_execution_time');
2621 2621
 
2622
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2623
-        ?>
2622
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2623
+		?>
2624 2624
 	<div id="gd_ie_reqs" class="metabox-holder">
2625 2625
       <div class="meta-box-sortables ui-sortable">
2626 2626
         <div class="postbox">
@@ -2793,7 +2793,7 @@  discard block
 block discarded – undo
2793 2793
 						 * Called just after the sample CSV download link.
2794 2794
 						 *
2795 2795
 						 * @since 1.0.0
2796
-                         * @package GeoDirectory
2796
+						 * @package GeoDirectory
2797 2797
 						 */
2798 2798
 						do_action('geodir_sample_cats_csv_download_link');
2799 2799
 						?>
@@ -2878,11 +2878,11 @@  discard block
 block discarded – undo
2878 2878
 	 *
2879 2879
 	 * Called after the last setting on the GD > Import & Export page.
2880 2880
 	 * @since 1.4.6
2881
-     * @package GeoDirectory
2881
+	 * @package GeoDirectory
2882 2882
 	 *
2883 2883
 	 * @param array $gd_posttypes GD post types.
2884
-     * @param array $gd_chunksize_options File chunk size options.
2885
-     * @param string $nonce Wordpress security token for GD import & export.
2884
+	 * @param array $gd_chunksize_options File chunk size options.
2885
+	 * @param string $nonce Wordpress security token for GD import & export.
2886 2886
 	 */
2887 2887
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2888 2888
 	?>
@@ -3569,44 +3569,44 @@  discard block
 block discarded – undo
3569 3569
 function geodir_init_filesystem()
3570 3570
 {
3571 3571
 
3572
-    if(!function_exists('get_filesystem_method')){
3573
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3574
-    }
3575
-    $access_type = get_filesystem_method();
3576
-    if ($access_type === 'direct') {
3577
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3578
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3579
-
3580
-        /* initialize the API */
3581
-        if (!WP_Filesystem($creds)) {
3582
-            /* any problems and we exit */
3583
-            //return '@@@3';
3584
-            return false;
3585
-        }
3586
-
3587
-        global $wp_filesystem;
3588
-        return $wp_filesystem;
3589
-        /* do our file manipulations below */
3590
-    } elseif (defined('FTP_USER')) {
3591
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3572
+	if(!function_exists('get_filesystem_method')){
3573
+		require_once(ABSPATH."/wp-admin/includes/file.php");
3574
+	}
3575
+	$access_type = get_filesystem_method();
3576
+	if ($access_type === 'direct') {
3577
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3578
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3579
+
3580
+		/* initialize the API */
3581
+		if (!WP_Filesystem($creds)) {
3582
+			/* any problems and we exit */
3583
+			//return '@@@3';
3584
+			return false;
3585
+		}
3592 3586
 
3593
-        /* initialize the API */
3594
-        if (!WP_Filesystem($creds)) {
3595
-            /* any problems and we exit */
3596
-            //return '@@@33';
3597
-            return false;
3598
-        }
3587
+		global $wp_filesystem;
3588
+		return $wp_filesystem;
3589
+		/* do our file manipulations below */
3590
+	} elseif (defined('FTP_USER')) {
3591
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3592
+
3593
+		/* initialize the API */
3594
+		if (!WP_Filesystem($creds)) {
3595
+			/* any problems and we exit */
3596
+			//return '@@@33';
3597
+			return false;
3598
+		}
3599 3599
 
3600
-        global $wp_filesystem;
3601
-        //return '@@@1';
3602
-        return $wp_filesystem;
3600
+		global $wp_filesystem;
3601
+		//return '@@@1';
3602
+		return $wp_filesystem;
3603 3603
 
3604
-    } else {
3605
-        //return '@@@2';
3606
-        /* don't have direct write access. Prompt user with our notice */
3607
-        add_action('admin_notice', 'geodir_filesystem_notice');
3608
-        return false;
3609
-    }
3604
+	} else {
3605
+		//return '@@@2';
3606
+		/* don't have direct write access. Prompt user with our notice */
3607
+		add_action('admin_notice', 'geodir_filesystem_notice');
3608
+		return false;
3609
+	}
3610 3610
 
3611 3611
 }
3612 3612
 
@@ -3624,10 +3624,10 @@  discard block
 block discarded – undo
3624 3624
  */
3625 3625
 function geodir_filesystem_notice()
3626 3626
 {   if ( defined( 'DOING_AJAX' ) ){return;}
3627
-    $access_type = get_filesystem_method();
3628
-    if ($access_type === 'direct') {
3629
-    } elseif (!defined('FTP_USER')) {
3630
-        ?>
3627
+	$access_type = get_filesystem_method();
3628
+	if ($access_type === 'direct') {
3629
+	} elseif (!defined('FTP_USER')) {
3630
+		?>
3631 3631
         <div class="error">
3632 3632
             <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'); ?>
3633 3633
                 <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>
@@ -3653,1251 +3653,1251 @@  discard block
 block discarded – undo
3653 3653
  * @return string Json data.
3654 3654
  */
3655 3655
 function geodir_ajax_import_export() {
3656
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3656
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3657 3657
     
3658
-    error_reporting(0);
3658
+	error_reporting(0);
3659 3659
 
3660
-    // try to set higher limits for import
3661
-    $max_input_time = ini_get('max_input_time');
3662
-    $max_execution_time = ini_get('max_execution_time');
3663
-    $memory_limit= ini_get('memory_limit');
3660
+	// try to set higher limits for import
3661
+	$max_input_time = ini_get('max_input_time');
3662
+	$max_execution_time = ini_get('max_execution_time');
3663
+	$memory_limit= ini_get('memory_limit');
3664 3664
 
3665
-    if(!$max_input_time || $max_input_time<3000){
3666
-        ini_set('max_input_time', 3000);
3667
-    }
3665
+	if(!$max_input_time || $max_input_time<3000){
3666
+		ini_set('max_input_time', 3000);
3667
+	}
3668 3668
 
3669
-    if(!$max_execution_time || $max_execution_time<3000){
3670
-        ini_set('max_execution_time', 3000);
3671
-    }
3669
+	if(!$max_execution_time || $max_execution_time<3000){
3670
+		ini_set('max_execution_time', 3000);
3671
+	}
3672 3672
 
3673
-    if($memory_limit && str_replace('M','',$memory_limit)){
3674
-        if(str_replace('M','',$memory_limit)<256){
3675
-            ini_set('memory_limit', '256M');
3676
-        }
3677
-    }
3673
+	if($memory_limit && str_replace('M','',$memory_limit)){
3674
+		if(str_replace('M','',$memory_limit)<256){
3675
+			ini_set('memory_limit', '256M');
3676
+		}
3677
+	}
3678 3678
 
3679
-    $json = array();
3679
+	$json = array();
3680 3680
 
3681
-    if ( !current_user_can( 'manage_options' ) ) {
3682
-        wp_send_json( $json );
3683
-    }
3681
+	if ( !current_user_can( 'manage_options' ) ) {
3682
+		wp_send_json( $json );
3683
+	}
3684 3684
 
3685
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3686
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3687
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3685
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3686
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3687
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3688 3688
 
3689
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3690
-        wp_send_json( $json );
3691
-    }
3689
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3690
+		wp_send_json( $json );
3691
+	}
3692 3692
 
3693
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3694
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3695
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3696
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3693
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3694
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3695
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3696
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3697 3697
 
3698
-    $wp_filesystem = geodir_init_filesystem();
3699
-    if (!$wp_filesystem) {
3700
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3701
-        wp_send_json( $json );
3702
-    }
3698
+	$wp_filesystem = geodir_init_filesystem();
3699
+	if (!$wp_filesystem) {
3700
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3701
+		wp_send_json( $json );
3702
+	}
3703 3703
 
3704
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3705
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3706
-        wp_send_json( $json );
3707
-    }
3704
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3705
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3706
+		wp_send_json( $json );
3707
+	}
3708 3708
 
3709
-    $csv_file_dir = geodir_path_import_export( false );
3710
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3711
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3712
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3713
-            wp_send_json( $json );
3714
-        }
3715
-    }
3709
+	$csv_file_dir = geodir_path_import_export( false );
3710
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3711
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3712
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3713
+			wp_send_json( $json );
3714
+		}
3715
+	}
3716 3716
     
3717
-    $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3718
-    $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3719
-
3720
-    switch ( $task ) {
3721
-        case 'export_posts': {
3722
-            // WPML
3723
-            $is_wpml = geodir_is_wpml();
3724
-            if ($is_wpml) {
3725
-                global $sitepress;
3726
-                $active_lang = ICL_LANGUAGE_CODE;
3717
+	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3718
+	$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3719
+
3720
+	switch ( $task ) {
3721
+		case 'export_posts': {
3722
+			// WPML
3723
+			$is_wpml = geodir_is_wpml();
3724
+			if ($is_wpml) {
3725
+				global $sitepress;
3726
+				$active_lang = ICL_LANGUAGE_CODE;
3727 3727
                 
3728
-                $sitepress->switch_lang('all', true);
3729
-            }
3730
-            // WPML
3731
-            if ( $post_type == 'gd_event' ) {
3732
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3733
-            }
3734
-            $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3728
+				$sitepress->switch_lang('all', true);
3729
+			}
3730
+			// WPML
3731
+			if ( $post_type == 'gd_event' ) {
3732
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3733
+			}
3734
+			$filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3735 3735
             
3736
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3737
-            if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3738
-                $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3739
-            }
3740
-            $posts_count = geodir_get_posts_count( $post_type );
3741
-            $file_url_base = geodir_path_import_export() . '/';
3742
-            $file_url = $file_url_base . $file_name . '.csv';
3743
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3744
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3736
+			$file_name = $post_type . '_' . date( 'dmyHi' );
3737
+			if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3738
+				$file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3739
+			}
3740
+			$posts_count = geodir_get_posts_count( $post_type );
3741
+			$file_url_base = geodir_path_import_export() . '/';
3742
+			$file_url = $file_url_base . $file_name . '.csv';
3743
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3744
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3745 3745
             
3746
-            $chunk_file_paths = array();
3746
+			$chunk_file_paths = array();
3747 3747
 
3748
-            if ( isset( $_REQUEST['_c'] ) ) {
3749
-                $json['total'] = $posts_count;
3750
-                // WPML
3751
-                if ($is_wpml) {
3752
-                    $sitepress->switch_lang($active_lang, true);
3753
-                }
3754
-                // WPML
3755
-                wp_send_json( $json );
3756
-                gd_die();
3757
-            } else if ( isset( $_REQUEST['_st'] ) ) {
3758
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3759
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3760
-                $percentage = min( $percentage, 100 );
3748
+			if ( isset( $_REQUEST['_c'] ) ) {
3749
+				$json['total'] = $posts_count;
3750
+				// WPML
3751
+				if ($is_wpml) {
3752
+					$sitepress->switch_lang($active_lang, true);
3753
+				}
3754
+				// WPML
3755
+				wp_send_json( $json );
3756
+				gd_die();
3757
+			} else if ( isset( $_REQUEST['_st'] ) ) {
3758
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3759
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3760
+				$percentage = min( $percentage, 100 );
3761 3761
                 
3762
-                $json['percentage'] = $percentage;
3763
-                // WPML
3764
-                if ($is_wpml) {
3765
-                    $sitepress->switch_lang($active_lang, true);
3766
-                }
3767
-                // WPML
3768
-                wp_send_json( $json );
3769
-                gd_die();
3770
-            } else {
3771
-                if ( !$posts_count > 0 ) {
3772
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3773
-                } else {
3774
-                    $total_posts = $posts_count;
3775
-                    if ($chunk_per_page > $total_posts) {
3776
-                        $chunk_per_page = $total_posts;
3777
-                    }
3778
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3762
+				$json['percentage'] = $percentage;
3763
+				// WPML
3764
+				if ($is_wpml) {
3765
+					$sitepress->switch_lang($active_lang, true);
3766
+				}
3767
+				// WPML
3768
+				wp_send_json( $json );
3769
+				gd_die();
3770
+			} else {
3771
+				if ( !$posts_count > 0 ) {
3772
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3773
+				} else {
3774
+					$total_posts = $posts_count;
3775
+					if ($chunk_per_page > $total_posts) {
3776
+						$chunk_per_page = $total_posts;
3777
+					}
3778
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3779 3779
                     
3780
-                    $j = $chunk_page_no;
3781
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3780
+					$j = $chunk_page_no;
3781
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3782 3782
                     
3783
-                    $per_page = 500;
3784
-                    if ($per_page > $chunk_per_page) {
3785
-                        $per_page = $chunk_per_page;
3786
-                    }
3787
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3783
+					$per_page = 500;
3784
+					if ($per_page > $chunk_per_page) {
3785
+						$per_page = $chunk_per_page;
3786
+					}
3787
+					$total_pages = ceil( $chunk_per_page / $per_page );
3788 3788
                     
3789
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3790
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3789
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3790
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3791 3791
                         
3792
-                        $clear = $i == 0 ? true : false;
3793
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3794
-                    }
3792
+						$clear = $i == 0 ? true : false;
3793
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3794
+					}
3795 3795
                         
3796
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3797
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3798
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3799
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3800
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3796
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3797
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3798
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3799
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3800
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3801 3801
                         
3802
-                        $file_url = $file_url_base . $chunk_file_name;
3803
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3804
-                    }
3802
+						$file_url = $file_url_base . $chunk_file_name;
3803
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3804
+					}
3805 3805
                     
3806
-                    if ( !empty($chunk_file_paths) ) {
3807
-                        $json['total'] = $posts_count;
3808
-                        $json['files'] = $chunk_file_paths;
3809
-                    } else {
3810
-                        if ($j > 1) {
3811
-                            $json['total'] = $posts_count;
3812
-                            $json['files'] = array();
3813
-                        } else {
3814
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3815
-                        }
3816
-                    }
3817
-                }
3818
-                // WPML
3819
-                if ($is_wpml) {
3820
-                    $sitepress->switch_lang($active_lang, true);
3821
-                }
3822
-                // WPML
3823
-                wp_send_json( $json );
3824
-            }
3825
-        }
3826
-        break;
3827
-        case 'export_cats': {
3828
-            // WPML
3829
-            $is_wpml = geodir_is_wpml();
3830
-            if ($is_wpml) {
3831
-                global $sitepress;
3832
-                $active_lang = ICL_LANGUAGE_CODE;
3806
+					if ( !empty($chunk_file_paths) ) {
3807
+						$json['total'] = $posts_count;
3808
+						$json['files'] = $chunk_file_paths;
3809
+					} else {
3810
+						if ($j > 1) {
3811
+							$json['total'] = $posts_count;
3812
+							$json['files'] = array();
3813
+						} else {
3814
+							$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3815
+						}
3816
+					}
3817
+				}
3818
+				// WPML
3819
+				if ($is_wpml) {
3820
+					$sitepress->switch_lang($active_lang, true);
3821
+				}
3822
+				// WPML
3823
+				wp_send_json( $json );
3824
+			}
3825
+		}
3826
+		break;
3827
+		case 'export_cats': {
3828
+			// WPML
3829
+			$is_wpml = geodir_is_wpml();
3830
+			if ($is_wpml) {
3831
+				global $sitepress;
3832
+				$active_lang = ICL_LANGUAGE_CODE;
3833 3833
                 
3834
-                $sitepress->switch_lang('all', true);
3835
-            }
3836
-            // WPML
3837
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3834
+				$sitepress->switch_lang('all', true);
3835
+			}
3836
+			// WPML
3837
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
3838 3838
             
3839
-            $terms_count = geodir_get_terms_count( $post_type );
3840
-            $file_url_base = geodir_path_import_export() . '/';
3841
-            $file_url = $file_url_base . $file_name . '.csv';
3842
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3843
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3839
+			$terms_count = geodir_get_terms_count( $post_type );
3840
+			$file_url_base = geodir_path_import_export() . '/';
3841
+			$file_url = $file_url_base . $file_name . '.csv';
3842
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3843
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3844 3844
             
3845
-            $chunk_file_paths = array();
3845
+			$chunk_file_paths = array();
3846 3846
             
3847
-            if ( isset( $_REQUEST['_st'] ) ) {
3848
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3849
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3850
-                $percentage = min( $percentage, 100 );
3847
+			if ( isset( $_REQUEST['_st'] ) ) {
3848
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3849
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3850
+				$percentage = min( $percentage, 100 );
3851 3851
                 
3852
-                $json['percentage'] = $percentage;
3853
-                // WPML
3854
-                if ($is_wpml) {
3855
-                    $sitepress->switch_lang($active_lang, true);
3856
-                }
3857
-                // WPML
3858
-                wp_send_json( $json );
3859
-            } else {
3860
-                if ( !$terms_count > 0 ) {
3861
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3862
-                } else {
3863
-                    $total_terms = $terms_count;
3864
-                    if ($chunk_per_page > $terms_count) {
3865
-                        $chunk_per_page = $terms_count;
3866
-                    }
3867
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3852
+				$json['percentage'] = $percentage;
3853
+				// WPML
3854
+				if ($is_wpml) {
3855
+					$sitepress->switch_lang($active_lang, true);
3856
+				}
3857
+				// WPML
3858
+				wp_send_json( $json );
3859
+			} else {
3860
+				if ( !$terms_count > 0 ) {
3861
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3862
+				} else {
3863
+					$total_terms = $terms_count;
3864
+					if ($chunk_per_page > $terms_count) {
3865
+						$chunk_per_page = $terms_count;
3866
+					}
3867
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3868 3868
                     
3869
-                    $j = $chunk_page_no;
3870
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3869
+					$j = $chunk_page_no;
3870
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3871 3871
                     
3872
-                    $per_page = 500;
3873
-                    if ($per_page > $chunk_per_page) {
3874
-                        $per_page = $chunk_per_page;
3875
-                    }
3876
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3872
+					$per_page = 500;
3873
+					if ($per_page > $chunk_per_page) {
3874
+						$per_page = $chunk_per_page;
3875
+					}
3876
+					$total_pages = ceil( $chunk_per_page / $per_page );
3877 3877
                     
3878
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3879
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3878
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3879
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3880 3880
                         
3881
-                        $clear = $i == 0 ? true : false;
3882
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3883
-                    }
3881
+						$clear = $i == 0 ? true : false;
3882
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3883
+					}
3884 3884
                     
3885
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3886
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3887
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3888
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3889
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3885
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3886
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3887
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3888
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3889
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3890 3890
                         
3891
-                        $file_url = $file_url_base . $chunk_file_name;
3892
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3893
-                    }
3891
+						$file_url = $file_url_base . $chunk_file_name;
3892
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3893
+					}
3894 3894
                     
3895
-                    if ( !empty($chunk_file_paths) ) {
3896
-                        $json['total'] = $terms_count;
3897
-                        $json['files'] = $chunk_file_paths;
3898
-                    } else {
3899
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3900
-                    }
3901
-                }
3902
-                // WPML
3903
-                if ($is_wpml) {
3904
-                    $sitepress->switch_lang($active_lang, true);
3905
-                }
3906
-                // WPML
3907
-                wp_send_json( $json );
3908
-            }
3909
-        }
3910
-        break;
3911
-        case 'export_locations': {
3912
-            $file_url_base = geodir_path_import_export() . '/';
3913
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3914
-            $file_url = $file_url_base . $file_name . '.csv';
3915
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3916
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3895
+					if ( !empty($chunk_file_paths) ) {
3896
+						$json['total'] = $terms_count;
3897
+						$json['files'] = $chunk_file_paths;
3898
+					} else {
3899
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3900
+					}
3901
+				}
3902
+				// WPML
3903
+				if ($is_wpml) {
3904
+					$sitepress->switch_lang($active_lang, true);
3905
+				}
3906
+				// WPML
3907
+				wp_send_json( $json );
3908
+			}
3909
+		}
3910
+		break;
3911
+		case 'export_locations': {
3912
+			$file_url_base = geodir_path_import_export() . '/';
3913
+			$file_name = 'gd_locations_' . date( 'dmyHi' );
3914
+			$file_url = $file_url_base . $file_name . '.csv';
3915
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3916
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3917 3917
             
3918
-            $items_count = (int)geodir_location_imex_count_locations();
3918
+			$items_count = (int)geodir_location_imex_count_locations();
3919 3919
             
3920
-            if ( isset( $_REQUEST['_st'] ) ) {
3921
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3922
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3923
-                $percentage = min( $percentage, 100 );
3920
+			if ( isset( $_REQUEST['_st'] ) ) {
3921
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3922
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3923
+				$percentage = min( $percentage, 100 );
3924 3924
                 
3925
-                $json['percentage'] = $percentage;
3926
-                wp_send_json( $json );
3927
-            } else {
3928
-                $chunk_file_paths = array();
3925
+				$json['percentage'] = $percentage;
3926
+				wp_send_json( $json );
3927
+			} else {
3928
+				$chunk_file_paths = array();
3929 3929
                 
3930
-                if ( !$items_count > 0 ) {
3931
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3932
-                } else {
3933
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3934
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3930
+				if ( !$items_count > 0 ) {
3931
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3932
+				} else {
3933
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3934
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3935 3935
                     
3936
-                    $j = $chunk_page_no;
3937
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3936
+					$j = $chunk_page_no;
3937
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3938 3938
                     
3939
-                    $per_page = 500;
3940
-                    $per_page = min( $per_page, $chunk_per_page );
3941
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3939
+					$per_page = 500;
3940
+					$per_page = min( $per_page, $chunk_per_page );
3941
+					$total_pages = ceil( $chunk_per_page / $per_page );
3942 3942
                     
3943
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3944
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3943
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3944
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3945 3945
                         
3946
-                        $clear = $i == 0 ? true : false;
3947
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3948
-                    }
3946
+						$clear = $i == 0 ? true : false;
3947
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3948
+					}
3949 3949
                     
3950
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3951
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3952
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3953
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3954
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3950
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3951
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3952
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3953
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3954
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3955 3955
                         
3956
-                        $file_url = $file_url_base . $chunk_file_name;
3957
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3958
-                    }
3956
+						$file_url = $file_url_base . $chunk_file_name;
3957
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3958
+					}
3959 3959
                     
3960
-                    if ( !empty($chunk_file_paths) ) {
3961
-                        $json['total'] = $items_count;
3962
-                        $json['files'] = $chunk_file_paths;
3963
-                    } else {
3964
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3965
-                    }
3966
-                }
3967
-                wp_send_json( $json );
3968
-            }
3969
-        }
3970
-        break;
3971
-        case 'export_hoods': {
3972
-            $file_url_base = geodir_path_import_export() . '/';
3973
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3974
-            $file_url = $file_url_base . $file_name . '.csv';
3975
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3976
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3960
+					if ( !empty($chunk_file_paths) ) {
3961
+						$json['total'] = $items_count;
3962
+						$json['files'] = $chunk_file_paths;
3963
+					} else {
3964
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3965
+					}
3966
+				}
3967
+				wp_send_json( $json );
3968
+			}
3969
+		}
3970
+		break;
3971
+		case 'export_hoods': {
3972
+			$file_url_base = geodir_path_import_export() . '/';
3973
+			$file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3974
+			$file_url = $file_url_base . $file_name . '.csv';
3975
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3976
+			$file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3977 3977
             
3978
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3978
+			$items_count = (int)geodir_location_imex_count_neighbourhoods();
3979 3979
             
3980
-            if ( isset( $_REQUEST['_st'] ) ) {
3981
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3982
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3983
-                $percentage = min( $percentage, 100 );
3980
+			if ( isset( $_REQUEST['_st'] ) ) {
3981
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3982
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3983
+				$percentage = min( $percentage, 100 );
3984 3984
                 
3985
-                $json['percentage'] = $percentage;
3986
-                wp_send_json( $json );
3987
-            } else {
3988
-                $chunk_file_paths = array();
3985
+				$json['percentage'] = $percentage;
3986
+				wp_send_json( $json );
3987
+			} else {
3988
+				$chunk_file_paths = array();
3989 3989
                 
3990
-                if ( !$items_count > 0 ) {
3991
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3992
-                } else {
3993
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3994
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3990
+				if ( !$items_count > 0 ) {
3991
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3992
+				} else {
3993
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3994
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3995 3995
                     
3996
-                    $j = $chunk_page_no;
3997
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3996
+					$j = $chunk_page_no;
3997
+					$chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3998 3998
                     
3999
-                    $per_page = 500;
4000
-                    $per_page = min( $per_page, $chunk_per_page );
4001
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3999
+					$per_page = 500;
4000
+					$per_page = min( $per_page, $chunk_per_page );
4001
+					$total_pages = ceil( $chunk_per_page / $per_page );
4002 4002
                     
4003
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4004
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
4003
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
4004
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
4005 4005
                         
4006
-                        $clear = $i == 0 ? true : false;
4007
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
4008
-                    }
4006
+						$clear = $i == 0 ? true : false;
4007
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
4008
+					}
4009 4009
                     
4010
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4011
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4012
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4013
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
4014
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4010
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
4011
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4012
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
4013
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
4014
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
4015 4015
                         
4016
-                        $file_url = $file_url_base . $chunk_file_name;
4017
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4018
-                    }
4016
+						$file_url = $file_url_base . $chunk_file_name;
4017
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4018
+					}
4019 4019
                     
4020
-                    if ( !empty($chunk_file_paths) ) {
4021
-                        $json['total'] = $items_count;
4022
-                        $json['files'] = $chunk_file_paths;
4023
-                    } else {
4024
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
4025
-                    }
4026
-                }
4027
-                wp_send_json( $json );
4028
-            }
4029
-        }
4030
-        break;
4031
-        case 'prepare_import':
4032
-        case 'import_cat':
4033
-        case 'import_post':
4034
-        case 'import_loc':
4035
-        case 'import_hood': {
4036
-            // WPML
4037
-            $is_wpml = geodir_is_wpml();
4038
-            if ($is_wpml) {
4039
-                global $sitepress;
4040
-                $active_lang = ICL_LANGUAGE_CODE;
4041
-            }
4042
-            // WPML
4020
+					if ( !empty($chunk_file_paths) ) {
4021
+						$json['total'] = $items_count;
4022
+						$json['files'] = $chunk_file_paths;
4023
+					} else {
4024
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
4025
+					}
4026
+				}
4027
+				wp_send_json( $json );
4028
+			}
4029
+		}
4030
+		break;
4031
+		case 'prepare_import':
4032
+		case 'import_cat':
4033
+		case 'import_post':
4034
+		case 'import_loc':
4035
+		case 'import_hood': {
4036
+			// WPML
4037
+			$is_wpml = geodir_is_wpml();
4038
+			if ($is_wpml) {
4039
+				global $sitepress;
4040
+				$active_lang = ICL_LANGUAGE_CODE;
4041
+			}
4042
+			// WPML
4043 4043
             
4044
-            ini_set( 'auto_detect_line_endings', true );
4044
+			ini_set( 'auto_detect_line_endings', true );
4045 4045
             
4046
-            $uploads = wp_upload_dir();
4047
-            $uploads_dir = $uploads['path'];
4048
-            $uploads_subdir = $uploads['subdir'];
4046
+			$uploads = wp_upload_dir();
4047
+			$uploads_dir = $uploads['path'];
4048
+			$uploads_subdir = $uploads['subdir'];
4049 4049
             
4050
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
4051
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
4050
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
4051
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
4052 4052
             
4053
-            $csv_file_arr = explode( '/', $csv_file );
4054
-            $csv_filename = end( $csv_file_arr );
4055
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
4053
+			$csv_file_arr = explode( '/', $csv_file );
4054
+			$csv_filename = end( $csv_file_arr );
4055
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
4056 4056
             
4057
-            $json['file'] = $csv_file;
4058
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4059
-            $file = array();
4057
+			$json['file'] = $csv_file;
4058
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4059
+			$file = array();
4060 4060
 
4061
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4062
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4061
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4062
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4063 4063
                 
4064
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4065
-                    $json['error'] = NULL;
4066
-                    $json['rows'] = 0;
4064
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4065
+					$json['error'] = NULL;
4066
+					$json['rows'] = 0;
4067 4067
                     
4068
-                    $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
4069
-                    setlocale(LC_ALL, 'en_US.UTF-8');
4070
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4071
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4072
-                            if ( !empty( $data ) ) {
4073
-                                $file[] = $data;
4074
-                            }
4075
-                        }
4076
-                        fclose($handle);
4077
-                    }
4078
-                    setlocale(LC_ALL, $lc_all);
4068
+					$lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
4069
+					setlocale(LC_ALL, 'en_US.UTF-8');
4070
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4071
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4072
+							if ( !empty( $data ) ) {
4073
+								$file[] = $data;
4074
+							}
4075
+						}
4076
+						fclose($handle);
4077
+					}
4078
+					setlocale(LC_ALL, $lc_all);
4079 4079
 
4080
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4080
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4081 4081
                     
4082
-                    if (!$json['rows'] > 0) {
4083
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
4084
-                    }
4085
-                } else {
4086
-                    wp_send_json( $json );
4087
-                }
4088
-            } else {
4089
-                wp_send_json( $json );
4090
-            }
4082
+					if (!$json['rows'] > 0) {
4083
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
4084
+					}
4085
+				} else {
4086
+					wp_send_json( $json );
4087
+				}
4088
+			} else {
4089
+				wp_send_json( $json );
4090
+			}
4091 4091
             
4092
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4093
-                wp_send_json( $json );
4094
-            }
4092
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4093
+				wp_send_json( $json );
4094
+			}
4095 4095
             
4096
-            $total = $json['rows'];
4097
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4098
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4096
+			$total = $json['rows'];
4097
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4098
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4099 4099
             
4100
-            $count = $limit;
4100
+			$count = $limit;
4101 4101
             
4102
-            if ($count < $total) {
4103
-                $count = $processed + $count;
4104
-                if ($count > $total) {
4105
-                    $count = $total;
4106
-                }
4107
-            } else {
4108
-                $count = $total;
4109
-            }
4102
+			if ($count < $total) {
4103
+				$count = $processed + $count;
4104
+				if ($count > $total) {
4105
+					$count = $total;
4106
+				}
4107
+			} else {
4108
+				$count = $total;
4109
+			}
4110 4110
             
4111
-            $created = 0;
4112
-            $updated = 0;
4113
-            $skipped = 0;
4114
-            $invalid = 0;
4115
-            $invalid_addr = 0;
4116
-            $images = 0;
4111
+			$created = 0;
4112
+			$updated = 0;
4113
+			$skipped = 0;
4114
+			$invalid = 0;
4115
+			$invalid_addr = 0;
4116
+			$images = 0;
4117 4117
             
4118
-            $gd_post_info = array();
4119
-            $countpost = 0;
4118
+			$gd_post_info = array();
4119
+			$countpost = 0;
4120 4120
             
4121
-            $post_types = geodir_get_posttypes();
4121
+			$post_types = geodir_get_posttypes();
4122 4122
 
4123
-            if ( $task == 'import_cat' ) {
4124
-                if (!empty($file)) {
4125
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4123
+			if ( $task == 'import_cat' ) {
4124
+				if (!empty($file)) {
4125
+					$columns = isset($file[0]) ? $file[0] : NULL;
4126 4126
                     
4127
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4128
-                        $json['error'] = CSV_INVAILD_FILE;
4129
-                        wp_send_json( $json );
4130
-                        exit;
4131
-                    }
4127
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4128
+						$json['error'] = CSV_INVAILD_FILE;
4129
+						wp_send_json( $json );
4130
+						exit;
4131
+					}
4132 4132
                     
4133
-                    $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4133
+					$gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4134 4134
                     
4135
-                    for ($i = 1; $i <= $limit; $i++) {
4136
-                        $index = $processed + $i;
4135
+					for ($i = 1; $i <= $limit; $i++) {
4136
+						$index = $processed + $i;
4137 4137
                         
4138
-                        if (isset($file[$index])) {
4139
-                            $row = $file[$index];
4140
-                            $row = array_map( 'trim', $row );
4141
-                            //$row = array_map( 'utf8_encode', $row );
4138
+						if (isset($file[$index])) {
4139
+							$row = $file[$index];
4140
+							$row = array_map( 'trim', $row );
4141
+							//$row = array_map( 'utf8_encode', $row );
4142 4142
                             
4143
-                            $cat_id = '';
4144
-                            $cat_name = '';
4145
-                            $cat_slug = '';
4146
-                            $cat_posttype = '';
4147
-                            $cat_parent = '';
4148
-                            $cat_description = '';
4149
-                            $cat_schema = '';
4150
-                            $cat_top_description = '';
4151
-                            $cat_image = '';
4152
-                            $cat_icon = '';
4153
-                            $cat_language = '';
4154
-                            $cat_id_original = '';
4143
+							$cat_id = '';
4144
+							$cat_name = '';
4145
+							$cat_slug = '';
4146
+							$cat_posttype = '';
4147
+							$cat_parent = '';
4148
+							$cat_description = '';
4149
+							$cat_schema = '';
4150
+							$cat_top_description = '';
4151
+							$cat_image = '';
4152
+							$cat_icon = '';
4153
+							$cat_language = '';
4154
+							$cat_id_original = '';
4155 4155
                             
4156
-                            $c = 0;
4157
-                            foreach ($columns as $column ) {
4158
-                                if ( $column == 'cat_id' ) {
4159
-                                    $cat_id = (int)$row[$c];
4160
-                                } else if ( $column == 'cat_name' ) {
4161
-                                    $cat_name = $row[$c];
4162
-                                } else if ( $column == 'cat_slug' ) {
4163
-                                    $cat_slug = $row[$c];
4164
-                                } else if ( $column == 'cat_posttype' ) {
4165
-                                    $cat_posttype = $row[$c];
4166
-                                } else if ( $column == 'cat_parent' ) {
4167
-                                    $cat_parent = trim($row[$c]);
4168
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4169
-                                    $cat_schema = $row[$c];
4170
-                                } else if ( $column == 'cat_description' ) {
4171
-                                    $cat_description = $row[$c];
4172
-                                } else if ( $column == 'cat_top_description' ) {
4173
-                                    $cat_top_description = $row[$c];
4174
-                                } else if ( $column == 'cat_image' ) {
4175
-                                    $cat_image = $row[$c];
4176
-                                } else if ( $column == 'cat_icon' ) {
4177
-                                    $cat_icon = $row[$c];
4178
-                                }
4179
-                                // WPML
4180
-                                if ( $is_wpml ) {
4181
-                                    if ( $column == 'cat_language' ) {
4182
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
4183
-                                    } else if ( $column == 'cat_id_original' ) {
4184
-                                        $cat_id_original = (int)$row[$c];
4185
-                                    }
4186
-                                }
4187
-                                // WPML
4188
-                                $c++;
4189
-                            }
4156
+							$c = 0;
4157
+							foreach ($columns as $column ) {
4158
+								if ( $column == 'cat_id' ) {
4159
+									$cat_id = (int)$row[$c];
4160
+								} else if ( $column == 'cat_name' ) {
4161
+									$cat_name = $row[$c];
4162
+								} else if ( $column == 'cat_slug' ) {
4163
+									$cat_slug = $row[$c];
4164
+								} else if ( $column == 'cat_posttype' ) {
4165
+									$cat_posttype = $row[$c];
4166
+								} else if ( $column == 'cat_parent' ) {
4167
+									$cat_parent = trim($row[$c]);
4168
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4169
+									$cat_schema = $row[$c];
4170
+								} else if ( $column == 'cat_description' ) {
4171
+									$cat_description = $row[$c];
4172
+								} else if ( $column == 'cat_top_description' ) {
4173
+									$cat_top_description = $row[$c];
4174
+								} else if ( $column == 'cat_image' ) {
4175
+									$cat_image = $row[$c];
4176
+								} else if ( $column == 'cat_icon' ) {
4177
+									$cat_icon = $row[$c];
4178
+								}
4179
+								// WPML
4180
+								if ( $is_wpml ) {
4181
+									if ( $column == 'cat_language' ) {
4182
+										$cat_language = geodir_strtolower( trim( $row[$c] ) );
4183
+									} else if ( $column == 'cat_id_original' ) {
4184
+										$cat_id_original = (int)$row[$c];
4185
+									}
4186
+								}
4187
+								// WPML
4188
+								$c++;
4189
+							}
4190 4190
                             
4191
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4192
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4191
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4192
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4193 4193
                                 
4194
-                                $invalid++;
4195
-                                continue;
4196
-                            }
4194
+								$invalid++;
4195
+								continue;
4196
+							}
4197 4197
                             
4198
-                            // WPML
4199
-                            if ($is_wpml && $cat_language != '') {
4200
-                                $sitepress->switch_lang($cat_language, true);
4201
-                            }
4202
-                            // WPML
4198
+							// WPML
4199
+							if ($is_wpml && $cat_language != '') {
4200
+								$sitepress->switch_lang($cat_language, true);
4201
+							}
4202
+							// WPML
4203 4203
                                                         
4204
-                            $term_data = array();
4205
-                            $term_data['name'] = $cat_name;
4206
-                            $term_data['slug'] = $cat_slug;
4207
-                            $term_data['description'] = $cat_description;
4208
-                            $term_data['cat_schema'] = $cat_schema;
4209
-                            $term_data['top_description'] = $cat_top_description;
4210
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4211
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4204
+							$term_data = array();
4205
+							$term_data['name'] = $cat_name;
4206
+							$term_data['slug'] = $cat_slug;
4207
+							$term_data['description'] = $cat_description;
4208
+							$term_data['cat_schema'] = $cat_schema;
4209
+							$term_data['top_description'] = $cat_top_description;
4210
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4211
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4212 4212
                             
4213
-                            //$term_data = array_map( 'utf8_encode', $term_data );
4213
+							//$term_data = array_map( 'utf8_encode', $term_data );
4214 4214
                             
4215
-                            $taxonomy = $cat_posttype . 'category';
4215
+							$taxonomy = $cat_posttype . 'category';
4216 4216
                             
4217
-                            $term_data['taxonomy'] = $taxonomy;
4217
+							$term_data['taxonomy'] = $taxonomy;
4218 4218
 
4219
-                            $term_parent_id = 0;
4220
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4221
-                                $term_parent = '';
4219
+							$term_parent_id = 0;
4220
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
4221
+								$term_parent = '';
4222 4222
                                 
4223
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4224
-                                    //
4225
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4226
-                                    //
4227
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4228
-                                    //
4229
-                                } else {
4230
-                                    $term_parent_data = array();
4231
-                                    $term_parent_data['name'] = $cat_parent;
4232
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4233
-                                    $term_parent_data['taxonomy'] = $taxonomy;
4223
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4224
+									//
4225
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4226
+									//
4227
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4228
+									//
4229
+								} else {
4230
+									$term_parent_data = array();
4231
+									$term_parent_data['name'] = $cat_parent;
4232
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4233
+									$term_parent_data['taxonomy'] = $taxonomy;
4234 4234
                                     
4235
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4236
-                                }
4235
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4236
+								}
4237 4237
                                 
4238
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4239
-                                    $term_parent_id = (int)$term_parent->term_id;
4240
-                                }
4241
-                            }
4242
-                            $term_data['parent'] = (int)$term_parent_id;
4238
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4239
+									$term_parent_id = (int)$term_parent->term_id;
4240
+								}
4241
+							}
4242
+							$term_data['parent'] = (int)$term_parent_id;
4243 4243
 
4244
-                            $term_id = NULL;
4245
-                            if ( $import_choice == 'update' ) {
4246
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4247
-                                    $term_data['term_id'] = $term['term_id'];
4244
+							$term_id = NULL;
4245
+							if ( $import_choice == 'update' ) {
4246
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4247
+									$term_data['term_id'] = $term['term_id'];
4248 4248
                                     
4249
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4250
-                                        $updated++;
4251
-                                    } else {
4252
-                                        $invalid++;
4253
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4254
-                                    }
4255
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4256
-                                    $term_data['term_id'] = $term['term_id'];
4249
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4250
+										$updated++;
4251
+									} else {
4252
+										$invalid++;
4253
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4254
+									}
4255
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4256
+									$term_data['term_id'] = $term['term_id'];
4257 4257
                                     
4258
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4259
-                                        $updated++;
4260
-                                    } else {
4261
-                                        $invalid++;
4262
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4263
-                                    }
4264
-                                } else {
4265
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4266
-                                        $created++;
4267
-                                    } else {
4268
-                                        $invalid++;
4269
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4270
-                                    }
4271
-                                }
4272
-                            } else if ( $import_choice == 'skip' ) {
4273
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4274
-                                    $skipped++;
4275
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4276
-                                    $skipped++;
4277
-                                } else {
4278
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4279
-                                        $created++;
4280
-                                    } else {
4281
-                                        $invalid++;
4282
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4283
-                                    }
4284
-                                }
4285
-                            } else {
4286
-                                $invalid++;
4287
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4288
-                            }
4258
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4259
+										$updated++;
4260
+									} else {
4261
+										$invalid++;
4262
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4263
+									}
4264
+								} else {
4265
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4266
+										$created++;
4267
+									} else {
4268
+										$invalid++;
4269
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4270
+									}
4271
+								}
4272
+							} else if ( $import_choice == 'skip' ) {
4273
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4274
+									$skipped++;
4275
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4276
+									$skipped++;
4277
+								} else {
4278
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4279
+										$created++;
4280
+									} else {
4281
+										$invalid++;
4282
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4283
+									}
4284
+								}
4285
+							} else {
4286
+								$invalid++;
4287
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4288
+							}
4289 4289
                             
4290
-                            if ( $term_id ) {
4291
-                                // WPML
4292
-                                if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4293
-                                    $wpml_element_type = 'tax_' . $taxonomy;
4294
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4295
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4296
-
4297
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4290
+							if ( $term_id ) {
4291
+								// WPML
4292
+								if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4293
+									$wpml_element_type = 'tax_' . $taxonomy;
4294
+									$source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4295
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4296
+
4297
+									$trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4298 4298
                                     
4299
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4300
-                                }
4301
-                                // WPML
4299
+									$sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4300
+								}
4301
+								// WPML
4302 4302
                                 
4303
-                                if ( isset( $term_data['top_description'] ) ) {
4304
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4305
-                                }
4303
+								if ( isset( $term_data['top_description'] ) ) {
4304
+									update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4305
+								}
4306 4306
                                 
4307
-                                if ( isset( $term_data['cat_schema'] ) ) {
4308
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4309
-                                }
4307
+								if ( isset( $term_data['cat_schema'] ) ) {
4308
+									update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4309
+								}
4310 4310
             
4311
-                                $attachment = false;
4312
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4313
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4314
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4311
+								$attachment = false;
4312
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4313
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4314
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4315 4315
                                     
4316
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4317
-                                        $attachment = true;
4318
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4319
-                                    }
4320
-                                }
4316
+									if ( basename($cat_image) != $term_data['image'] ) {
4317
+										$attachment = true;
4318
+										update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4319
+									}
4320
+								}
4321 4321
                                 
4322
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4323
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4324
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4322
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4323
+									$cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4324
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4325 4325
                                         
4326
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4327
-                                        $attachment = true;
4328
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4329
-                                    }
4330
-                                }
4326
+									if ( basename($cat_icon) != $term_data['icon'] ) {
4327
+										$attachment = true;
4328
+										update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4329
+									}
4330
+								}
4331 4331
                                 
4332
-                                if ( $attachment ) {
4333
-                                    $images++;
4334
-                                }
4335
-                            }
4332
+								if ( $attachment ) {
4333
+									$images++;
4334
+								}
4335
+							}
4336 4336
                             
4337
-                            // WPML
4338
-                            if ($is_wpml && $cat_language != '') {
4339
-                                $sitepress->switch_lang($active_lang, true);
4340
-                            }
4341
-                            // WPML
4342
-                        }
4343
-                    }
4344
-                }
4337
+							// WPML
4338
+							if ($is_wpml && $cat_language != '') {
4339
+								$sitepress->switch_lang($active_lang, true);
4340
+							}
4341
+							// WPML
4342
+						}
4343
+					}
4344
+				}
4345 4345
                 
4346
-                $json = array();
4347
-                $json['processed'] = $limit;
4348
-                $json['created'] = $created;
4349
-                $json['updated'] = $updated;
4350
-                $json['skipped'] = $skipped;
4351
-                $json['invalid'] = $invalid;
4352
-                $json['images'] = $images;
4346
+				$json = array();
4347
+				$json['processed'] = $limit;
4348
+				$json['created'] = $created;
4349
+				$json['updated'] = $updated;
4350
+				$json['skipped'] = $skipped;
4351
+				$json['invalid'] = $invalid;
4352
+				$json['images'] = $images;
4353 4353
                 
4354
-                wp_send_json( $json );
4355
-                exit;
4356
-            } else if ( $task == 'import_post' ) {
4357
-                //run some stuff to make the import quicker
4358
-                wp_defer_term_counting( true );
4359
-                wp_defer_comment_counting( true );
4360
-                $wpdb->query( 'SET autocommit = 0;' );
4361
-
4362
-                //remove_all_actions('publish_post');
4363
-                //remove_all_actions('transition_post_status');
4364
-                //remove_all_actions('publish_future_post');
4365
-
4366
-                if (!empty($file)) {
4367
-                    $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4368
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4369
-                    $default_status = 'publish';
4370
-                    $current_date = date_i18n( 'Y-m-d', time() );
4354
+				wp_send_json( $json );
4355
+				exit;
4356
+			} else if ( $task == 'import_post' ) {
4357
+				//run some stuff to make the import quicker
4358
+				wp_defer_term_counting( true );
4359
+				wp_defer_comment_counting( true );
4360
+				$wpdb->query( 'SET autocommit = 0;' );
4361
+
4362
+				//remove_all_actions('publish_post');
4363
+				//remove_all_actions('transition_post_status');
4364
+				//remove_all_actions('publish_future_post');
4365
+
4366
+				if (!empty($file)) {
4367
+					$is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4368
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4369
+					$default_status = 'publish';
4370
+					$current_date = date_i18n( 'Y-m-d', time() );
4371 4371
                     
4372
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4372
+					$columns = isset($file[0]) ? $file[0] : NULL;
4373 4373
                     
4374
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4375
-                        $json['error'] = CSV_INVAILD_FILE;
4376
-                        wp_send_json( $json );
4377
-                        exit;
4378
-                    }
4374
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4375
+						$json['error'] = CSV_INVAILD_FILE;
4376
+						wp_send_json( $json );
4377
+						exit;
4378
+					}
4379 4379
 
4380
-                    $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4381
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4382
-                    $processed_actual = 0;
4383
-                    for ($i = 1; $i <= $limit; $i++) {
4384
-                        $index = $processed + $i;
4385
-                        $gd_post = array();
4380
+					$gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4381
+					$wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4382
+					$processed_actual = 0;
4383
+					for ($i = 1; $i <= $limit; $i++) {
4384
+						$index = $processed + $i;
4385
+						$gd_post = array();
4386 4386
                         
4387
-                        if (isset($file[$index])) {
4388
-                            $processed_actual++;
4389
-                            $row = $file[$index];
4390
-                            $row = array_map( 'trim', $row );
4391
-                            //$row = array_map( 'utf8_encode', $row );
4392
-                            $row = array_map( 'addslashes_gpc', $row );
4387
+						if (isset($file[$index])) {
4388
+							$processed_actual++;
4389
+							$row = $file[$index];
4390
+							$row = array_map( 'trim', $row );
4391
+							//$row = array_map( 'utf8_encode', $row );
4392
+							$row = array_map( 'addslashes_gpc', $row );
4393 4393
                             
4394
-                            $post_id = '';
4395
-                            $post_title = '';
4396
-                            $post_author = '';
4397
-                            $post_content = '';
4398
-                            $post_category_arr = array();
4399
-                            $default_category = '';
4400
-                            $post_tags = array();
4401
-                            $post_type = '';
4402
-                            $post_status = '';
4403
-                            $geodir_video = '';
4404
-                            $post_address = '';
4405
-                            $post_city = '';
4406
-                            $post_region = '';
4407
-                            $post_country = '';
4408
-                            $post_zip = '';
4409
-                            $post_latitude = '';
4410
-                            $post_longitude = '';
4411
-                            $post_neighbourhood = '';
4412
-                            $neighbourhood_latitude = '';
4413
-                            $neighbourhood_longitude = '';
4414
-                            $geodir_timing = '';
4415
-                            $geodir_contact = '';
4416
-                            $geodir_email = '';
4417
-                            $geodir_website = '';
4418
-                            $geodir_twitter = '';
4419
-                            $geodir_facebook = '';
4420
-                            $geodir_twitter = '';
4421
-                            $post_images = array();
4394
+							$post_id = '';
4395
+							$post_title = '';
4396
+							$post_author = '';
4397
+							$post_content = '';
4398
+							$post_category_arr = array();
4399
+							$default_category = '';
4400
+							$post_tags = array();
4401
+							$post_type = '';
4402
+							$post_status = '';
4403
+							$geodir_video = '';
4404
+							$post_address = '';
4405
+							$post_city = '';
4406
+							$post_region = '';
4407
+							$post_country = '';
4408
+							$post_zip = '';
4409
+							$post_latitude = '';
4410
+							$post_longitude = '';
4411
+							$post_neighbourhood = '';
4412
+							$neighbourhood_latitude = '';
4413
+							$neighbourhood_longitude = '';
4414
+							$geodir_timing = '';
4415
+							$geodir_contact = '';
4416
+							$geodir_email = '';
4417
+							$geodir_website = '';
4418
+							$geodir_twitter = '';
4419
+							$geodir_facebook = '';
4420
+							$geodir_twitter = '';
4421
+							$post_images = array();
4422 4422
                             
4423
-                            $expire_date = 'Never';
4423
+							$expire_date = 'Never';
4424 4424
                             
4425
-                            $language = '';
4426
-                            $original_post_id = '';
4425
+							$language = '';
4426
+							$original_post_id = '';
4427 4427
                             
4428
-                            $c = 0;
4429
-                            foreach ($columns as $column ) {
4430
-                                $gd_post[$column] = $row[$c];
4428
+							$c = 0;
4429
+							foreach ($columns as $column ) {
4430
+								$gd_post[$column] = $row[$c];
4431 4431
                                 
4432
-                                if ( $column == 'post_id' ) {
4433
-                                    $post_id = $row[$c];
4434
-                                } else if ( $column == 'post_title' ) {
4435
-                                    $post_title = sanitize_text_field($row[$c]);
4436
-                                } else if ( $column == 'post_author' ) {
4437
-                                    $post_author = $row[$c];
4438
-                                } else if ( $column == 'post_content' ) {
4439
-                                    $post_content = $row[$c];
4440
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4441
-                                    $post_category_arr = explode( ',', $row[$c] );
4442
-                                } else if ( $column == 'default_category' ) {
4443
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
4444
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4445
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4446
-                                } else if ( $column == 'post_type' ) {
4447
-                                    $post_type = $row[$c];
4448
-                                } else if ( $column == 'post_status' ) {
4449
-                                    $post_status = sanitize_key( $row[$c] );
4450
-                                } else if ( $column == 'is_featured' ) {
4451
-                                    $is_featured = (int)$row[$c];
4452
-                                } else if ( $column == 'geodir_video' ) {
4453
-                                    $geodir_video = $row[$c];
4454
-                                } else if ( $column == 'post_address' ) {
4455
-                                    $post_address = sanitize_text_field($row[$c]);
4456
-                                } else if ( $column == 'post_city' ) {
4457
-                                    $post_city = sanitize_text_field($row[$c]);
4458
-                                } else if ( $column == 'post_region' ) {
4459
-                                    $post_region = sanitize_text_field($row[$c]);
4460
-                                } else if ( $column == 'post_country' ) {
4461
-                                    $post_country = sanitize_text_field($row[$c]);
4462
-                                } else if ( $column == 'post_zip' ) {
4463
-                                    $post_zip = sanitize_text_field($row[$c]);
4464
-                                } else if ( $column == 'post_latitude' ) {
4465
-                                    $post_latitude = sanitize_text_field($row[$c]);
4466
-                                } else if ( $column == 'post_longitude' ) {
4467
-                                    $post_longitude = sanitize_text_field($row[$c]);
4468
-                                } else if ( $column == 'post_neighbourhood' ) {
4469
-                                    $post_neighbourhood = sanitize_text_field($row[$c]);
4470
-                                    unset($gd_post[$column]);
4471
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4472
-                                    $neighbourhood_latitude = sanitize_text_field($row[$c]);
4473
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4474
-                                    $neighbourhood_longitude = sanitize_text_field($row[$c]);
4475
-                                } else if ( $column == 'geodir_timing' ) {
4476
-                                    $geodir_timing = sanitize_text_field($row[$c]);
4477
-                                } else if ( $column == 'geodir_contact' ) {
4478
-                                    $geodir_contact = sanitize_text_field($row[$c]);
4479
-                                } else if ( $column == 'geodir_email' ) {
4480
-                                    $geodir_email = sanitize_email($row[$c]);
4481
-                                } else if ( $column == 'geodir_website' ) {
4482
-                                    $geodir_website = sanitize_text_field($row[$c]);
4483
-                                } else if ( $column == 'geodir_twitter' ) {
4484
-                                    $geodir_twitter = sanitize_text_field($row[$c]);
4485
-                                } else if ( $column == 'geodir_facebook' ) {
4486
-                                    $geodir_facebook = sanitize_text_field($row[$c]);
4487
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4488
-                                    $post_images[] = $row[$c];
4489
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4490
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4491
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4492
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
4493
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4494
-                                }
4495
-                                // WPML
4496
-                                if ($is_wpml) {
4497
-                                    if ($column == 'language') {
4498
-                                        $language = geodir_strtolower(trim($row[$c]));
4499
-                                    } else if ($column == 'original_post_id') {
4500
-                                        $original_post_id = (int)$row[$c];
4501
-                                    }
4502
-                                }
4503
-                                // WPML
4504
-                                $c++;
4505
-                            }
4506
-                            // listing claimed or not
4507
-                            if ($is_claim_active && isset($gd_post['claimed'])) {
4508
-                                $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4509
-                            }
4432
+								if ( $column == 'post_id' ) {
4433
+									$post_id = $row[$c];
4434
+								} else if ( $column == 'post_title' ) {
4435
+									$post_title = sanitize_text_field($row[$c]);
4436
+								} else if ( $column == 'post_author' ) {
4437
+									$post_author = $row[$c];
4438
+								} else if ( $column == 'post_content' ) {
4439
+									$post_content = $row[$c];
4440
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
4441
+									$post_category_arr = explode( ',', $row[$c] );
4442
+								} else if ( $column == 'default_category' ) {
4443
+									$default_category = wp_kses_normalize_entities($row[$c]);
4444
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
4445
+									$post_tags = explode( ',', sanitize_text_field($row[$c]) );
4446
+								} else if ( $column == 'post_type' ) {
4447
+									$post_type = $row[$c];
4448
+								} else if ( $column == 'post_status' ) {
4449
+									$post_status = sanitize_key( $row[$c] );
4450
+								} else if ( $column == 'is_featured' ) {
4451
+									$is_featured = (int)$row[$c];
4452
+								} else if ( $column == 'geodir_video' ) {
4453
+									$geodir_video = $row[$c];
4454
+								} else if ( $column == 'post_address' ) {
4455
+									$post_address = sanitize_text_field($row[$c]);
4456
+								} else if ( $column == 'post_city' ) {
4457
+									$post_city = sanitize_text_field($row[$c]);
4458
+								} else if ( $column == 'post_region' ) {
4459
+									$post_region = sanitize_text_field($row[$c]);
4460
+								} else if ( $column == 'post_country' ) {
4461
+									$post_country = sanitize_text_field($row[$c]);
4462
+								} else if ( $column == 'post_zip' ) {
4463
+									$post_zip = sanitize_text_field($row[$c]);
4464
+								} else if ( $column == 'post_latitude' ) {
4465
+									$post_latitude = sanitize_text_field($row[$c]);
4466
+								} else if ( $column == 'post_longitude' ) {
4467
+									$post_longitude = sanitize_text_field($row[$c]);
4468
+								} else if ( $column == 'post_neighbourhood' ) {
4469
+									$post_neighbourhood = sanitize_text_field($row[$c]);
4470
+									unset($gd_post[$column]);
4471
+								} else if ( $column == 'neighbourhood_latitude' ) {
4472
+									$neighbourhood_latitude = sanitize_text_field($row[$c]);
4473
+								} else if ( $column == 'neighbourhood_longitude' ) {
4474
+									$neighbourhood_longitude = sanitize_text_field($row[$c]);
4475
+								} else if ( $column == 'geodir_timing' ) {
4476
+									$geodir_timing = sanitize_text_field($row[$c]);
4477
+								} else if ( $column == 'geodir_contact' ) {
4478
+									$geodir_contact = sanitize_text_field($row[$c]);
4479
+								} else if ( $column == 'geodir_email' ) {
4480
+									$geodir_email = sanitize_email($row[$c]);
4481
+								} else if ( $column == 'geodir_website' ) {
4482
+									$geodir_website = sanitize_text_field($row[$c]);
4483
+								} else if ( $column == 'geodir_twitter' ) {
4484
+									$geodir_twitter = sanitize_text_field($row[$c]);
4485
+								} else if ( $column == 'geodir_facebook' ) {
4486
+									$geodir_facebook = sanitize_text_field($row[$c]);
4487
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4488
+									$post_images[] = $row[$c];
4489
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4490
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4491
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4492
+									$row[$c] = str_replace('/', '-', $row[$c]);
4493
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4494
+								}
4495
+								// WPML
4496
+								if ($is_wpml) {
4497
+									if ($column == 'language') {
4498
+										$language = geodir_strtolower(trim($row[$c]));
4499
+									} else if ($column == 'original_post_id') {
4500
+										$original_post_id = (int)$row[$c];
4501
+									}
4502
+								}
4503
+								// WPML
4504
+								$c++;
4505
+							}
4506
+							// listing claimed or not
4507
+							if ($is_claim_active && isset($gd_post['claimed'])) {
4508
+								$gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4509
+							}
4510 4510
                             
4511
-                            // WPML
4512
-                            if ($is_wpml && $language != '') {
4513
-                                $sitepress->switch_lang($language, true);
4514
-                            }
4515
-                            // WPML
4511
+							// WPML
4512
+							if ($is_wpml && $language != '') {
4513
+								$sitepress->switch_lang($language, true);
4514
+							}
4515
+							// WPML
4516 4516
 
4517
-                            $gd_post['IMAGE'] = $post_images;
4517
+							$gd_post['IMAGE'] = $post_images;
4518 4518
                             
4519
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4520
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4519
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4520
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4521 4521
                                                                                                                 
4522
-                            $valid = true;
4522
+							$valid = true;
4523 4523
                             
4524
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4525
-                                $invalid++;
4526
-                                $valid = false;
4527
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4528
-                            }
4524
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4525
+								$invalid++;
4526
+								$valid = false;
4527
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4528
+							}
4529 4529
                             
4530
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4531
-                            if ( $location_allowed ) {
4532
-                                $location_result = geodir_get_default_location();
4533
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4534
-                                    $invalid_addr++;
4535
-                                    $valid = false;
4536
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4537
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4538
-                                    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 ) ) ) {
4539
-                                        $invalid_addr++;
4540
-                                        $valid = false;
4541
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4542
-                                    } else {
4543
-                                        if (!$location_manager) {
4544
-                                            $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.
4545
-                                        }
4546
-                                    }
4547
-                                }
4548
-                            }
4530
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4531
+							if ( $location_allowed ) {
4532
+								$location_result = geodir_get_default_location();
4533
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4534
+									$invalid_addr++;
4535
+									$valid = false;
4536
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4537
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4538
+									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 ) ) ) {
4539
+										$invalid_addr++;
4540
+										$valid = false;
4541
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4542
+									} else {
4543
+										if (!$location_manager) {
4544
+											$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.
4545
+										}
4546
+									}
4547
+								}
4548
+							}
4549 4549
                             
4550
-                            if ( !$valid ) {
4551
-                                continue;
4552
-                            }
4550
+							if ( !$valid ) {
4551
+								continue;
4552
+							}
4553 4553
 
4554
-                            $cat_taxonomy = $post_type . 'category';
4555
-                            $tags_taxonomy = $post_type . '_tags';
4554
+							$cat_taxonomy = $post_type . 'category';
4555
+							$tags_taxonomy = $post_type . '_tags';
4556 4556
                             
4557
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4558
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
4559
-                            }
4557
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4558
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
4559
+							}
4560 4560
 
4561
-                            $post_category = array();
4562
-                            $default_category_id = NULL;
4563
-                            if ( !empty( $post_category_arr ) ) {
4564
-                                foreach ( $post_category_arr as $value ) {
4565
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4561
+							$post_category = array();
4562
+							$default_category_id = NULL;
4563
+							if ( !empty( $post_category_arr ) ) {
4564
+								foreach ( $post_category_arr as $value ) {
4565
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
4566 4566
                                     
4567
-                                    if ( $category_name != '' ) {
4568
-                                        $term_category = array();
4567
+									if ( $category_name != '' ) {
4568
+										$term_category = array();
4569 4569
                                         
4570
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4571
-                                            $term_category = $term;
4572
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4573
-                                            $term_category = $term;
4574
-                                        } else {
4575
-                                            $term_data = array();
4576
-                                            $term_data['name'] = $category_name;
4577
-                                            $term_data['taxonomy'] = $cat_taxonomy;
4570
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4571
+											$term_category = $term;
4572
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4573
+											$term_category = $term;
4574
+										} else {
4575
+											$term_data = array();
4576
+											$term_data['name'] = $category_name;
4577
+											$term_data['taxonomy'] = $cat_taxonomy;
4578 4578
                                             
4579
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4580
-                                            if ( $term_id ) {
4581
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4582
-                                            }
4583
-                                        }
4579
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4580
+											if ( $term_id ) {
4581
+												$term_category = get_term( $term_id, $cat_taxonomy );
4582
+											}
4583
+										}
4584 4584
                                         
4585
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4586
-                                            $post_category[] = intval($term_category->term_id);
4585
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4586
+											$post_category[] = intval($term_category->term_id);
4587 4587
                                             
4588
-                                            if ($category_name == $default_category) {
4589
-                                                $default_category_id = intval($term_category->term_id);
4590
-                                            }
4591
-                                        }
4592
-                                    }
4593
-                                }
4594
-                            }
4588
+											if ($category_name == $default_category) {
4589
+												$default_category_id = intval($term_category->term_id);
4590
+											}
4591
+										}
4592
+									}
4593
+								}
4594
+							}
4595 4595
 
4596
-                            $save_post = array();
4597
-                            $save_post['post_title'] = $post_title;
4598
-                            $save_post['post_content'] = $post_content;
4599
-                            $save_post['post_type'] = $post_type;
4600
-                            $save_post['post_author'] = $post_author;
4601
-                            $save_post['post_status'] = $post_status;
4602
-                            $save_post['post_category'] = $post_category;
4603
-                            $save_post['post_tags'] = $post_tags;
4604
-
4605
-                            $saved_post_id = NULL;
4606
-                            if ( $import_choice == 'update' ) {
4607
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4596
+							$save_post = array();
4597
+							$save_post['post_title'] = $post_title;
4598
+							$save_post['post_content'] = $post_content;
4599
+							$save_post['post_type'] = $post_type;
4600
+							$save_post['post_author'] = $post_author;
4601
+							$save_post['post_status'] = $post_status;
4602
+							$save_post['post_category'] = $post_category;
4603
+							$save_post['post_tags'] = $post_tags;
4604
+
4605
+							$saved_post_id = NULL;
4606
+							if ( $import_choice == 'update' ) {
4607
+								$gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4608 4608
                                 
4609
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4610
-                                    $save_post['ID'] = $post_id;
4609
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4610
+									$save_post['ID'] = $post_id;
4611 4611
                                     
4612
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4613
-                                        if ( is_wp_error( $saved_post_id ) ) {
4614
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4615
-                                            $saved_post_id = 0;
4616
-                                        } else {
4617
-                                            $saved_post_id = $post_id;
4618
-                                            $updated++;
4619
-                                        }
4620
-                                    }
4621
-                                } else {
4622
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4623
-                                        if ( is_wp_error( $saved_post_id ) ) {
4624
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4625
-                                            $saved_post_id = 0;
4626
-                                        } else {
4627
-                                            $created++;
4628
-                                        }
4629
-                                    }
4630
-                                }
4612
+									if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4613
+										if ( is_wp_error( $saved_post_id ) ) {
4614
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4615
+											$saved_post_id = 0;
4616
+										} else {
4617
+											$saved_post_id = $post_id;
4618
+											$updated++;
4619
+										}
4620
+									}
4621
+								} else {
4622
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4623
+										if ( is_wp_error( $saved_post_id ) ) {
4624
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4625
+											$saved_post_id = 0;
4626
+										} else {
4627
+											$created++;
4628
+										}
4629
+									}
4630
+								}
4631 4631
                                 
4632
-                                if ( !$saved_post_id > 0 ) {
4633
-                                    $invalid++;
4634
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4635
-                                }
4636
-                            } else if ( $import_choice == 'skip' ) {
4637
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4638
-                                    $skipped++;	
4639
-                                } else {
4640
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4641
-                                        if ( is_wp_error( $saved_post_id ) ) {
4642
-                                            $invalid++;
4632
+								if ( !$saved_post_id > 0 ) {
4633
+									$invalid++;
4634
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4635
+								}
4636
+							} else if ( $import_choice == 'skip' ) {
4637
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4638
+									$skipped++;	
4639
+								} else {
4640
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4641
+										if ( is_wp_error( $saved_post_id ) ) {
4642
+											$invalid++;
4643 4643
                                             
4644
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4645
-                                            $saved_post_id = 0;
4646
-                                        } else {
4647
-                                            $created++;
4648
-                                        }
4649
-                                    } else {
4650
-                                        $invalid++;
4644
+											geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4645
+											$saved_post_id = 0;
4646
+										} else {
4647
+											$created++;
4648
+										}
4649
+									} else {
4650
+										$invalid++;
4651 4651
                                         
4652
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4653
-                                    }
4654
-                                }
4655
-                            } else {
4656
-                                $invalid++;
4652
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4653
+									}
4654
+								}
4655
+							} else {
4656
+								$invalid++;
4657 4657
                                 
4658
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4659
-                            }
4658
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4659
+							}
4660 4660
 
4661
-                            if ( (int)$saved_post_id > 0 ) {
4662
-                                // WPML
4663
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
4664
-                                    $wpml_post_type = 'post_' . $post_type;
4665
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4666
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4661
+							if ( (int)$saved_post_id > 0 ) {
4662
+								// WPML
4663
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
4664
+									$wpml_post_type = 'post_' . $post_type;
4665
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4666
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4667 4667
 
4668
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4668
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4669 4669
                                     
4670
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4671
-                                }
4672
-                                // WPML
4673
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4670
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4671
+								}
4672
+								// WPML
4673
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
4674 4674
                                 
4675
-                                $gd_post['post_id'] = $saved_post_id;
4676
-                                $gd_post['ID'] = $saved_post_id;
4677
-                                $gd_post['post_tags'] = $post_tags;
4678
-                                $gd_post['post_title'] = $post_title;
4679
-                                $gd_post['post_status'] = $post_status;
4680
-                                $gd_post['submit_time'] = time();
4681
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4675
+								$gd_post['post_id'] = $saved_post_id;
4676
+								$gd_post['ID'] = $saved_post_id;
4677
+								$gd_post['post_tags'] = $post_tags;
4678
+								$gd_post['post_title'] = $post_title;
4679
+								$gd_post['post_status'] = $post_status;
4680
+								$gd_post['submit_time'] = time();
4681
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4682 4682
                                                     
4683
-                                // post location
4684
-                                $post_location_id = 0;
4685
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4686
-                                    $gd_post['post_neighbourhood'] = '';
4683
+								// post location
4684
+								$post_location_id = 0;
4685
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4686
+									$gd_post['post_neighbourhood'] = '';
4687 4687
                                     
4688
-                                    $post_location_info = array(
4689
-                                                                'city' => $post_city,
4690
-                                                                'region' => $post_region,
4691
-                                                                'country' => $post_country,
4692
-                                                                'geo_lat' => $post_latitude,
4693
-                                                                'geo_lng' => $post_longitude
4694
-                                                            );
4695
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4696
-                                        $post_location_id = $location_id;
4697
-                                    }
4688
+									$post_location_info = array(
4689
+																'city' => $post_city,
4690
+																'region' => $post_region,
4691
+																'country' => $post_country,
4692
+																'geo_lat' => $post_latitude,
4693
+																'geo_lng' => $post_longitude
4694
+															);
4695
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4696
+										$post_location_id = $location_id;
4697
+									}
4698 4698
                                     
4699
-                                    if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4700
-                                        $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4699
+									if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4700
+										$neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4701 4701
 
4702
-                                        $hood_data = array();
4703
-                                        $hood_data['hood_location_id'] = $post_location_id;
4704
-                                        $hood_data['hood_name'] = $post_neighbourhood;
4702
+										$hood_data = array();
4703
+										$hood_data['hood_location_id'] = $post_location_id;
4704
+										$hood_data['hood_name'] = $post_neighbourhood;
4705 4705
                                         
4706
-                                        if (!empty($neighbourhood_info)) {
4707
-                                            $hood_data['hood_id'] = $neighbourhood_info->hood_id;
4708
-                                            $hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4706
+										if (!empty($neighbourhood_info)) {
4707
+											$hood_data['hood_id'] = $neighbourhood_info->hood_id;
4708
+											$hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4709 4709
                                             
4710
-                                            if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4711
-                                                $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4712
-                                                $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4713
-                                            }
4714
-                                        }
4710
+											if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4711
+												$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4712
+												$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4713
+											}
4714
+										}
4715 4715
                                         
4716
-                                        if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4717
-                                            $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4718
-                                            $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4719
-                                        }
4716
+										if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4717
+											$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4718
+											$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4719
+										}
4720 4720
                                         
4721
-                                        $hood_data['hood_latitude'] = $post_latitude;
4722
-                                        $hood_data['hood_longitude'] = $post_longitude;
4721
+										$hood_data['hood_latitude'] = $post_latitude;
4722
+										$hood_data['hood_longitude'] = $post_longitude;
4723 4723
 
4724
-                                        $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4725
-                                        if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4726
-                                            $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4727
-                                        }
4728
-                                    }
4729
-                                }
4730
-                                $gd_post['post_location_id'] = $post_location_id;
4724
+										$neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4725
+										if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4726
+											$gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4727
+										}
4728
+									}
4729
+								}
4730
+								$gd_post['post_location_id'] = $post_location_id;
4731 4731
                                 
4732
-                                // post package info
4733
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4734
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4735
-                                    $package_id = $gd_post_info->package_id;
4736
-                                }
4732
+								// post package info
4733
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4734
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4735
+									$package_id = $gd_post_info->package_id;
4736
+								}
4737 4737
                                 
4738
-                                $package_info = array();
4739
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4740
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4738
+								$package_info = array();
4739
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4740
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
4741 4741
                                     
4742
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4743
-                                        $package_info = array();
4744
-                                    }
4745
-                                }
4742
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4743
+										$package_info = array();
4744
+									}
4745
+								}
4746 4746
                                 
4747
-                                if (empty($package_info)) {
4748
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4749
-                                }
4747
+								if (empty($package_info)) {
4748
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
4749
+								}
4750 4750
                                  
4751
-                                if (!empty($package_info))	 {
4752
-                                    $package_id = $package_info['pid'];
4751
+								if (!empty($package_info))	 {
4752
+									$package_id = $package_info['pid'];
4753 4753
                                     
4754
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4755
-                                        $gd_post['expire_date'] = $expire_date;
4756
-                                    } else {
4757
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4758
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4759
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4760
-                                        } else {
4761
-                                            $gd_post['expire_date'] = 'Never';
4762
-                                        }
4763
-                                    }
4754
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4755
+										$gd_post['expire_date'] = $expire_date;
4756
+									} else {
4757
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4758
+											$gd_post['alive_days'] = (int)$package_info['days'];
4759
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4760
+										} else {
4761
+											$gd_post['expire_date'] = 'Never';
4762
+										}
4763
+									}
4764 4764
                                     
4765
-                                    $gd_post['package_id'] = $package_id;
4766
-                                }
4765
+									$gd_post['package_id'] = $package_id;
4766
+								}
4767 4767
 
4768
-                                $table = $plugin_prefix . $post_type . '_detail';
4768
+								$table = $plugin_prefix . $post_type . '_detail';
4769 4769
                                 
4770
-                                if ($post_type == 'gd_event') {
4771
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
4772
-                                }
4770
+								if ($post_type == 'gd_event') {
4771
+									$gd_post = geodir_imex_process_event_data($gd_post);
4772
+								}
4773 4773
                                 
4774
-                                if (isset($gd_post['post_id'])) {
4775
-                                    unset($gd_post['post_id']);
4776
-                                }
4774
+								if (isset($gd_post['post_id'])) {
4775
+									unset($gd_post['post_id']);
4776
+								}
4777 4777
 
4778
-                                // Export franchise fields
4779
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4780
-                                if ($is_franchise_active) {
4781
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4782
-                                        $gd_franchise_lock = array();
4778
+								// Export franchise fields
4779
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4780
+								if ($is_franchise_active) {
4781
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4782
+										$gd_franchise_lock = array();
4783 4783
                                         
4784
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4785
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4786
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4787
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4788
-                                        }
4784
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4785
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4786
+											$gd_franchise_lock = trim( $gd_franchise_lock );
4787
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
4788
+										}
4789 4789
                                         
4790
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4791
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4792
-                                    } else {
4793
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4794
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4795
-                                        }
4796
-                                    }
4797
-                                }
4790
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4791
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4792
+									} else {
4793
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4794
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4795
+										}
4796
+									}
4797
+								}
4798 4798
                                 
4799
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4800
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4801
-                                    if ($default_category_id) {
4802
-                                        $save_post['post_default_category'] = $default_category_id;
4803
-                                        $gd_post['default_category'] = $default_category_id;
4804
-                                    }
4805
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
4806
-                                }
4799
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4800
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4801
+									if ($default_category_id) {
4802
+										$save_post['post_default_category'] = $default_category_id;
4803
+										$gd_post['default_category'] = $default_category_id;
4804
+									}
4805
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
4806
+								}
4807 4807
                                 
4808
-                                // Save post info
4809
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4810
-                                // post taxonomies
4811
-                                if ( !empty( $save_post['post_category'] ) ) {
4812
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4808
+								// Save post info
4809
+								geodir_save_post_info( $saved_post_id, $gd_post );
4810
+								// post taxonomies
4811
+								if ( !empty( $save_post['post_category'] ) ) {
4812
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4813 4813
                                     
4814
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4815
-                                    if ($default_category_id) {
4816
-                                        $post_default_category = $default_category_id;
4817
-                                    }
4818
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4819
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4820
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4814
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4815
+									if ($default_category_id) {
4816
+										$post_default_category = $default_category_id;
4817
+									}
4818
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4819
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4820
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4821 4821
                                     
4822
-                                    if ($post_category_str != '' && $post_default_category) {
4823
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4824
-                                    }
4822
+									if ($post_category_str != '' && $post_default_category) {
4823
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4824
+									}
4825 4825
                                     
4826
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4826
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4827 4827
                                     
4828
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4829
-                                }
4828
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4829
+								}
4830 4830
 
4831
-                                if ( !empty( $save_post['post_tags'] ) ) {
4832
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4833
-                                }
4831
+								if ( !empty( $save_post['post_tags'] ) ) {
4832
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4833
+								}
4834 4834
 
4835
-                                // Post images
4836
-                                if ( !empty( $post_images ) ) {
4837
-                                    $post_images = array_unique($post_images);
4835
+								// Post images
4836
+								if ( !empty( $post_images ) ) {
4837
+									$post_images = array_unique($post_images);
4838 4838
                                     
4839
-                                    $old_post_images_arr = array();
4840
-                                    $saved_post_images_arr = array();
4839
+									$old_post_images_arr = array();
4840
+									$saved_post_images_arr = array();
4841 4841
                                     
4842
-                                    $order = 1;
4842
+									$order = 1;
4843 4843
                                     
4844
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4845
-                                    if (!empty($old_post_images)) {
4846
-                                        foreach( $old_post_images as $old_post_image ) {
4847
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4848
-                                                $old_post_images_arr[] = $old_post_image->file;
4849
-                                            }
4850
-                                        }
4851
-                                    }
4844
+									$old_post_images = geodir_get_images( $saved_post_id );
4845
+									if (!empty($old_post_images)) {
4846
+										foreach( $old_post_images as $old_post_image ) {
4847
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4848
+												$old_post_images_arr[] = $old_post_image->file;
4849
+											}
4850
+										}
4851
+									}
4852 4852
 
4853
-                                    foreach ( $post_images as $post_image ) {
4854
-                                        $image_name = basename( $post_image );
4855
-                                        $saved_post_images_arr[] = $image_name;
4853
+									foreach ( $post_images as $post_image ) {
4854
+										$image_name = basename( $post_image );
4855
+										$saved_post_images_arr[] = $image_name;
4856 4856
                                         
4857
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4858
-                                            continue; // Skip if image already exists.
4859
-                                        }
4857
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4858
+											continue; // Skip if image already exists.
4859
+										}
4860 4860
                                         
4861
-                                        $image_name_parts = explode( '.', $image_name );
4862
-                                        array_pop( $image_name_parts );
4863
-                                        $proper_image_name = implode( '.', $image_name_parts );
4861
+										$image_name_parts = explode( '.', $image_name );
4862
+										array_pop( $image_name_parts );
4863
+										$proper_image_name = implode( '.', $image_name_parts );
4864 4864
                                         
4865
-                                        $arr_file_type = wp_check_filetype( $image_name );
4865
+										$arr_file_type = wp_check_filetype( $image_name );
4866 4866
                                         
4867
-                                        if ( !empty( $arr_file_type ) ) {
4868
-                                            $uploaded_file_type = $arr_file_type['type'];
4867
+										if ( !empty( $arr_file_type ) ) {
4868
+											$uploaded_file_type = $arr_file_type['type'];
4869 4869
                                             
4870
-                                            $attachment = array();
4871
-                                            $attachment['post_id'] = $saved_post_id;
4872
-                                            $attachment['title'] = $proper_image_name;
4873
-                                            $attachment['content'] = '';
4874
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4875
-                                            $attachment['mime_type'] = $uploaded_file_type;
4876
-                                            $attachment['menu_order'] = $order;
4877
-                                            $attachment['is_featured'] = 0;
4878
-
4879
-                                            $attachment_set = '';
4880
-                                            foreach ( $attachment as $key => $val ) {
4881
-                                                if ( $val != '' ) {
4882
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4883
-                                                }
4884
-                                            }
4885
-                                            $attachment_set = trim( $attachment_set, ", " );
4870
+											$attachment = array();
4871
+											$attachment['post_id'] = $saved_post_id;
4872
+											$attachment['title'] = $proper_image_name;
4873
+											$attachment['content'] = '';
4874
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
4875
+											$attachment['mime_type'] = $uploaded_file_type;
4876
+											$attachment['menu_order'] = $order;
4877
+											$attachment['is_featured'] = 0;
4878
+
4879
+											$attachment_set = '';
4880
+											foreach ( $attachment as $key => $val ) {
4881
+												if ( $val != '' ) {
4882
+													$attachment_set .= $key . " = '" . $val . "', ";
4883
+												}
4884
+											}
4885
+											$attachment_set = trim( $attachment_set, ", " );
4886 4886
                                                                                         
4887
-                                            // Add new attachment
4888
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4887
+											// Add new attachment
4888
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4889 4889
                                                                                         
4890
-                                            $order++;
4891
-                                        }
4892
-                                    }
4890
+											$order++;
4891
+										}
4892
+									}
4893 4893
 
4894
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4895
-                                    // Remove previous attachment
4896
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4894
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4895
+									// Remove previous attachment
4896
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4897 4897
                                     
4898
-                                    if ( !empty( $saved_post_images_arr ) ) {
4899
-                                        geodir_set_wp_featured_image($saved_post_id);
4900
-                                        /*
4898
+									if ( !empty( $saved_post_images_arr ) ) {
4899
+										geodir_set_wp_featured_image($saved_post_id);
4900
+										/*
4901 4901
                                         $menu_order = 1;
4902 4902
                                         
4903 4903
                                         foreach ( $saved_post_images_arr as $img_name ) {
@@ -4910,281 +4910,281 @@  discard block
 block discarded – undo
4910 4910
                                             }
4911 4911
                                             $menu_order++;
4912 4912
                                         }*/
4913
-                                    }
4913
+									}
4914 4914
                                     
4915
-                                    if ( $order > 1 ) {
4916
-                                        $images++;
4917
-                                    }
4918
-                                }
4915
+									if ( $order > 1 ) {
4916
+										$images++;
4917
+									}
4918
+								}
4919 4919
 
4920
-                                /** This action is documented in geodirectory-functions/post-functions.php */
4921
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4920
+								/** This action is documented in geodirectory-functions/post-functions.php */
4921
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4922 4922
                                 
4923
-                                if (isset($is_featured)) {
4924
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4925
-                                }
4926
-                                if (isset($gd_post['expire_date'])) {
4927
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4928
-                                }
4929
-                            }
4923
+								if (isset($is_featured)) {
4924
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4925
+								}
4926
+								if (isset($gd_post['expire_date'])) {
4927
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4928
+								}
4929
+							}
4930 4930
                             
4931
-                            // WPML
4932
-                            if ($is_wpml && $language != '') {
4933
-                                $sitepress->switch_lang($active_lang, true);
4934
-                            }
4935
-                            // WPML
4936
-                        }
4937
-                    }
4938
-                }
4931
+							// WPML
4932
+							if ($is_wpml && $language != '') {
4933
+								$sitepress->switch_lang($active_lang, true);
4934
+							}
4935
+							// WPML
4936
+						}
4937
+					}
4938
+				}
4939 4939
 
4940
-                //undo some stuff to make the import quicker
4941
-                wp_defer_term_counting( false );
4942
-                wp_defer_comment_counting( false );
4943
-                $wpdb->query( 'COMMIT;' );
4944
-                $wpdb->query( 'SET autocommit = 1;' );
4945
-
4946
-                $json = array();
4947
-                $json['processed'] = $processed_actual;
4948
-                $json['created'] = $created;
4949
-                $json['updated'] = $updated;
4950
-                $json['skipped'] = $skipped;
4951
-                $json['invalid'] = $invalid;
4952
-                $json['invalid_addr'] = $invalid_addr;
4953
-                $json['images'] = $images;
4940
+				//undo some stuff to make the import quicker
4941
+				wp_defer_term_counting( false );
4942
+				wp_defer_comment_counting( false );
4943
+				$wpdb->query( 'COMMIT;' );
4944
+				$wpdb->query( 'SET autocommit = 1;' );
4945
+
4946
+				$json = array();
4947
+				$json['processed'] = $processed_actual;
4948
+				$json['created'] = $created;
4949
+				$json['updated'] = $updated;
4950
+				$json['skipped'] = $skipped;
4951
+				$json['invalid'] = $invalid;
4952
+				$json['invalid_addr'] = $invalid_addr;
4953
+				$json['images'] = $images;
4954 4954
                 
4955
-                wp_send_json( $json );
4956
-                exit;
4957
-            } else if ( $task == 'import_loc' ) {
4958
-                global $gd_post_types;
4959
-                $gd_post_types = $post_types;
4955
+				wp_send_json( $json );
4956
+				exit;
4957
+			} else if ( $task == 'import_loc' ) {
4958
+				global $gd_post_types;
4959
+				$gd_post_types = $post_types;
4960 4960
                 
4961
-                if (!empty($file)) {
4962
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4961
+				if (!empty($file)) {
4962
+					$columns = isset($file[0]) ? $file[0] : NULL;
4963 4963
                     
4964
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4965
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4966
-                        wp_send_json( $json );
4967
-                    }
4964
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4965
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4966
+						wp_send_json( $json );
4967
+					}
4968 4968
                     
4969
-                    $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4970
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4971
-                    for ($i = 1; $i <= $limit; $i++) {
4972
-                        $index = $processed + $i;
4969
+					$gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4970
+					$gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4971
+					for ($i = 1; $i <= $limit; $i++) {
4972
+						$index = $processed + $i;
4973 4973
                         
4974
-                        if (isset($file[$index])) {
4975
-                            $row = $file[$index];
4976
-                            $row = array_map( 'trim', $row );
4977
-                            $data = array();
4974
+						if (isset($file[$index])) {
4975
+							$row = $file[$index];
4976
+							$row = array_map( 'trim', $row );
4977
+							$data = array();
4978 4978
                             
4979
-                            foreach ($columns as $c => $column ) {
4980
-                                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'))) {
4981
-                                    $data[$column] = $row[$c];
4982
-                                }
4983
-                            }
4979
+							foreach ($columns as $c => $column ) {
4980
+								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'))) {
4981
+									$data[$column] = $row[$c];
4982
+								}
4983
+							}
4984 4984
 
4985
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4986
-                                $invalid++;
4987
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4988
-                                continue;
4989
-                            }
4985
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4986
+								$invalid++;
4987
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4988
+								continue;
4989
+							}
4990 4990
                             
4991
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4991
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4992 4992
                             
4993
-                            if ( $import_choice == 'update' ) {
4994
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4995
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4996
-                                        $updated++;
4997
-                                    } else {
4998
-                                        $invalid++;
4999
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5000
-                                    }
5001
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5002
-                                    $data['location_id'] = (int)$location->location_id;
4993
+							if ( $import_choice == 'update' ) {
4994
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4995
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4996
+										$updated++;
4997
+									} else {
4998
+										$invalid++;
4999
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5000
+									}
5001
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5002
+									$data['location_id'] = (int)$location->location_id;
5003 5003
                                     
5004
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
5005
-                                        $data['location_id'] = (int)$location->location_id;
5006
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
5007
-                                        $data['location_id'] = (int)$location->location_id;
5008
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
5009
-                                        $data['location_id'] = (int)$location->location_id;
5010
-                                    }
5004
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
5005
+										$data['location_id'] = (int)$location->location_id;
5006
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
5007
+										$data['location_id'] = (int)$location->location_id;
5008
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
5009
+										$data['location_id'] = (int)$location->location_id;
5010
+									}
5011 5011
                                     
5012
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5013
-                                        $updated++;
5014
-                                    } else {
5015
-                                        $invalid++;
5016
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5017
-                                    }
5018
-                                } else {
5019
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5020
-                                        $created++;
5021
-                                    } else {
5022
-                                        $invalid++;
5023
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5024
-                                    }
5025
-                                }
5026
-                            } elseif ( $import_choice == 'skip' ) {
5027
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5028
-                                    $skipped++;
5029
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5030
-                                    $skipped++;
5031
-                                } else {
5032
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5033
-                                        $created++;
5034
-                                    } else {
5035
-                                        $invalid++;
5036
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5037
-                                    }
5038
-                                }
5039
-                            } else {
5040
-                                $invalid++;
5041
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5042
-                            }
5043
-                        }
5044
-                    }
5045
-                }
5012
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5013
+										$updated++;
5014
+									} else {
5015
+										$invalid++;
5016
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5017
+									}
5018
+								} else {
5019
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5020
+										$created++;
5021
+									} else {
5022
+										$invalid++;
5023
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5024
+									}
5025
+								}
5026
+							} elseif ( $import_choice == 'skip' ) {
5027
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5028
+									$skipped++;
5029
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5030
+									$skipped++;
5031
+								} else {
5032
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5033
+										$created++;
5034
+									} else {
5035
+										$invalid++;
5036
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5037
+									}
5038
+								}
5039
+							} else {
5040
+								$invalid++;
5041
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5042
+							}
5043
+						}
5044
+					}
5045
+				}
5046 5046
                 
5047
-                $json = array();
5048
-                $json['processed'] = $limit;
5049
-                $json['created'] = $created;
5050
-                $json['updated'] = $updated;
5051
-                $json['skipped'] = $skipped;
5052
-                $json['invalid'] = $invalid;
5053
-                $json['images'] = $images;
5047
+				$json = array();
5048
+				$json['processed'] = $limit;
5049
+				$json['created'] = $created;
5050
+				$json['updated'] = $updated;
5051
+				$json['skipped'] = $skipped;
5052
+				$json['invalid'] = $invalid;
5053
+				$json['images'] = $images;
5054 5054
                 
5055
-                wp_send_json( $json );
5056
-            } else if ( $task == 'import_hood' ) {               
5057
-                if (!empty($file)) {
5058
-                    $columns = isset($file[0]) ? $file[0] : NULL;
5055
+				wp_send_json( $json );
5056
+			} else if ( $task == 'import_hood' ) {               
5057
+				if (!empty($file)) {
5058
+					$columns = isset($file[0]) ? $file[0] : NULL;
5059 5059
                     
5060
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5061
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
5062
-                        wp_send_json( $json );
5063
-                    }
5060
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5061
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
5062
+						wp_send_json( $json );
5063
+					}
5064 5064
                     
5065
-                    $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
5066
-                    $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
5067
-                    for ($i = 1; $i <= $limit; $i++) {
5068
-                        $index = $processed + $i;
5065
+					$gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
5066
+					$gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
5067
+					for ($i = 1; $i <= $limit; $i++) {
5068
+						$index = $processed + $i;
5069 5069
                         
5070
-                        if (isset($file[$index])) {
5071
-                            $row = $file[$index];
5072
-                            $row = array_map( 'trim', $row );
5073
-                            $data = array();
5070
+						if (isset($file[$index])) {
5071
+							$row = $file[$index];
5072
+							$row = array_map( 'trim', $row );
5073
+							$data = array();
5074 5074
                             
5075
-                            foreach ($columns as $c => $column) {
5076
-                                if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5077
-                                    $data[$column] = sanitize_text_field($row[$c]);
5078
-                                }
5079
-                            }
5075
+							foreach ($columns as $c => $column) {
5076
+								if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5077
+									$data[$column] = sanitize_text_field($row[$c]);
5078
+								}
5079
+							}
5080 5080
 
5081
-                            if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5082
-                                $invalid++;
5083
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5084
-                                continue;
5085
-                            }
5081
+							if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5082
+								$invalid++;
5083
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5084
+								continue;
5085
+							}
5086 5086
                             
5087
-                            $location_info = array();
5088
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5089
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5090
-                            } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5091
-                                $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5092
-                            }
5087
+							$location_info = array();
5088
+							if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5089
+								$location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5090
+							} else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5091
+								$location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5092
+							}
5093 5093
 
5094
-                            if (empty($location_info)) {
5095
-                                $invalid++;
5096
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5097
-                                continue;
5098
-                            }
5094
+							if (empty($location_info)) {
5095
+								$invalid++;
5096
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5097
+								continue;
5098
+							}
5099 5099
                             
5100
-                            $location_id = $location_info->location_id;
5100
+							$location_id = $location_info->location_id;
5101 5101
 
5102
-                            $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5102
+							$data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5103 5103
                             
5104
-                            $hood_data = array();
5105
-                            $hood_data['hood_name'] = $data['neighbourhood_name'];
5106
-                            $hood_data['hood_slug'] = $data['neighbourhood_slug'];
5107
-                            $hood_data['hood_latitude'] = $data['latitude'];
5108
-                            $hood_data['hood_longitude'] = $data['longitude'];
5109
-                            $hood_data['hood_location_id'] = $location_id;
5104
+							$hood_data = array();
5105
+							$hood_data['hood_name'] = $data['neighbourhood_name'];
5106
+							$hood_data['hood_slug'] = $data['neighbourhood_slug'];
5107
+							$hood_data['hood_latitude'] = $data['latitude'];
5108
+							$hood_data['hood_longitude'] = $data['longitude'];
5109
+							$hood_data['hood_location_id'] = $location_id;
5110 5110
                                     
5111
-                            if ( $import_choice == 'update' ) {
5112
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5113
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5111
+							if ( $import_choice == 'update' ) {
5112
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5113
+									$hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5114 5114
                                     
5115
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5116
-                                        $updated++;
5117
-                                    } else {
5118
-                                        $invalid++;
5119
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5120
-                                    }
5121
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5122
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5115
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5116
+										$updated++;
5117
+									} else {
5118
+										$invalid++;
5119
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5120
+									}
5121
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5122
+									$hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5123 5123
                                     
5124
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5125
-                                        $updated++;
5126
-                                    } else {
5127
-                                        $invalid++;
5128
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5129
-                                    }
5130
-                                } else {
5131
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5132
-                                        $created++;
5133
-                                    } else {
5134
-                                        $invalid++;
5135
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5136
-                                    }
5137
-                                }
5138
-                            } elseif ( $import_choice == 'skip' ) {
5139
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5140
-                                    $skipped++;
5141
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5142
-                                    $skipped++;
5143
-                                } else {
5124
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5125
+										$updated++;
5126
+									} else {
5127
+										$invalid++;
5128
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5129
+									}
5130
+								} else {
5131
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5132
+										$created++;
5133
+									} else {
5134
+										$invalid++;
5135
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5136
+									}
5137
+								}
5138
+							} elseif ( $import_choice == 'skip' ) {
5139
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5140
+									$skipped++;
5141
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5142
+									$skipped++;
5143
+								} else {
5144 5144
                                     
5145
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5146
-                                        $created++;
5147
-                                    } else {
5148
-                                        $invalid++;
5149
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5150
-                                    }
5151
-                                }
5152
-                            } else {
5153
-                                $invalid++;
5154
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5155
-                            }
5156
-                        }
5157
-                    }
5158
-                }
5145
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5146
+										$created++;
5147
+									} else {
5148
+										$invalid++;
5149
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5150
+									}
5151
+								}
5152
+							} else {
5153
+								$invalid++;
5154
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5155
+							}
5156
+						}
5157
+					}
5158
+				}
5159 5159
                 
5160
-                $json = array();
5161
-                $json['processed'] = $limit;
5162
-                $json['created'] = $created;
5163
-                $json['updated'] = $updated;
5164
-                $json['skipped'] = $skipped;
5165
-                $json['invalid'] = $invalid;
5166
-                $json['images'] = $images;
5160
+				$json = array();
5161
+				$json['processed'] = $limit;
5162
+				$json['created'] = $created;
5163
+				$json['updated'] = $updated;
5164
+				$json['skipped'] = $skipped;
5165
+				$json['invalid'] = $invalid;
5166
+				$json['images'] = $images;
5167 5167
                 
5168
-                wp_send_json( $json );
5169
-            }
5170
-        }
5171
-        break;
5172
-        case 'import_finish':{
5173
-            /**
5174
-             * Run an action when an import finishes.
5175
-             *
5176
-             * This action can be used to fire functions after an import ends.
5177
-             *
5178
-             * @since 1.5.3
5179
-             * @package GeoDirectory
5180
-             */
5181
-            do_action('geodir_import_finished');
5182
-        }
5183
-        break;
5168
+				wp_send_json( $json );
5169
+			}
5170
+		}
5171
+		break;
5172
+		case 'import_finish':{
5173
+			/**
5174
+			 * Run an action when an import finishes.
5175
+			 *
5176
+			 * This action can be used to fire functions after an import ends.
5177
+			 *
5178
+			 * @since 1.5.3
5179
+			 * @package GeoDirectory
5180
+			 */
5181
+			do_action('geodir_import_finished');
5182
+		}
5183
+		break;
5184 5184
 
5185
-    }
5186
-    echo '0';
5187
-    gd_die();
5185
+	}
5186
+	echo '0';
5187
+	gd_die();
5188 5188
 }
5189 5189
 
5190 5190
 /**
@@ -5228,12 +5228,12 @@  discard block
 block discarded – undo
5228 5228
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5229 5229
 	}
5230 5230
 	
5231
-    if( !empty( $term ) ) {
5231
+	if( !empty( $term ) ) {
5232 5232
 		$result = wp_insert_term( $term, $taxonomy, $args );
5233
-        if( !is_wp_error( $result ) ) {
5234
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5235
-        }
5236
-    }
5233
+		if( !is_wp_error( $result ) ) {
5234
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5235
+		}
5236
+	}
5237 5237
 	
5238 5238
 	return false;
5239 5239
 }
@@ -5279,16 +5279,16 @@  discard block
 block discarded – undo
5279 5279
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5280 5280
 		
5281 5281
 		if( !is_wp_error( $result ) ) {
5282
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5283
-        }
5282
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5283
+		}
5284 5284
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5285 5285
 		$term_data['term_id'] = $term_info['term_id'];
5286 5286
 		
5287 5287
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5288 5288
 		
5289 5289
 		if( !is_wp_error( $result ) ) {
5290
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5291
-        }
5290
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5291
+		}
5292 5292
 	} else {
5293 5293
 		return geodir_imex_insert_term( $taxonomy, $term_data );
5294 5294
 	}
@@ -5310,47 +5310,47 @@  discard block
 block discarded – undo
5310 5310
  * @return int Posts count.
5311 5311
  */
5312 5312
 function geodir_get_posts_count( $post_type ) {
5313
-    global $wpdb, $plugin_prefix;
5313
+	global $wpdb, $plugin_prefix;
5314 5314
 
5315
-    if ( !post_type_exists( $post_type ) ) {
5316
-        return 0;
5317
-    }
5315
+	if ( !post_type_exists( $post_type ) ) {
5316
+		return 0;
5317
+	}
5318 5318
         
5319
-    $table = $plugin_prefix . $post_type . '_detail';
5319
+	$table = $plugin_prefix . $post_type . '_detail';
5320 5320
 
5321
-    // Skip listing with statuses trash, auto-draft etc...
5322
-    $skip_statuses = geodir_imex_export_skip_statuses();
5323
-    $where_statuses = '';
5324
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5325
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5326
-    }
5321
+	// Skip listing with statuses trash, auto-draft etc...
5322
+	$skip_statuses = geodir_imex_export_skip_statuses();
5323
+	$where_statuses = '';
5324
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5325
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5326
+	}
5327 5327
     
5328
-    /**
5329
-     * Filter the SQL where clause part to filter posts count in import/export.
5330
-     *
5331
-     * @since 1.6.4
5332
-     * @package GeoDirectory
5333
-     *
5334
-     * @param string $where SQL where clause part.
5335
-     */
5336
-    $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5337
-
5338
-    $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5339
-
5340
-    $posts_count = (int)$wpdb->get_var( $query );
5328
+	/**
5329
+	 * Filter the SQL where clause part to filter posts count in import/export.
5330
+	 *
5331
+	 * @since 1.6.4
5332
+	 * @package GeoDirectory
5333
+	 *
5334
+	 * @param string $where SQL where clause part.
5335
+	 */
5336
+	$where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5337
+
5338
+	$query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5339
+
5340
+	$posts_count = (int)$wpdb->get_var( $query );
5341 5341
     
5342
-    /**
5343
-     * Modify returned post counts for the current post type.
5344
-     *
5345
-     * @since 1.4.6
5346
-     * @package GeoDirectory
5347
-     *
5348
-     * @param int $posts_count Post counts.
5349
-     * @param string $post_type Post type.
5350
-     */
5351
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5352
-
5353
-    return $posts_count;
5342
+	/**
5343
+	 * Modify returned post counts for the current post type.
5344
+	 *
5345
+	 * @since 1.4.6
5346
+	 * @package GeoDirectory
5347
+	 *
5348
+	 * @param int $posts_count Post counts.
5349
+	 * @param string $post_type Post type.
5350
+	 */
5351
+	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5352
+
5353
+	return $posts_count;
5354 5354
 }
5355 5355
 
5356 5356
 /**
@@ -5378,10 +5378,10 @@  discard block
 block discarded – undo
5378 5378
 	
5379 5379
 	if ( !empty( $posts ) ) {
5380 5380
 		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5381
-        $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5382
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5383
-        $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5384
-        $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
5381
+		$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5382
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5383
+		$neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5384
+		$is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
5385 5385
 		
5386 5386
 		$csv_row = array();
5387 5387
 		$csv_row[] = 'post_id';
@@ -5413,7 +5413,7 @@  discard block
 block discarded – undo
5413 5413
 		}
5414 5414
 		$csv_row[] = 'post_status';
5415 5415
 		$csv_row[] = 'is_featured';
5416
-        // Export claim listing field
5416
+		// Export claim listing field
5417 5417
 		if ($is_claim_active) {
5418 5418
 			$csv_row[] = 'claimed';
5419 5419
 		}
@@ -5421,7 +5421,7 @@  discard block
 block discarded – undo
5421 5421
 			$csv_row[] = 'package_id';
5422 5422
 			$csv_row[] = 'expire_date';
5423 5423
 		}
5424
-        $csv_row[] = 'post_date';
5424
+		$csv_row[] = 'post_date';
5425 5425
 		$csv_row[] = 'geodir_video';
5426 5426
 		$csv_row[] = 'post_address';
5427 5427
 		$csv_row[] = 'post_city';
@@ -5430,11 +5430,11 @@  discard block
 block discarded – undo
5430 5430
 		$csv_row[] = 'post_zip';
5431 5431
 		$csv_row[] = 'post_latitude';
5432 5432
 		$csv_row[] = 'post_longitude';
5433
-        if ($neighbourhood_active) {
5434
-            $csv_row[] = 'post_neighbourhood';
5435
-            $csv_row[] = 'neighbourhood_latitude';
5436
-            $csv_row[] = 'neighbourhood_longitude';
5437
-        }
5433
+		if ($neighbourhood_active) {
5434
+			$csv_row[] = 'post_neighbourhood';
5435
+			$csv_row[] = 'neighbourhood_latitude';
5436
+			$csv_row[] = 'neighbourhood_longitude';
5437
+		}
5438 5438
 		$csv_row[] = 'geodir_timing';
5439 5439
 		$csv_row[] = 'geodir_contact';
5440 5440
 		$csv_row[] = 'geodir_email';
@@ -5466,21 +5466,21 @@  discard block
 block discarded – undo
5466 5466
 			$csv_row[] = 'franchise';
5467 5467
 		}
5468 5468
         
5469
-        /**
5470
-         * Filter columns feild names of gd export listings csv.
5471
-         *
5472
-         * @since 1.6.5
5473
-         * @package GeoDirectory
5474
-         *
5475
-         * @param array $csv_row Column names being exported in csv.
5476
-         * @param string $post_type The post type.
5477
-         */
5478
-        $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
5469
+		/**
5470
+		 * Filter columns feild names of gd export listings csv.
5471
+		 *
5472
+		 * @since 1.6.5
5473
+		 * @package GeoDirectory
5474
+		 *
5475
+		 * @param array $csv_row Column names being exported in csv.
5476
+		 * @param string $post_type The post type.
5477
+		 */
5478
+		$csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
5479 5479
 		
5480 5480
 		$csv_rows[] = $csv_row;
5481 5481
 
5482 5482
 		$images_count = 5;
5483
-        $xx=0;
5483
+		$xx=0;
5484 5484
 		foreach ( $posts as $post ) {$xx++;
5485 5485
 			$post_id = $post['ID'];
5486 5486
 			
@@ -5611,14 +5611,14 @@  discard block
 block discarded – undo
5611 5611
 			}
5612 5612
 			$csv_row[] = $post_info['post_status']; // post_status
5613 5613
 			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5614
-            if ($is_claim_active) {
5615
-                $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5616
-            }
5614
+			if ($is_claim_active) {
5615
+				$csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5616
+			}
5617 5617
 			if ($is_payment_plugin) {
5618 5618
 				$csv_row[] = (int)$post_info['package_id']; // package_id
5619 5619
 				$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
5620 5620
 			}
5621
-            $csv_row[] = $post_info['post_date']; // post_date
5621
+			$csv_row[] = $post_info['post_date']; // post_date
5622 5622
 			$csv_row[] = $post_info['geodir_video']; // geodir_video
5623 5623
 			$csv_row[] = $post_info['post_address']; // post_address
5624 5624
 			$csv_row[] = $post_info['post_city']; // post_city
@@ -5627,21 +5627,21 @@  discard block
 block discarded – undo
5627 5627
 			$csv_row[] = $post_info['post_zip']; // post_zip
5628 5628
 			$csv_row[] = $post_info['post_latitude']; // post_latitude
5629 5629
 			$csv_row[] = $post_info['post_longitude']; // post_longitude
5630
-            if ($neighbourhood_active) {
5631
-                $post_neighbourhood = '';
5632
-                $neighbourhood_latitude = '';
5633
-                $neighbourhood_longitude = '';
5634
-                if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5635
-                    if (!empty($hood_info)) {
5636
-                        $post_neighbourhood = $hood_info->hood_name;
5637
-                        $neighbourhood_latitude = $hood_info->hood_latitude;
5638
-                        $neighbourhood_longitude = $hood_info->hood_longitude;
5639
-                    }
5640
-                }
5641
-                $csv_row[] = $post_neighbourhood; // post_neighbourhood
5642
-                $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5643
-                $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5644
-            }
5630
+			if ($neighbourhood_active) {
5631
+				$post_neighbourhood = '';
5632
+				$neighbourhood_latitude = '';
5633
+				$neighbourhood_longitude = '';
5634
+				if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5635
+					if (!empty($hood_info)) {
5636
+						$post_neighbourhood = $hood_info->hood_name;
5637
+						$neighbourhood_latitude = $hood_info->hood_latitude;
5638
+						$neighbourhood_longitude = $hood_info->hood_longitude;
5639
+					}
5640
+				}
5641
+				$csv_row[] = $post_neighbourhood; // post_neighbourhood
5642
+				$csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5643
+				$csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5644
+			}
5645 5645
 			$csv_row[] = $post_info['geodir_timing']; // geodir_timing
5646 5646
 			$csv_row[] = $post_info['geodir_contact']; // geodir_contact
5647 5647
 			$csv_row[] = $post_info['geodir_email']; // geodir_email
@@ -5681,16 +5681,16 @@  discard block
 block discarded – undo
5681 5681
 				$csv_row[] = (int)$franchise; // franchise id
5682 5682
 			}
5683 5683
             
5684
-            /**
5685
-             * Filter columns values of gd export listings csv file
5686
-             *
5687
-             * @since 1.6.5
5688
-             * @package GeoDirectory
5689
-             *
5690
-             * @param array $csv_row Field values being exported in csv.
5691
-             * @param array $post_info The post info.
5692
-             */
5693
-            $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5684
+			/**
5685
+			 * Filter columns values of gd export listings csv file
5686
+			 *
5687
+			 * @since 1.6.5
5688
+			 * @package GeoDirectory
5689
+			 *
5690
+			 * @param array $csv_row Field values being exported in csv.
5691
+			 * @param array $post_info The post info.
5692
+			 */
5693
+			$csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5694 5694
 			
5695 5695
 			for ( $c = 0; $c < $images_count; $c++ ) {
5696 5696
 				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
@@ -5723,64 +5723,64 @@  discard block
 block discarded – undo
5723 5723
  * @return array Array of posts data.
5724 5724
  */
5725 5725
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5726
-    global $wpdb, $plugin_prefix;
5726
+	global $wpdb, $plugin_prefix;
5727 5727
 
5728
-    if ( ! post_type_exists( $post_type ) )
5729
-        return new stdClass;
5728
+	if ( ! post_type_exists( $post_type ) )
5729
+		return new stdClass;
5730 5730
         
5731
-    $table = $plugin_prefix . $post_type . '_detail';
5731
+	$table = $plugin_prefix . $post_type . '_detail';
5732 5732
 
5733
-    $limit = '';
5734
-    if ( $per_page > 0 && $page_no > 0 ) {
5735
-        $offset = ( $page_no - 1 ) * $per_page;
5733
+	$limit = '';
5734
+	if ( $per_page > 0 && $page_no > 0 ) {
5735
+		$offset = ( $page_no - 1 ) * $per_page;
5736 5736
         
5737
-        if ( $offset > 0 ) {
5738
-            $limit = " LIMIT " . $offset . "," . $per_page;
5739
-        } else {
5740
-            $limit = " LIMIT " . $per_page;
5741
-        }
5742
-    }
5737
+		if ( $offset > 0 ) {
5738
+			$limit = " LIMIT " . $offset . "," . $per_page;
5739
+		} else {
5740
+			$limit = " LIMIT " . $per_page;
5741
+		}
5742
+	}
5743 5743
 
5744
-    // Skip listing with statuses trash, auto-draft etc...
5745
-    $skip_statuses = geodir_imex_export_skip_statuses();
5746
-    $where_statuses = '';
5747
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5748
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5749
-    }
5744
+	// Skip listing with statuses trash, auto-draft etc...
5745
+	$skip_statuses = geodir_imex_export_skip_statuses();
5746
+	$where_statuses = '';
5747
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5748
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5749
+	}
5750 5750
     
5751
-    /**
5752
-     * Filter the SQL where clause part to filter posts in import/export.
5753
-     *
5754
-     * @since 1.6.4
5755
-     * @package GeoDirectory
5756
-     *
5757
-     * @param string $where SQL where clause part.
5758
-     */
5759
-    $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5760
-
5761
-    $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5762
-    /**
5763
-     * Modify returned posts SQL query for the current post type.
5764
-     *
5765
-     * @since 1.4.6
5766
-     * @package GeoDirectory
5767
-     *
5768
-     * @param int $query The SQL query.
5769
-     * @param string $post_type Post type.
5770
-     */
5771
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5772
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5773
-
5774
-    /**
5775
-     * Modify returned post results for the current post type.
5776
-     *
5777
-     * @since 1.4.6
5778
-     * @package GeoDirectory
5779
-     *
5780
-     * @param object $results An object containing all post ids.
5781
-     * @param string $post_type Post type.
5782
-     */
5783
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5751
+	/**
5752
+	 * Filter the SQL where clause part to filter posts in import/export.
5753
+	 *
5754
+	 * @since 1.6.4
5755
+	 * @package GeoDirectory
5756
+	 *
5757
+	 * @param string $where SQL where clause part.
5758
+	 */
5759
+	$where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5760
+
5761
+	$query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5762
+	/**
5763
+	 * Modify returned posts SQL query for the current post type.
5764
+	 *
5765
+	 * @since 1.4.6
5766
+	 * @package GeoDirectory
5767
+	 *
5768
+	 * @param int $query The SQL query.
5769
+	 * @param string $post_type Post type.
5770
+	 */
5771
+	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5772
+	$results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5773
+
5774
+	/**
5775
+	 * Modify returned post results for the current post type.
5776
+	 *
5777
+	 * @since 1.4.6
5778
+	 * @package GeoDirectory
5779
+	 *
5780
+	 * @param object $results An object containing all post ids.
5781
+	 * @param string $post_type Post type.
5782
+	 */
5783
+	return apply_filters( 'geodir_export_posts', $results, $post_type );
5784 5784
 }
5785 5785
 
5786 5786
 /**
@@ -5799,26 +5799,26 @@  discard block
 block discarded – undo
5799 5799
  * @return string The SQL query.
5800 5800
  */
5801 5801
 function geodir_imex_get_events_query( $query, $post_type ) {
5802
-    if ( $post_type == 'gd_event' ) {
5803
-        global $wpdb, $plugin_prefix;
5802
+	if ( $post_type == 'gd_event' ) {
5803
+		global $wpdb, $plugin_prefix;
5804 5804
         
5805
-        $table = $plugin_prefix . $post_type . '_detail';
5806
-        $schedule_table = EVENT_SCHEDULE;
5805
+		$table = $plugin_prefix . $post_type . '_detail';
5806
+		$schedule_table = EVENT_SCHEDULE;
5807 5807
         
5808
-        // Skip listing with statuses trash, auto-draft etc...
5809
-        $skip_statuses = geodir_imex_export_skip_statuses();
5810
-        $where_statuses = '';
5811
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5812
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5813
-        }
5808
+		// Skip listing with statuses trash, auto-draft etc...
5809
+		$skip_statuses = geodir_imex_export_skip_statuses();
5810
+		$where_statuses = '';
5811
+		if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5812
+			$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5813
+		}
5814 5814
         
5815
-        /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5816
-        $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5815
+		/** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5816
+		$where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5817 5817
 
5818
-        $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime 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 " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5819
-    }
5818
+		$query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime 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 " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5819
+	}
5820 5820
 
5821
-    return $query;
5821
+	return $query;
5822 5822
 }
5823 5823
 
5824 5824
 /**
@@ -5840,36 +5840,36 @@  discard block
 block discarded – undo
5840 5840
  * @return int Total terms count.
5841 5841
  */
5842 5842
 function geodir_get_terms_count( $post_type ) {
5843
-    $args = array( 'hide_empty' => 0 );
5843
+	$args = array( 'hide_empty' => 0 );
5844 5844
 
5845
-    remove_all_filters( 'get_terms' );
5845
+	remove_all_filters( 'get_terms' );
5846 5846
 
5847
-    $taxonomy = $post_type . 'category';
5847
+	$taxonomy = $post_type . 'category';
5848 5848
 
5849
-    // WPML
5850
-    $is_wpml = geodir_is_wpml();
5851
-    $active_lang = 'all';
5852
-    if ( $is_wpml ) {
5853
-        global $sitepress;
5854
-        $active_lang = $sitepress->get_current_language();
5849
+	// WPML
5850
+	$is_wpml = geodir_is_wpml();
5851
+	$active_lang = 'all';
5852
+	if ( $is_wpml ) {
5853
+		global $sitepress;
5854
+		$active_lang = $sitepress->get_current_language();
5855 5855
         
5856
-        if ( $active_lang != 'all' ) {
5857
-            $sitepress->switch_lang( 'all', true );
5858
-        }
5859
-    }
5860
-    // WPML
5856
+		if ( $active_lang != 'all' ) {
5857
+			$sitepress->switch_lang( 'all', true );
5858
+		}
5859
+	}
5860
+	// WPML
5861 5861
             
5862
-    $count_terms = wp_count_terms( $taxonomy, $args );
5862
+	$count_terms = wp_count_terms( $taxonomy, $args );
5863 5863
 
5864
-    // WPML
5865
-    if ( $is_wpml && $active_lang !== 'all' ) {
5866
-        global $sitepress;
5867
-        $sitepress->switch_lang( $active_lang, true );
5868
-    }
5869
-    // WPML
5870
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5864
+	// WPML
5865
+	if ( $is_wpml && $active_lang !== 'all' ) {
5866
+		global $sitepress;
5867
+		$sitepress->switch_lang( $active_lang, true );
5868
+	}
5869
+	// WPML
5870
+	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5871 5871
      
5872
-    return $count_terms;
5872
+	return $count_terms;
5873 5873
 }
5874 5874
 
5875 5875
 /**
@@ -5908,11 +5908,11 @@  discard block
 block discarded – undo
5908 5908
 		$csv_row[] = 'cat_posttype';
5909 5909
 		$csv_row[] = 'cat_parent';
5910 5910
 		$csv_row[] = 'cat_schema';
5911
-        // WPML
5911
+		// WPML
5912 5912
 		$is_wpml = geodir_is_wpml();
5913 5913
 		if ($is_wpml) {
5914 5914
 			$csv_row[] = 'cat_language';
5915
-            $csv_row[] = 'cat_id_original';
5915
+			$csv_row[] = 'cat_id_original';
5916 5916
 		}
5917 5917
 		// WPML
5918 5918
 		$csv_row[] = 'cat_description';
@@ -5942,10 +5942,10 @@  discard block
 block discarded – undo
5942 5942
 			$csv_row[] = $post_type;
5943 5943
 			$csv_row[] = $cat_parent;
5944 5944
 			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5945
-            // WPML
5945
+			// WPML
5946 5946
 			if ($is_wpml) {
5947 5947
 				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5948
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5948
+				$csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5949 5949
 			}
5950 5950
 			// WPML
5951 5951
 			$csv_row[] = $term->description;
@@ -6541,43 +6541,43 @@  discard block
 block discarded – undo
6541 6541
  * @param string $status Post status.
6542 6542
  */
6543 6543
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
6544
-    global $wpdb, $current_user;
6545
-
6546
-    $option_value = get_option($option);
6547
-
6548
-    if ($option_value > 0) :
6549
-        if (get_post($option_value)) :
6550
-            // Page exists
6551
-            return;
6552
-        endif;
6553
-    endif;
6554
-
6555
-    $page_found = $wpdb->get_var(
6556
-        $wpdb->prepare(
6557
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6558
-            array($slug)
6559
-        )
6560
-    );
6561
-
6562
-    if ($page_found) :
6563
-        // Page exists
6564
-        if (!$option_value) update_option($option, $page_found);
6565
-        return;
6566
-    endif;
6567
-
6568
-    $page_data = array(
6569
-        'post_status' => $status,
6570
-        'post_type' => 'page',
6571
-        'post_author' => $current_user->ID,
6572
-        'post_name' => $slug,
6573
-        'post_title' => $page_title,
6574
-        'post_content' => $page_content,
6575
-        'post_parent' => $post_parent,
6576
-        'comment_status' => 'closed'
6577
-    );
6578
-    $page_id = wp_insert_post($page_data);
6579
-
6580
-    add_option($option, $page_id);
6544
+	global $wpdb, $current_user;
6545
+
6546
+	$option_value = get_option($option);
6547
+
6548
+	if ($option_value > 0) :
6549
+		if (get_post($option_value)) :
6550
+			// Page exists
6551
+			return;
6552
+		endif;
6553
+	endif;
6554
+
6555
+	$page_found = $wpdb->get_var(
6556
+		$wpdb->prepare(
6557
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6558
+			array($slug)
6559
+		)
6560
+	);
6561
+
6562
+	if ($page_found) :
6563
+		// Page exists
6564
+		if (!$option_value) update_option($option, $page_found);
6565
+		return;
6566
+	endif;
6567
+
6568
+	$page_data = array(
6569
+		'post_status' => $status,
6570
+		'post_type' => 'page',
6571
+		'post_author' => $current_user->ID,
6572
+		'post_name' => $slug,
6573
+		'post_title' => $page_title,
6574
+		'post_content' => $page_content,
6575
+		'post_parent' => $post_parent,
6576
+		'comment_status' => 'closed'
6577
+	);
6578
+	$page_id = wp_insert_post($page_data);
6579
+
6580
+	add_option($option, $page_id);
6581 6581
 
6582 6582
 }
6583 6583
 
@@ -6608,9 +6608,9 @@  discard block
 block discarded – undo
6608 6608
  * @package GeoDirectory
6609 6609
  */
6610 6610
 function geodir_admin_upgrade_notice() {
6611
-    $class = "error";
6612
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6613
-    echo"<div class=\"$class\"> <p>$message</p></div>";
6611
+	$class = "error";
6612
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6613
+	echo"<div class=\"$class\"> <p>$message</p></div>";
6614 6614
 }
6615 6615
 
6616 6616
 /**
@@ -6623,18 +6623,18 @@  discard block
 block discarded – undo
6623 6623
  */
6624 6624
 function geodire_admin_upgrade_notice( $plugin_data, $r )
6625 6625
 {
6626
-    // readme contents
6627
-    $args = array(
6628
-        'timeout'     => 15,
6629
-        'redirection' => 5
6630
-    );
6631
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6632
-    $data       = wp_remote_get( $url, $args );
6626
+	// readme contents
6627
+	$args = array(
6628
+		'timeout'     => 15,
6629
+		'redirection' => 5
6630
+	);
6631
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6632
+	$data       = wp_remote_get( $url, $args );
6633 6633
 
6634
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
6634
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
6635 6635
 
6636
-        geodir_in_plugin_update_message($data['body']);
6637
-    }
6636
+		geodir_in_plugin_update_message($data['body']);
6637
+	}
6638 6638
 }
6639 6639
 
6640 6640
 
@@ -6642,28 +6642,28 @@  discard block
 block discarded – undo
6642 6642
 * @param string $content http response body
6643 6643
 */
6644 6644
 function geodir_in_plugin_update_message($content) {
6645
-    // Output Upgrade Notice
6646
-    $matches        = null;
6647
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6648
-    $upgrade_notice = '';
6649
-    if ( preg_match( $regexp, $content, $matches ) ) {
6650
-        if(empty($matches)){return;}
6651
-
6652
-        $version = trim( $matches[1] );
6653
-        if($version && $version>GEODIRECTORY_VERSION){
6654
-
6655
-
6656
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6657
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6658
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6659
-            foreach ( $notices as $index => $line ) {
6660
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6661
-            }
6662
-            $upgrade_notice .= '</div> ';
6663
-        }
6664
-        }
6665
-    }
6666
-    echo $upgrade_notice;
6645
+	// Output Upgrade Notice
6646
+	$matches        = null;
6647
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6648
+	$upgrade_notice = '';
6649
+	if ( preg_match( $regexp, $content, $matches ) ) {
6650
+		if(empty($matches)){return;}
6651
+
6652
+		$version = trim( $matches[1] );
6653
+		if($version && $version>GEODIRECTORY_VERSION){
6654
+
6655
+
6656
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6657
+		if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6658
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6659
+			foreach ( $notices as $index => $line ) {
6660
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6661
+			}
6662
+			$upgrade_notice .= '</div> ';
6663
+		}
6664
+		}
6665
+	}
6666
+	echo $upgrade_notice;
6667 6667
 }
6668 6668
 
6669 6669
 /**
@@ -6696,19 +6696,19 @@  discard block
 block discarded – undo
6696 6696
  * @param array Listing statuses to be skipped.
6697 6697
  */
6698 6698
 function geodir_imex_export_skip_statuses() {
6699
-    $statuses = array( 'trash', 'auto-draft' );
6699
+	$statuses = array( 'trash', 'auto-draft' );
6700 6700
     
6701
-    /**
6702
-     * Filter the statuses to skip during GD export listings.
6703
-     *
6704
-     * @since 1.6.0
6705
-     * @package GeoDirectory
6706
-     *
6707
-     * @param array $statuses Listing statuses to be skipped.
6708
-     */
6709
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6701
+	/**
6702
+	 * Filter the statuses to skip during GD export listings.
6703
+	 *
6704
+	 * @since 1.6.0
6705
+	 * @package GeoDirectory
6706
+	 *
6707
+	 * @param array $statuses Listing statuses to be skipped.
6708
+	 */
6709
+	$statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6710 6710
      
6711
-    return $statuses;
6711
+	return $statuses;
6712 6712
 }
6713 6713
 
6714 6714
 /**
@@ -6720,15 +6720,15 @@  discard block
 block discarded – undo
6720 6720
  * @since 1.6.3
6721 6721
  */
6722 6722
 function geodir_admin_dequeue_scripts() {
6723
-    // EDD
6724
-    if (wp_script_is('jquery-chosen', 'enqueued')) {
6725
-        wp_dequeue_script('jquery-chosen');
6726
-    }
6723
+	// EDD
6724
+	if (wp_script_is('jquery-chosen', 'enqueued')) {
6725
+		wp_dequeue_script('jquery-chosen');
6726
+	}
6727 6727
     
6728
-    // Ultimate Addons for Visual Composer
6729
-    if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6730
-        wp_dequeue_script('ultimate-vc-backend-script');
6731
-    }
6728
+	// Ultimate Addons for Visual Composer
6729
+	if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6730
+		wp_dequeue_script('ultimate-vc-backend-script');
6731
+	}
6732 6732
 }
6733 6733
 
6734 6734
 /**
@@ -6744,24 +6744,24 @@  discard block
 block discarded – undo
6744 6744
  * @return string SQL where clause part.
6745 6745
  */
6746 6746
 function geodir_imex_get_filter_where($where = '', $post_type = '') {
6747
-    global $wpdb;
6747
+	global $wpdb;
6748 6748
     
6749
-    $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6749
+	$filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6750 6750
     
6751
-    if ( !empty( $filters ) ) {
6752
-        foreach ( $filters as $field => $value ) {
6753
-            switch ($field) {
6754
-                case 'start_date':
6755
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6756
-                break;
6757
-                case 'end_date':
6758
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6759
-                break;
6760
-            }
6761
-        }
6762
-    }
6751
+	if ( !empty( $filters ) ) {
6752
+		foreach ( $filters as $field => $value ) {
6753
+			switch ($field) {
6754
+				case 'start_date':
6755
+					$where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6756
+				break;
6757
+				case 'end_date':
6758
+					$where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6759
+				break;
6760
+			}
6761
+		}
6762
+	}
6763 6763
     
6764
-    return $where;
6764
+	return $where;
6765 6765
 }
6766 6766
 add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2);
6767 6767
 add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2);
Please login to merge, or discard this patch.
Spacing   +922 added lines, -922 removed lines patch added patch discarded remove patch
@@ -46,31 +46,31 @@  discard block
 block discarded – undo
46 46
     function geodir_admin_styles()
47 47
     {
48 48
 
49
-        wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
49
+        wp_register_style('geodirectory-admin-css', geodir_plugin_url().'/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
50 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);
52
+        wp_register_style('geodirectory-frontend-style', geodir_plugin_url().'/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
53 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);
55
+        wp_register_style('geodir-chosen-style', geodir_plugin_url().'/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
56 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);
58
+        wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url().'/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
59 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);
61
+        wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url().'/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
62 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);
64
+        wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url().'/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
65 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);
67
+        wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url().'/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
68 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);
70
+        wp_register_style('geodir-rating-style', geodir_plugin_url().'/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
71 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);
73
+        wp_register_style('geodir-rtl-style', geodir_plugin_url().'/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
74 74
         wp_enqueue_style('geodir-rtl-style');
75 75
 
76 76
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90 90
         wp_enqueue_style('font-awesome');
91 91
 
92
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
92
+        wp_register_script('geodirectory-admin', geodir_plugin_url().'/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
93 93
         wp_enqueue_script('geodirectory-admin');
94 94
 
95 95
     }
@@ -108,60 +108,60 @@  discard block
 block discarded – undo
108 108
         
109 109
         wp_enqueue_script('jquery');
110 110
 
111
-        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
+        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);
112 112
 
113
-        wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
113
+        wp_register_script('chosen', geodir_plugin_url().'/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
114 114
         wp_enqueue_script('chosen');
115 115
 
116
-        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
116
+        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url().'/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
117 117
         wp_enqueue_script('geodirectory-choose-ajax');
118 118
 
119 119
         if (isset($_REQUEST['listing_type'])) {
120
-            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
120
+            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url().'/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
121 121
         }
122 122
 
123 123
         wp_enqueue_script('geodirectory-custom-fields-script');
124
-        $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
124
+        $plugin_path = geodir_plugin_url().'/geodirectory-functions/cat-meta-functions';
125 125
 
126
-        wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
126
+        wp_enqueue_script('tax-meta-clss', $plugin_path.'/js/tax-meta-clss.js', array('jquery'), null, true);
127 127
 
128 128
         if (in_array($geodir_map_name, array('auto', 'google'))) {
129
-            $map_lang = "&language=" . geodir_get_map_default_language();
130
-            $map_key = "&key=" . geodir_get_map_api_key();
129
+            $map_lang = "&language=".geodir_get_map_default_language();
130
+            $map_key = "&key=".geodir_get_map_api_key();
131 131
             /** This filter is documented in geodirectory_template_tags.php */
132 132
             $map_extra = apply_filters('geodir_googlemap_script_extra', '');
133
-            wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
133
+            wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?'.$map_lang.$map_key.$map_extra, '', NULL);
134 134
         }
135 135
         
136 136
         if ($geodir_map_name == 'osm') {
137 137
             // Leaflet OpenStreetMap
138
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
138
+            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
139 139
             wp_enqueue_style('geodirectory-leaflet-style');
140 140
                 
141
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
141
+            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
142 142
             wp_enqueue_script('geodirectory-leaflet-script');
143 143
             
144
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
144
+            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url().'/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
145 145
             wp_enqueue_script('geodirectory-leaflet-geo-script');
146 146
         }
147
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
147
+        wp_enqueue_script('jquery-ui-autocomplete');
148 148
         
149
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
149
+        wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
150 150
         wp_enqueue_script('geodirectory-goMap-script');
151 151
 
152
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
152
+        wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
153 153
         wp_enqueue_script('geodirectory-goMap-script');
154 154
 
155 155
 		// font awesome rating script
156 156
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
157
-			wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
157
+			wp_register_script('geodir-barrating-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
158 158
 			wp_enqueue_script('geodir-barrating-js');
159 159
 		} else { // default rating script
160
-			wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
160
+			wp_register_script('geodir-jRating-js', geodir_plugin_url().'/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
161 161
 			wp_enqueue_script('geodir-jRating-js');
162 162
 		}
163 163
 
164
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
164
+        wp_register_script('geodir-on-document-load', geodir_plugin_url().'/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
165 165
         wp_enqueue_script('geodir-on-document-load');
166 166
 
167 167
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         wp_enqueue_script('plupload-all');
170 170
         wp_enqueue_script('jquery-ui-sortable');
171 171
 
172
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
172
+        wp_register_script('geodirectory-plupload-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
173 173
         wp_enqueue_script('geodirectory-plupload-script');
174 174
 
175 175
         // SCRIPT FOR UPLOAD END
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
224 224
 
225 225
 
226
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
226
+        wp_register_script('geodirectory-admin-script', geodir_plugin_url().'/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
227 227
         wp_enqueue_script('geodirectory-admin-script');
228 228
 
229 229
         wp_enqueue_style('farbtastic');
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
 
232 232
         $screen = get_current_screen();
233 233
         if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
234
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
234
+            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url().'/geodirectory-assets/js/listing_validation_admin.js');
235 235
         }
236 236
 
237
-        $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
237
+        $ajax_cons_data = array('url' => __(get_option('siteurl').'?geodir_ajax=true'));
238 238
         wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
239 239
 
240 240
     }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
         if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
259 259
 
260
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
260
+        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url().'/geodirectory-assets/images/favicon.ico', '55.1984');
261 261
 
262 262
 
263 263
     }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                 $geodir_menu_order[] = 'separator-geodirectory';
292 292
                 if (!empty($post_types)) {
293 293
                     foreach ($post_types as $post_type) {
294
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
294
+                        $geodir_menu_order[] = 'edit.php?post_type='.$post_type;
295 295
                     }
296 296
                 }
297 297
                 $geodir_menu_order[] = $item;
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 {
335 335
     if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
336 336
         echo '<div id="message" class="updated fade">
337
-                        <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>
338
-                        <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
337
+                        <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>
338
+                        <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory').'</strong></p>
339 339
                 </div>';
340 340
 
341 341
     }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
     if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
344 344
         switch ($_REQUEST['msg']) {
345 345
             case 'success':
346
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
346
+                echo '<div id="message" class="updated fade"><p><strong>'.__('Your settings have been saved.', 'geodirectory').'</strong></p></div>';
347 347
                 flush_rewrite_rules(false);
348 348
 
349 349
                 break;
@@ -351,30 +351,30 @@  discard block
 block discarded – undo
351 351
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
352 352
 				
353 353
 				if ($gderr == 21)
354
-			    	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>';
354
+			    	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>';
355 355
 				else
356
-					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
356
+					echo '<div id="message" class="error fade"><p><strong>'.__('Error: Your settings have not been saved, please try again.', 'geodirectory').'</strong></p></div>';
357 357
                 break;
358 358
         }
359 359
     }
360 360
 
361 361
     $geodir_load_map = get_option('geodir_load_map');
362 362
     $need_map_key = false;
363
-    if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
363
+    if ($geodir_load_map == '' || $geodir_load_map == 'google' || $geodir_load_map == 'auto') {
364 364
         $need_map_key = true;
365 365
     }
366 366
 
367 367
     if (!geodir_get_map_api_key() && $need_map_key) {
368
-        echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
368
+        echo '<div class="error"><p><strong>'.sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings').'\'>', '</a>').'</strong></p></div>';
369 369
     }
370 370
 
371 371
     if (!geodir_is_default_location_set()) {
372
-        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>';
372
+        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>';
373 373
 
374 374
     }
375 375
 
376 376
     if (!function_exists('curl_init')) {
377
-        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>';
377
+        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>';
378 378
 
379 379
     }
380 380
 
@@ -394,18 +394,18 @@  discard block
 block discarded – undo
394 394
 function geodir_handle_option_form_submit($current_tab)
395 395
 {
396 396
     global $geodir_settings;
397
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
397
+    if (file_exists(dirname(__FILE__).'/option-pages/'.$current_tab.'_array.php')) {
398 398
         /**
399 399
          * Contains settings array for current tab.
400 400
          *
401 401
          * @since 1.0.0
402 402
          * @package GeoDirectory
403 403
          */
404
-        include_once('option-pages/' . $current_tab . '_array.php');
404
+        include_once('option-pages/'.$current_tab.'_array.php');
405 405
     }
406 406
     if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
407 407
         if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
408
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
408
+        if (!wp_verify_nonce($_REQUEST['_wpnonce-'.$current_tab], 'geodir-settings-'.$current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
409 409
 		
410 410
 		/**
411 411
 		 * Fires before updating geodirectory admin settings.
@@ -438,13 +438,13 @@  discard block
 block discarded – undo
438 438
          * @param string $current_tab The current settings tab name.
439 439
          * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
440 440
          */
441
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
441
+        do_action('geodir_update_options_'.$current_tab, $geodir_settings[$current_tab]);
442 442
 
443 443
         flush_rewrite_rules(false);
444 444
 
445 445
         $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
446 446
 
447
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
447
+        $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$_REQUEST['active_tab'].'&msg=success');
448 448
 
449 449
         wp_redirect($redirect_url);
450 450
         exit();
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 }
455 455
 
456 456
 
457
-if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
457
+if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined('GD_TESTING_MODE'))) {
458 458
     /**
459 459
      * GeoDirectory dummy data installation.
460 460
      *
@@ -470,18 +470,18 @@  discard block
 block discarded – undo
470 470
         global $wpdb, $plugin_prefix;
471 471
 
472 472
         if (!geodir_is_default_location_set()) {
473
-            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>';
473
+            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>';
474 474
         } else {
475 475
 
476
-            $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
476
+            $geodir_url = admin_url().'admin.php?page=geodirectory&tab=general_settings&active_tab=';
477 477
 
478
-            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
478
+            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM ".$plugin_prefix.$post_type."_detail WHERE post_dummy='1'");
479 479
 
480 480
             if ($post_counts > 0) {
481 481
                 $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
482 482
 
483
-                $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>';
484
-                $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>';
483
+                $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>';
484
+                $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>';
485 485
             } else {
486 486
                 $options_list = '';
487 487
                 for ($option = 1; $option <= 30; $option++) {
@@ -489,13 +489,13 @@  discard block
 block discarded – undo
489 489
                     if ($option == 10)
490 490
                         $selected = 'selected="selected"';
491 491
 
492
-                    $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
492
+                    $options_list .= '<option '.$selected.' value="'.$option.'">'.$option.'</option>';
493 493
                 }
494 494
 
495 495
                 $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
496 496
 
497
-                $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>';
498
-                $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>';
497
+                $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>';
498
+                $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>';
499 499
 
500 500
             }
501 501
             echo $dummy_msg;
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
             <script>
504 504
                 <?php
505 505
                   $default_location = geodir_get_default_location();
506
-                  $city =  isset($default_location->city) ? $default_location->city : '';
507
-                  $region =isset($default_location->region) ? $default_location->region : '';
508
-                  $country =isset($default_location->country) ? $default_location->country : '';
509
-                  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
510
-                  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
506
+                  $city = isset($default_location->city) ? $default_location->city : '';
507
+                  $region = isset($default_location->region) ? $default_location->region : '';
508
+                  $country = isset($default_location->country) ? $default_location->country : '';
509
+                  $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
510
+                  $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
511 511
                 ?>
512 512
                 var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null;
513
-                var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>';
513
+                var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country; ?>';
514 514
                 var bound_lat_lng;
515 515
                 var latlng = ['<?php echo $city_latitude; ?>', <?php echo $city_longitude; ?>];
516 516
                 var lat = <?php echo $city_latitude; ?>;
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                                 );
554 554
 
555 555
                             } else {
556
-                                alert("<?php _e('Geocode was not successful for the following reason:','geodirectory');?> " + status);
556
+                                alert("<?php _e('Geocode was not successful for the following reason:', 'geodirectory'); ?> " + status);
557 557
                             }
558 558
                         });
559 559
                 }
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
                     var total_dummy_post_count = jQuery('#sub_' + active_tab).find('.selected_sample_data').val();
567 567
 
568 568
                     if (id == 'geodir_dummy_delete') {
569
-                        if (confirm('<?php _e('Are you sure you want to delete dummy data?' , 'geodirectory'); ?>')) {
569
+                        if (confirm('<?php _e('Are you sure you want to delete dummy data?', 'geodirectory'); ?>')) {
570 570
                             jQuery('#sub_' + active_tab).find('.geodir_auto_install').hide();
571 571
                             jQuery('#sub_' + active_tab).find('.geodir_show_progress').show();
572 572
                             jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&_wpnonce=' + nonce,
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                         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,
586 586
                             function (data) {
587 587
 
588
-                                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 + '');
588
+                                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 + '');
589 589
                                 dummy_post_index++;
590 590
                                 if (dummy_post_index <= total_dummy_post_count)
591 591
                                     geodir_autoinstall(obj, id, nonce, posttype);
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
      * @package GeoDirectory
627 627
      */
628 628
     include_once('place_dummy_post.php');
629
-    delete_transient( 'cached_dummy_images' );
629
+    delete_transient('cached_dummy_images');
630 630
 
631 631
 }
632 632
 
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
     global $wpdb, $plugin_prefix;
644 644
 
645 645
 
646
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
646
+    $post_ids = $wpdb->get_results("SELECT post_id FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
647 647
 
648 648
 
649 649
     foreach ($post_ids as $post_ids_obj) {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
     }
652 652
 
653 653
     //double check posts are deleted
654
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
654
+    $wpdb->get_results("DELETE FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
655 655
 }
656 656
 
657 657
 /**
@@ -689,14 +689,14 @@  discard block
 block discarded – undo
689 689
 
690 690
 
691 691
                     if (geodir_dummy_folder_exists())
692
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
692
+                        $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon";
693 693
                     else
694 694
                         $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
695 695
 
696 696
                     $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
697 697
 
698 698
                     $catname = str_replace(' ', '_', $catname);
699
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
699
+                    $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
700 700
 
701 701
                     if (empty($uploaded['error'])) {
702 702
                         $new_path = $uploaded['file'];
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
                     $wp_filetype = wp_check_filetype(basename($new_path), null);
707 707
 
708 708
                     $attachment = array(
709
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
709
+                        'guid' => $uploads['baseurl'].'/'.basename($new_path),
710 710
                         'post_mime_type' => $wp_filetype['type'],
711 711
                         'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
712 712
                         'post_content' => '',
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 
717 717
                     // you must first include the image.php file
718 718
                     // for the function wp_generate_attachment_metadata() to work
719
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
719
+                    require_once(ABSPATH.'wp-admin/includes/image.php');
720 720
                     $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
721 721
                     wp_update_attachment_metadata($attach_id, $attach_data);
722 722
 
@@ -733,14 +733,14 @@  discard block
 block discarded – undo
733 733
                 $last_catid = wp_insert_term($catname, 'gd_placecategory');
734 734
 
735 735
                 if (geodir_dummy_folder_exists())
736
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
736
+                    $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon";
737 737
                 else
738 738
                     $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
739 739
 
740 740
                 $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
741 741
 
742 742
                 $catname = str_replace(' ', '_', $catname);
743
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
743
+                $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
744 744
 
745 745
                 if (empty($uploaded['error'])) {
746 746
                     $new_path = $uploaded['file'];
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
                 $wp_filetype = wp_check_filetype(basename($new_path), null);
751 751
 
752 752
                 $attachment = array(
753
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
753
+                    'guid' => $uploads['baseurl'].'/'.basename($new_path),
754 754
                     'post_mime_type' => $wp_filetype['type'],
755 755
                     'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
756 756
                     'post_content' => '',
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 
763 763
                 // you must first include the image.php file
764 764
                 // for the function wp_generate_attachment_metadata() to work
765
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
765
+                require_once(ABSPATH.'wp-admin/includes/image.php');
766 766
                 $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
767 767
                 wp_update_attachment_metadata($attach_id, $attach_data);
768 768
 
@@ -804,18 +804,18 @@  discard block
 block discarded – undo
804 804
 
805 805
         elseif (isset($value['type']) && $value['type'] == 'image_width') :
806 806
 
807
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
808
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
809
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
810
-                if (isset($_POST[$value['id'] . '_crop'])) :
811
-                    update_option($value['id'] . '_crop', 1);
807
+            if (isset($value['id']) && isset($_POST[$value['id'].'_width'])) {
808
+                update_option($value['id'].'_width', $_POST[$value['id'].'_width']);
809
+                update_option($value['id'].'_height', $_POST[$value['id'].'_height']);
810
+                if (isset($_POST[$value['id'].'_crop'])) :
811
+                    update_option($value['id'].'_crop', 1);
812 812
                 else :
813
-                    update_option($value['id'] . '_crop', 0);
813
+                    update_option($value['id'].'_crop', 0);
814 814
                 endif;
815 815
             } else {
816
-                update_option($value['id'] . '_width', $value['std']);
817
-                update_option($value['id'] . '_height', $value['std']);
818
-                update_option($value['id'] . '_crop', 1);
816
+                update_option($value['id'].'_width', $value['std']);
817
+                update_option($value['id'].'_height', $value['std']);
818
+                update_option($value['id'].'_crop', 1);
819 819
             }
820 820
 
821 821
         elseif (isset($value['type']) && $value['type'] == 'map') :
@@ -857,12 +857,12 @@  discard block
 block discarded – undo
857 857
         elseif (isset($value['type']) && $value['type'] == 'file') :
858 858
 
859 859
 
860
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
860
+            if (isset($_POST[$value['id'].'_remove']) && $_POST[$value['id'].'_remove']) {// if remove is set then remove the file
861 861
 
862 862
                 if (get_option($value['id'])) {
863 863
                     $image_name_arr = explode('/', get_option($value['id']));
864 864
                     $noimg_name = end($image_name_arr);
865
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
865
+                    $img_path = $uploads['path'].'/'.$noimg_name;
866 866
                     if (file_exists($img_path))
867 867
                         unlink($img_path);
868 868
                 }
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
                 if (get_option($value['id'])) {
891 891
                     $image_name_arr = explode('/', get_option($value['id']));
892 892
                     $noimg_name = end($image_name_arr);
893
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
893
+                    $img_path = $uploads['path'].'/'.$noimg_name;
894 894
                     if (file_exists($img_path))
895 895
                         unlink($img_path);
896 896
                 }
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
             // same menu setting per theme.
912 912
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
913 913
                 $theme = wp_get_theme();
914
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
914
+                update_option('geodir_theme_location_nav_'.$theme->name, $_POST[$value['id']]);
915 915
             }
916 916
 
917 917
             if (isset($value['id']) && isset($_POST[$value['id']])) {
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
 
982 982
             $listing_slug = $geodir_posttype_info['labels']['singular_name'];
983 983
 
984
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
985
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
984
+            $tabs[$geodir_post_type.'_fields_settings'] = array(
985
+                'label' => __(ucfirst($listing_slug).' Settings', 'geodirectory'),
986 986
                 'subtabs' => array(
987 987
                     array('subtab' => 'custom_fields',
988 988
                         'label' => __('Custom Fields', 'geodirectory'),
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
  */
1016 1016
 function geodir_tools_setting_tab($tabs)
1017 1017
 {
1018
-    wp_enqueue_script( 'jquery-ui-progressbar' );
1018
+    wp_enqueue_script('jquery-ui-progressbar');
1019 1019
     $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1020 1020
     return $tabs;
1021 1021
 }
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
  */
1050 1050
 function geodir_extend_geodirectory_setting_tab($tabs)
1051 1051
 {
1052
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1052
+    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory').' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1053 1053
     return $tabs;
1054 1054
 }
1055 1055
 
@@ -1109,8 +1109,8 @@  discard block
 block discarded – undo
1109 1109
                     _e('Unknown', 'geodirectory');
1110 1110
                 } else {
1111 1111
                     /* If there is a city id, append 'city name' to the text string. */
1112
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1113
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1112
+                    $add_location_id = $location_id > 0 ? ' ('.$location_id.')' : '';
1113
+                    echo(__($location->country, 'geodirectory').'-'.$location->region.'-'.$location->city.$add_location_id);
1114 1114
                 }
1115 1115
                 break;
1116 1116
 
@@ -1128,14 +1128,14 @@  discard block
 block discarded – undo
1128 1128
                         $expire_class = 'expire_over';
1129 1129
                     }
1130 1130
                     $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1131
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1131
+                    $date_diff_text = '<br /><span class="'.$expire_class.'">('.$date_diff.' '.$state.')</span>';
1132 1132
                 }
1133 1133
                 /* If no expire_date is found, output a default message. */
1134 1134
                 if (empty($expire_date))
1135 1135
                     echo __('Unknown', 'geodirectory');
1136 1136
                 /* If there is a expire_date, append 'days left' to the text string. */
1137 1137
                 else
1138
-                    echo $expire_date . $date_diff_text;
1138
+                    echo $expire_date.$date_diff_text;
1139 1139
                 break;
1140 1140
 
1141 1141
             /* If displaying the 'categorys' column. */
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 function geodir_post_information_save($post_id, $post) {
1203 1203
     global $wpdb, $current_user;
1204 1204
 
1205
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1205
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
1206 1206
         return;
1207 1207
     }
1208 1208
 
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
                     $tab_id = $value['id'];
1271 1271
 
1272 1272
                 if (isset($value['desc']) && $value['desc'])
1273
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1273
+                    $desc = '<span style=" text-transform:none;">:- '.$value['desc'].'</span>';
1274 1274
 
1275 1275
                 if (isset($value['name']) && $value['name']) {
1276 1276
                     if ($first_title === true) {
@@ -1278,9 +1278,9 @@  discard block
 block discarded – undo
1278 1278
                     } else {
1279 1279
                         echo '</div>';
1280 1280
                     }
1281
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1281
+                    echo '<dd id="'.trim($tab_id).'" class="geodir_option_tabs" ><a href="javascript:void(0);">'.$value['name'].'</a></dd>';
1282 1282
 
1283
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1283
+                    echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
1284 1284
                 }
1285 1285
 
1286 1286
                 /**
@@ -1290,21 +1290,21 @@  discard block
 block discarded – undo
1290 1290
                  *
1291 1291
                  * @since 1.0.0
1292 1292
                  */
1293
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1293
+                do_action('geodir_settings_'.sanitize_title($value['id']));
1294 1294
                 break;
1295 1295
 
1296 1296
             case 'no_tabs':
1297 1297
 
1298 1298
                 echo '<div class="inner_content_tab_main">';
1299
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1299
+                echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
1300 1300
 
1301 1301
                 break;
1302 1302
 
1303 1303
             case 'sectionstart':
1304 1304
                 if (isset($value['desc']) && $value['desc'])
1305
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1305
+                    $desc = '<span style=" text-transform:none;"> - '.$value['desc'].'</span>';
1306 1306
                 if (isset($value['name']) && $value['name'])
1307
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1307
+                    echo '<h3>'.$value['name'].$desc.'</h3>';
1308 1308
                 /**
1309 1309
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1310 1310
                  *
@@ -1312,8 +1312,8 @@  discard block
 block discarded – undo
1312 1312
                  *
1313 1313
                  * @since 1.0.0
1314 1314
                  */
1315
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1316
-                echo '<table class="form-table">' . "\n\n";
1315
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_start');
1316
+                echo '<table class="form-table">'."\n\n";
1317 1317
 
1318 1318
                 break;
1319 1319
             case 'sectionend':
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
                  *
1325 1325
                  * @since 1.0.0
1326 1326
                  */
1327
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1327
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_end');
1328 1328
                 echo '</table>';
1329 1329
                 /**
1330 1330
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
                  *
1334 1334
                  * @since 1.0.0
1335 1335
                  */
1336
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1336
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_after');
1337 1337
                 break;
1338 1338
             case 'text':
1339 1339
                 ?>
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1343 1343
                                            id="<?php echo esc_attr($value['id']); ?>"
1344 1344
                                            type="<?php echo esc_attr($value['type']); ?>"
1345
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1345
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1346 1346
                                            style=" <?php echo esc_attr($value['css']); ?>"
1347 1347
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1348 1348
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1360 1360
                                            id="<?php echo esc_attr($value['id']); ?>"
1361 1361
                                            type="<?php echo esc_attr($value['type']); ?>"
1362
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1362
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1363 1363
                                            style="<?php echo esc_attr($value['css']); ?>"
1364 1364
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1365 1365
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1405,17 +1405,17 @@  discard block
 block discarded – undo
1405 1405
                     <?php _e('Width', 'geodirectory'); ?> <input
1406 1406
                         name="<?php echo esc_attr($value['id']); ?>_width"
1407 1407
                         id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3"
1408
-                        value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1408
+                        value="<?php if ($size = get_option($value['id'].'_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1409 1409
 
1410 1410
                     <?php _e('Height', 'geodirectory'); ?> <input
1411 1411
                         name="<?php echo esc_attr($value['id']); ?>_height"
1412 1412
                         id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3"
1413
-                        value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1413
+                        value="<?php if ($size = get_option($value['id'].'_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1414 1414
 
1415 1415
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
1416 1416
                             name="<?php echo esc_attr($value['id']); ?>_crop"
1417 1417
                             id="<?php echo esc_attr($value['id']); ?>_crop"
1418
-                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label>
1418
+                            type="checkbox" <?php if (get_option($value['id'].'_crop') != '') checked(get_option($value['id'].'_crop'), 1); else checked(1); ?> /></label>
1419 1419
 
1420 1420
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1421 1421
                 </tr><?php
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
                                             id="<?php echo esc_attr($value['id']); ?>"
1466 1466
                                             style="<?php echo esc_attr($value['css']); ?>"
1467 1467
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1468
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1468
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>"
1469 1469
                                             option-ajaxchosen="false">
1470 1470
                         <?php
1471 1471
                         foreach ($value['options'] as $key => $val) {
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
                             } else {
1477 1477
                                 ?>
1478 1478
                                 <option
1479
-                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1479
+                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values))); ?>><?php echo ucfirst($val) ?></option>
1480 1480
                             <?php
1481 1481
                             }
1482 1482
                         }
@@ -1511,7 +1511,7 @@  discard block
 block discarded – undo
1511 1511
                 ?>
1512 1512
 
1513 1513
                 <tr valign="top">
1514
-                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1514
+                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
1515 1515
                     <td width="60%">
1516 1516
                         <select name="geodir_default_map_language" style="width:60%">
1517 1517
                             <?php
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 
1594 1594
                 <tr valign="top">
1595 1595
                     <th class="titledesc"
1596
-                        width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
1596
+                        width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
1597 1597
                     <td width="60%">
1598 1598
                         <select name="geodir_default_map_search_pt" style="width:60%">
1599 1599
                             <?php
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
                         $cat_display = 'checkbox';
1635 1635
                         $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1636 1636
                         $gd_cats = get_option('geodir_exclude_cat_on_map');
1637
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1637
+                        $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
1638 1638
                         $count = 1;
1639 1639
                         ?>
1640 1640
                         <table width="70%" class="widefat">
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
                                                                                            name="home_map_post_types[]"
1664 1664
                                                                                            id="<?php echo esc_attr($value['id']); ?>"
1665 1665
                                                                                            value="<?php echo $key; ?>"
1666
-                                                                                           class="map_post_type" <?php echo $checked;?> />
1666
+                                                                                           class="map_post_type" <?php echo $checked; ?> />
1667 1667
                                         <?php echo $post_types_obj->labels->singular_name; ?></td>
1668 1668
                                     <td width="40%">
1669 1669
                                         <div class="home_map_category" style="overflow:auto;width:200px;height:100px;"
@@ -1721,12 +1721,12 @@  discard block
 block discarded – undo
1721 1721
                 ?>
1722 1722
                 <fieldset>
1723 1723
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1724
-                    <label for="<?php echo $value['id'];?>">
1724
+                    <label for="<?php echo $value['id']; ?>">
1725 1725
                         <input name="<?php echo esc_attr($value['id']); ?>"
1726
-                               id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1726
+                               id="<?php echo esc_attr($value['id'].$value['value']); ?>" type="radio"
1727 1727
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1728 1728
                             echo 'checked="checked"';
1729
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1729
+                        }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
1730 1730
                         <?php echo $value['desc']; ?></label><br>
1731 1731
                 </fieldset>
1732 1732
                 <?php
@@ -1746,9 +1746,9 @@  discard block
 block discarded – undo
1746 1746
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1747 1747
                 <td class="forminp">
1748 1748
                     <textarea
1749
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1749
+                        <?php if (isset($value['args'])) echo $value['args'].' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1750 1750
                         id="<?php echo esc_attr($value['id']); ?>"
1751
-                        <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1751
+                        <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1752 1752
                         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
1753 1753
                         class="description"><?php echo $value['desc'] ?></span>
1754 1754
 
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 					}
1794 1794
 				}
1795 1795
 				//
1796
-				$page_setting = (int)get_option($value['id']);
1796
+				$page_setting = (int) get_option($value['id']);
1797 1797
 
1798 1798
                 $args = array('name' => $value['id'],
1799 1799
                     'id' => $value['id'],
@@ -1810,7 +1810,7 @@  discard block
 block discarded – undo
1810 1810
                 <tr valign="top" class="single_select_page">
1811 1811
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1812 1812
                 <td class="forminp">
1813
-                    <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' " . $disabled . " id=", wp_dropdown_pages($args)); ?>
1813
+                    <?php echo str_replace(' id=', " data-placeholder='".__('Select a page...', 'geodirectory')."' style='".$value['css']."' class='".$value['class']."' ".$disabled." id=", wp_dropdown_pages($args)); ?>
1814 1814
                     <span class="description"><?php echo $value['desc'] ?></span>
1815 1815
                 </td>
1816 1816
                 </tr><?php
@@ -1819,7 +1819,7 @@  discard block
 block discarded – undo
1819 1819
 				}
1820 1820
                 break;
1821 1821
             case 'single_select_country' :
1822
-                $country_setting = (string)get_option($value['id']);
1822
+                $country_setting = (string) get_option($value['id']);
1823 1823
                 if (strstr($country_setting, ':')) :
1824 1824
                     $country = current(explode(':', $country_setting));
1825 1825
                     $state = end(explode(':', $country_setting));
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
             case 'multi_select_countries' :
1843 1843
                 $countries = $geodirectory->countries->countries;
1844 1844
                 asort($countries);
1845
-                $selections = (array)get_option($value['id']);
1845
+                $selections = (array) get_option($value['id']);
1846 1846
                 ?>
1847 1847
                 <tr valign="top">
1848 1848
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
                             title="Country" class="chosen_select">
1853 1853
                         <?php
1854 1854
                         if ($countries) foreach ($countries as $key => $val) :
1855
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1855
+                            echo '<option value="'.$key.'" '.selected(in_array($key, $selections), true, false).'>'.$val.'</option>';
1856 1856
                         endforeach;
1857 1857
                         ?>
1858 1858
                     </select>
@@ -1864,8 +1864,8 @@  discard block
 block discarded – undo
1864 1864
                 break;
1865 1865
 
1866 1866
             case 'google_analytics' :
1867
-                $selections = (array)get_option($value['id']);
1868
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1867
+                $selections = (array) get_option($value['id']);
1868
+                if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
1869 1869
                     ?>
1870 1870
                     <tr valign="top">
1871 1871
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1876,20 +1876,20 @@  discard block
 block discarded – undo
1876 1876
 
1877 1877
                             $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1878 1878
                             $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1879
-                            $state = "&state=123";//any string
1880
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1879
+                            $state = "&state=123"; //any string
1880
+                            $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
1881 1881
                             $response_type = "&response_type=code";
1882 1882
                             $client_id = "&client_id=".get_option('geodir_ga_client_id');
1883 1883
                             $access_type = "&access_type=offline";
1884 1884
                             $approval_prompt = "&approval_prompt=force";
1885 1885
 
1886
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1886
+                            $auth_url = $oAuthURL.$scope.$state.$redirect_uri.$response_type.$client_id.$access_type.$approval_prompt;
1887 1887
 
1888 1888
 
1889 1889
                             ?>
1890 1890
                             <script>
1891 1891
                                 function gd_ga_popup() {
1892
-                                    var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
1892
+                                    var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
1893 1893
                                     var pollTimer = window.setInterval(function () {
1894 1894
                                         if (win.closed !== false) { // !== is required for compatibility with Opera
1895 1895
                                             window.clearInterval(pollTimer);
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
                             } else {
1912 1912
                                 ?>
1913 1913
                                 <span class="button-primary"
1914
-                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1914
+                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
1915 1915
                             <?php
1916 1916
                             }
1917 1917
                             ?>
@@ -1982,9 +1982,9 @@  discard block
 block discarded – undo
1982 1982
 
1983 1983
             <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
1984 1984
             jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
1985
-            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
1985
+            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
1986 1986
             jQuery('.gd-content-heading').hide();
1987
-            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
1987
+            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
1988 1988
             <?php } ?>
1989 1989
         });
1990 1990
     </script>
@@ -2070,7 +2070,7 @@  discard block
 block discarded – undo
2070 2070
     wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2071 2071
 
2072 2072
     if (geodir_get_featured_image($post_id, 'thumbnail')) {
2073
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2073
+        echo '<h4>'.__('Featured Image', 'geodirectory').'</h4>';
2074 2074
         geodir_show_featured_image($post_id, 'thumbnail');
2075 2075
     }
2076 2076
 
@@ -2081,13 +2081,13 @@  discard block
 block discarded – undo
2081 2081
 
2082 2082
     <h5 class="form_title">
2083 2083
         <?php if ($image_limit != 0 && $image_limit == 1) {
2084
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2084
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('image with this package', 'geodirectory').')</small>';
2085 2085
         } ?>
2086 2086
         <?php if ($image_limit != 0 && $image_limit > 1) {
2087
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2087
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('images with this package', 'geodirectory').')</small>';
2088 2088
         } ?>
2089 2089
         <?php if ($image_limit == 0) {
2090
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2090
+            echo '<br /><small>('.__('You can upload unlimited images with this package', 'geodirectory').')</small>';
2091 2091
         } ?>
2092 2092
     </h5>
2093 2093
 
@@ -2126,10 +2126,10 @@  discard block
 block discarded – undo
2126 2126
         <div
2127 2127
             class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
2128 2128
             id="<?php echo $id; ?>plupload-upload-ui">
2129
-            <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
2129
+            <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
2130 2130
             <input id="<?php echo $id; ?>plupload-browse-button" type="button"
2131 2131
                    value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
2132
-            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span>
2132
+            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id.'pluploadan'); ?>"></span>
2133 2133
             <?php if ($width && $height): ?>
2134 2134
                 <span class="plupload-resize"></span>
2135 2135
                 <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span>
@@ -2141,7 +2141,7 @@  discard block
 block discarded – undo
2141 2141
              id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
2142 2142
         </div>
2143 2143
         <span
2144
-            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory');?></span>
2144
+            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory'); ?></span>
2145 2145
         <span id="<?php echo $id; ?>upload-error" style="display:none"></span>
2146 2146
     </div>
2147 2147
 
@@ -2351,9 +2351,9 @@  discard block
 block discarded – undo
2351 2351
     $plugin = 'avada-nag';
2352 2352
     $timestamp = 'avada-nag1234';
2353 2353
     $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');
2354
-    echo '<div id="' . $timestamp . '"  class="error">';
2355
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2356
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2354
+    echo '<div id="'.$timestamp.'"  class="error">';
2355
+    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\''.$plugin.'\',\''.$timestamp.'\');" ><i class="fa fa-times"></i></span>';
2356
+    echo "<img class='gd-icon-noti' src='".plugin_dir_url('')."geodirectory/geodirectory-assets/images/favicon.ico' > ";
2357 2357
     echo "<p>$message</p>";
2358 2358
     echo "</div>";
2359 2359
 
@@ -2486,7 +2486,7 @@  discard block
 block discarded – undo
2486 2486
 		
2487 2487
 		// Don't allow same slug url for listing and location
2488 2488
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2489
-			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2489
+			$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab.'&msg=fail&gderr=21');
2490 2490
         	wp_redirect($redirect_url);
2491 2491
 			exit;
2492 2492
 		}
@@ -2498,7 +2498,7 @@  discard block
 block discarded – undo
2498 2498
 			$default_language = $sitepress->get_default_language();
2499 2499
 			
2500 2500
 			if ($current_language != 'all' && $current_language != $default_language) {
2501
-				$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
2501
+				$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab);
2502 2502
 				wp_redirect($redirect_url);
2503 2503
 				exit;
2504 2504
 			}
@@ -2519,11 +2519,11 @@  discard block
 block discarded – undo
2519 2519
 function geodir_hide_admin_preview_button() {
2520 2520
     global $post_type;
2521 2521
     $post_types = geodir_get_posttypes();
2522
-    if(in_array($post_type, $post_types))
2522
+    if (in_array($post_type, $post_types))
2523 2523
         echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2524 2524
 }
2525
-add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2526
-add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2525
+add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
2526
+add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
2527 2527
 
2528 2528
 /**
2529 2529
  * Add the tab in left sidebar menu fro import & export page.
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
  *
2534 2534
  * @return array Array of tab data.
2535 2535
  */
2536
-function geodir_import_export_tab( $tabs ) {
2537
-	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2536
+function geodir_import_export_tab($tabs) {
2537
+	$tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
2538 2538
     return $tabs;
2539 2539
 }
2540 2540
 
@@ -2548,8 +2548,8 @@  discard block
 block discarded – undo
2548 2548
  * @return string Html content.
2549 2549
  */
2550 2550
 function geodir_import_export_page() {
2551
-	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2552
-	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2551
+	$nonce = wp_create_nonce('geodir_import_export_nonce');
2552
+	$gd_cats_sample_csv = geodir_plugin_url().'/geodirectory-assets/gd_sample_categories.csv';
2553 2553
     /**
2554 2554
      * Filter sample category data csv file url.
2555 2555
      *
@@ -2558,9 +2558,9 @@  discard block
 block discarded – undo
2558 2558
      *
2559 2559
      * @param string $gd_cats_sample_csv Sample category data csv file url.
2560 2560
      */
2561
-	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2561
+	$gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
2562 2562
 	
2563
-	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2563
+	$gd_posts_sample_csv = geodir_plugin_url().'/geodirectory-assets/place_listing.csv';
2564 2564
     /**
2565 2565
      * Filter sample post data csv file url.
2566 2566
      *
@@ -2569,15 +2569,15 @@  discard block
 block discarded – undo
2569 2569
      *
2570 2570
      * @param string $gd_posts_sample_csv Sample post data csv file url.
2571 2571
      */
2572
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2572
+    $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
2573 2573
 	
2574
-	$gd_posttypes = geodir_get_posttypes( 'array' );
2574
+	$gd_posttypes = geodir_get_posttypes('array');
2575 2575
 	
2576 2576
 	$gd_posttypes_option = '';
2577
-	foreach ( $gd_posttypes as $gd_posttype => $row ) {
2578
-		$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>';
2577
+	foreach ($gd_posttypes as $gd_posttype => $row) {
2578
+		$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>';
2579 2579
 	}
2580
-	wp_enqueue_script( 'jquery-ui-progressbar' );
2580
+	wp_enqueue_script('jquery-ui-progressbar');
2581 2581
 	
2582 2582
 	$gd_chunksize_options = array();
2583 2583
 	$gd_chunksize_options[100] = 100;
@@ -2599,49 +2599,49 @@  discard block
 block discarded – undo
2599 2599
      *
2600 2600
      * @param string $gd_chunksize_options Entries options.
2601 2601
      */
2602
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2602
+    $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
2603 2603
 	
2604 2604
 	$gd_chunksize_option = '';
2605 2605
 	foreach ($gd_chunksize_options as $value => $title) {
2606
-		$gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>';
2606
+		$gd_chunksize_option .= '<option value="'.$value.'" '.selected($value, 5000, false).'>'.$title.'</option>';
2607 2607
 	}
2608 2608
 	
2609 2609
 	$uploads = wp_upload_dir();
2610 2610
 ?>
2611 2611
 </form>
2612 2612
 <div class="inner_content_tab_main gd-import-export">
2613
-  <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3>
2614
-  <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span>
2613
+  <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
2614
+  <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
2615 2615
   <div class="gd-content-heading">
2616 2616
 
2617 2617
   <?php
2618 2618
     ini_set('max_execution_time', 999999);
2619
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2619
+    $ini_max_execution_time_check = @ini_get('max_execution_time');
2620 2620
     ini_restore('max_execution_time');
2621 2621
 
2622
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2622
+    if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
2623 2623
         ?>
2624 2624
 	<div id="gd_ie_reqs" class="metabox-holder">
2625 2625
       <div class="meta-box-sortables ui-sortable">
2626 2626
         <div class="postbox">
2627
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3>
2627
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
2628 2628
           <div class="inside">
2629
-            <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>
2629
+            <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>
2630 2630
 			<table class="form-table">
2631 2631
 				<thead>
2632 2632
 				  <tr>
2633
-				  	<th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th>
2633
+				  	<th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
2634 2634
 				  </tr>
2635 2635
 				</thead>
2636 2636
 				<tbody>
2637 2637
 				  <tr>
2638
-				  	<td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td>
2638
+				  	<td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
2639 2639
 				  </tr>
2640 2640
 				  <tr>
2641
-				  	<td>max_execution_time</td><td><?php  echo @ini_get( 'max_execution_time' );?></td><td>3000</td>
2641
+				  	<td>max_execution_time</td><td><?php  echo @ini_get('max_execution_time'); ?></td><td>3000</td>
2642 2642
 				  </tr>
2643 2643
 				  <tr>
2644
-				  	<td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td>
2644
+				  	<td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
2645 2645
 				  </tr>
2646 2646
 				</tbody>
2647 2647
 		    </table>
@@ -2653,21 +2653,21 @@  discard block
 block discarded – undo
2653 2653
 	<div id="gd_ie_imposts" class="metabox-holder">
2654 2654
       <div class="meta-box-sortables ui-sortable">
2655 2655
         <div id="gd_ie_im_posts" class="postbox gd-hndle-pbox">
2656
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Listings: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2657
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3>
2656
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Listings: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2657
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
2658 2658
           <div class="inside">
2659 2659
             <table class="form-table">
2660 2660
 				<tbody>
2661 2661
 				  <tr>
2662 2662
 					<td class="gd-imex-box">
2663 2663
 						<div class="gd-im-choices">
2664
-						<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>
2665
-						<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>
2664
+						<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>
2665
+						<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>
2666 2666
 						</div>
2667 2667
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui">
2668 2668
 							<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');" />
2669
-							<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">
2670
-						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" />
2669
+							<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">
2670
+						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" />
2671 2671
 							<?php
2672 2672
 							/**
2673 2673
 							 * Called just after the sample CSV download link.
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
 							 */
2677 2677
 							do_action('geodir_sample_csv_download_link');
2678 2678
 							?>
2679
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span>
2679
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
2680 2680
 							<div class="filelist"></div>
2681 2681
 						</div>
2682 2682
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2694,7 +2694,7 @@  discard block
 block discarded – undo
2694 2694
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2695 2695
 						</div>
2696 2696
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2697
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2697
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2698 2698
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2699 2699
 									id="gd-import-perc">0%</font> )
2700 2700
 								<div class="gd-fileprogress"></div>
@@ -2706,10 +2706,10 @@  discard block
 block discarded – undo
2706 2706
                     	<div class="gd-imex-btns" style="display:none;">
2707 2707
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2708 2708
                         	<input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2709
-                        	<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"/>
2710
-                        	<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')"/>
2709
+                        	<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"/>
2710
+                        	<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')"/>
2711 2711
 							<div id="gd_process_data" style="display:none">
2712
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2712
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2713 2713
 							</div>
2714 2714
 						</div>
2715 2715
 					</td>
@@ -2723,30 +2723,30 @@  discard block
 block discarded – undo
2723 2723
 	<div id="gd_ie_excategs" class="metabox-holder">
2724 2724
 	  <div class="meta-box-sortables ui-sortable">
2725 2725
 		<div id="gd_ie_ex_posts" class="postbox gd-hndle-pbox">
2726
-		  <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - Listings: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2727
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3>
2726
+		  <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - Listings: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2727
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
2728 2728
 		  <div class="inside">
2729 2729
 			<table class="form-table">
2730 2730
 			  <tbody>
2731 2731
 				<tr>
2732 2732
 				  <td class="fld"><label for="gd_post_type">
2733
-					<?php _e( 'Post Type:', 'geodirectory' );?>
2733
+					<?php _e('Post Type:', 'geodirectory'); ?>
2734 2734
 					</label></td>
2735 2735
 				  <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px">
2736
-					  <?php echo $gd_posttypes_option;?>
2736
+					  <?php echo $gd_posttypes_option; ?>
2737 2737
 					</select></td>
2738 2738
 				</tr>
2739 2739
 				<tr>
2740
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2741
-					<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>
2740
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2741
+					<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>
2742 2742
 				</tr>
2743 2743
                 <tr class="gd-imex-dates">
2744
-					<td class="fld"><label><?php _e( 'Published Date:', 'geodirectory' );?></label></td>
2745
-					<td><label><span class="label-responsive"><?php _e( 'Start date:', 'geodirectory' );?></span><input type="text" id="gd_imex_start_date" name="gd_imex[start_date]" data-type="date" /></label><label><span class="label-responsive"><?php _e( 'End date:', 'geodirectory' );?></span><input type="text" id="gd_imex_end_date" name="gd_imex[end_date]" data-type="date" /></label></td>
2744
+					<td class="fld"><label><?php _e('Published Date:', 'geodirectory'); ?></label></td>
2745
+					<td><label><span class="label-responsive"><?php _e('Start date:', 'geodirectory'); ?></span><input type="text" id="gd_imex_start_date" name="gd_imex[start_date]" data-type="date" /></label><label><span class="label-responsive"><?php _e('End date:', 'geodirectory'); ?></span><input type="text" id="gd_imex_end_date" name="gd_imex[end_date]" data-type="date" /></label></td>
2746 2746
 				</tr>
2747 2747
 				<tr>
2748 2748
 				  <td class="fld" style="vertical-align:top"><label>
2749
-					<?php _e( 'Progress:', 'geodirectory' );?>
2749
+					<?php _e('Progress:', 'geodirectory'); ?>
2750 2750
 					</label></td>
2751 2751
 				  <td><div id='gd_progressbar_box'>
2752 2752
 					  <div id="gd_progressbar" class="gd_progressbar">
@@ -2754,13 +2754,13 @@  discard block
 block discarded – undo
2754 2754
 					  </div>
2755 2755
 					</div>
2756 2756
 					<p style="display:inline-block">
2757
-					  <?php _e( 'Elapsed Time:', 'geodirectory' );?>
2757
+					  <?php _e('Elapsed Time:', 'geodirectory'); ?>
2758 2758
 					</p>
2759 2759
 					  
2760 2760
 					<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2761 2761
 				</tr>
2762 2762
 				<tr class="gd-ie-actions">
2763
-				  <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">
2763
+				  <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">
2764 2764
 				  </td>
2765 2765
 				  <td id="gd_ie_ex_files" class="gd-ie-files"></td>
2766 2766
 				</tr>
@@ -2773,21 +2773,21 @@  discard block
 block discarded – undo
2773 2773
 	<div id="gd_ie_imcategs" class="metabox-holder">
2774 2774
       <div class="meta-box-sortables ui-sortable">
2775 2775
         <div id="gd_ie_imcats" class="postbox gd-hndle-pbox">
2776
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2777
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3>
2776
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2777
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
2778 2778
           <div class="inside">
2779 2779
             <table class="form-table">
2780 2780
 				<tbody>
2781 2781
 				  <tr>
2782 2782
 					<td class="gd-imex-box">
2783 2783
 						<div class="gd-im-choices">
2784
-						<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>
2785
-						<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>
2784
+						<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>
2785
+						<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>
2786 2786
 						</div>
2787 2787
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui">
2788 2788
 							<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');" />
2789
-							<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">
2790
-						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" />
2789
+							<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">
2790
+						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" />
2791 2791
 						<?php
2792 2792
 						/**
2793 2793
 						 * Called just after the sample CSV download link.
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
 						 */
2798 2798
 						do_action('geodir_sample_cats_csv_download_link');
2799 2799
 						?>
2800
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span>
2800
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
2801 2801
 							<div class="filelist"></div>
2802 2802
 						</div>
2803 2803
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2814,7 +2814,7 @@  discard block
 block discarded – undo
2814 2814
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2815 2815
 						</div>
2816 2816
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2817
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2817
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2818 2818
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2819 2819
 									id="gd-import-perc">0%</font> )
2820 2820
 								<div class="gd-fileprogress"></div>
@@ -2826,10 +2826,10 @@  discard block
 block discarded – undo
2826 2826
                     	<div class="gd-imex-btns" style="display:none;">
2827 2827
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2828 2828
                         	<input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2829
-                        	<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"/>
2830
-                        	<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')"/>
2829
+                        	<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"/>
2830
+                        	<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')"/>
2831 2831
 							<div id="gd_process_data" style="display:none">
2832
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2832
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2833 2833
 							</div>
2834 2834
 						</div>
2835 2835
 					</td>
@@ -2843,26 +2843,26 @@  discard block
 block discarded – undo
2843 2843
 	<div id="gd_ie_excategs" class="metabox-holder">
2844 2844
       <div class="meta-box-sortables ui-sortable">
2845 2845
         <div id="gd_ie_ex_cats" class="postbox gd-hndle-pbox">
2846
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2847
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3>
2846
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2847
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
2848 2848
           <div class="inside">
2849 2849
             <table class="form-table">
2850 2850
 				<tbody>
2851 2851
 				  <tr>
2852
-					<td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td>
2853
-					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td>
2852
+					<td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
2853
+					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td>
2854 2854
 				  </tr>
2855 2855
 				   <tr>
2856
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2857
-					<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>
2856
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2857
+					<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>
2858 2858
 				  </tr>
2859 2859
 				  <tr>
2860
-					<td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td>
2861
-					<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>
2860
+					<td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
2861
+					<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>
2862 2862
 				  </tr>
2863 2863
 				  <tr class="gd-ie-actions">
2864 2864
 					<td style="vertical-align:top">
2865
-						<input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2865
+						<input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2866 2866
 					</td>
2867 2867
 					<td id="gd_ie_ex_files" class="gd-ie-files"></td>
2868 2868
 				  </tr>
@@ -2884,7 +2884,7 @@  discard block
 block discarded – undo
2884 2884
      * @param array $gd_chunksize_options File chunk size options.
2885 2885
      * @param string $nonce Wordpress security token for GD import & export.
2886 2886
 	 */
2887
-	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2887
+	do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
2888 2888
 	?>
2889 2889
   </div>
2890 2890
 </div>
@@ -2903,7 +2903,7 @@  discard block
 block discarded – undo
2903 2903
         jQuery.ajax({
2904 2904
             url: ajaxurl,
2905 2905
             type: "POST",
2906
-            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>',
2906
+            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>',
2907 2907
             dataType: 'json',
2908 2908
             cache: false,
2909 2909
             success: function(data) {
@@ -2955,7 +2955,7 @@  discard block
 block discarded – undo
2955 2955
 
2956 2956
         jQuery(cont).find('.filelist .file').remove();
2957 2957
         
2958
-        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
2958
+        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
2959 2959
         jQuery('#gd-import-msg', cont).show();
2960 2960
         
2961 2961
         return false;
@@ -3014,7 +3014,7 @@  discard block
 block discarded – undo
3014 3014
     jQuery.ajax({
3015 3015
         url: ajaxurl,
3016 3016
         type: "POST",
3017
-        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>',
3017
+        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>',
3018 3018
         dataType : 'json',
3019 3019
         cache: false,
3020 3020
         success: function (data) {
@@ -3203,27 +3203,27 @@  discard block
 block discarded – undo
3203 3203
 
3204 3204
     var gdMsg = '<p></p>';
3205 3205
     if ( processed > 0 ) {
3206
-        var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>';
3206
+        var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
3207 3207
         msgParse = msgParse.replace("%s", processed);
3208 3208
         gdMsg += msgParse;
3209 3209
     }
3210 3210
 
3211 3211
     if ( updated > 0 ) {
3212
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3212
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
3213 3213
         msgParse = msgParse.replace("%s", updated);
3214 3214
         msgParse = msgParse.replace("%d", processed);
3215 3215
         gdMsg += msgParse;
3216 3216
     }
3217 3217
 
3218 3218
     if ( created > 0 ) {
3219
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3219
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
3220 3220
         msgParse = msgParse.replace("%s", created);
3221 3221
         msgParse = msgParse.replace("%d", processed);
3222 3222
         gdMsg += msgParse;
3223 3223
     }
3224 3224
 
3225 3225
     if ( skipped > 0 ) {
3226
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3226
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
3227 3227
         msgParse = msgParse.replace("%s", skipped);
3228 3228
         msgParse = msgParse.replace("%d", processed);
3229 3229
         gdMsg += msgParse;
@@ -3233,17 +3233,17 @@  discard block
 block discarded – undo
3233 3233
         if (type=='loc') {
3234 3234
             invalid_addr = invalid;
3235 3235
         }
3236
-        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>';
3236
+        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>';
3237 3237
         msgParse = msgParse.replace("%s", invalid_addr);
3238 3238
         msgParse = msgParse.replace("%d", total);
3239 3239
         gdMsg += msgParse;
3240 3240
     }
3241 3241
 
3242 3242
     if (invalid > 0 && type!='loc') {
3243
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3243
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory'), '%s', '%d')); ?></p>';
3244 3244
         
3245 3245
         if (type=='hood') {
3246
-            msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ), '%s', '%d' ) );?></p>';
3246
+            msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory'), '%s', '%d')); ?></p>';
3247 3247
         }
3248 3248
         msgParse = msgParse.replace("%s", invalid);
3249 3249
         msgParse = msgParse.replace("%d", total);
@@ -3251,7 +3251,7 @@  discard block
 block discarded – undo
3251 3251
     }
3252 3252
 
3253 3253
     if (images > 0) {
3254
-        gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>';
3254
+        gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>';
3255 3255
     }
3256 3256
     gdMsg += '<p></p>';
3257 3257
     jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
@@ -3415,9 +3415,9 @@  discard block
 block discarded – undo
3415 3415
             if (typeof filters !== 'undefined' && filters && doFilter) {
3416 3416
                 getTotal = true;
3417 3417
                 attach += '&_c=1';
3418
-                gd_progressbar(el, 0, '<i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Preparing...', 'geodirectory' ) );?>');
3418
+                gd_progressbar(el, 0, '<i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Preparing...', 'geodirectory')); ?>');
3419 3419
             } else {
3420
-                gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3420
+                gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3421 3421
             }
3422 3422
             jQuery(el).find('#gd_timer').text('00:00:01');
3423 3423
             jQuery('#gd_ie_ex_files', el).html('');
@@ -3426,7 +3426,7 @@  discard block
 block discarded – undo
3426 3426
         jQuery.ajax({
3427 3427
             url: ajaxurl,
3428 3428
             type: "POST",
3429
-            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page + attach,
3429
+            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page + attach,
3430 3430
             dataType : 'json',
3431 3431
             cache: false,
3432 3432
             beforeSend: function (jqXHR, settings) {},
@@ -3451,11 +3451,11 @@  discard block
 block discarded – undo
3451 3451
                         } else {
3452 3452
                             if (pages < page || pages == page) {
3453 3453
                                 window.clearInterval(timer_posts);
3454
-                                gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3454
+                                gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3455 3455
                             } else {
3456 3456
                                 var percentage = Math.round(((page * chunk_size) / total_posts) * 100);
3457 3457
                                 percentage = percentage > 100 ? 100 : percentage;
3458
-                                gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3458
+                                gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3459 3459
                             }
3460 3460
                             if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3461 3461
                                 var obj_files = data.files;
@@ -3486,7 +3486,7 @@  discard block
 block discarded – undo
3486 3486
 
3487 3487
     function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
3488 3488
         if (page < 2) {
3489
-            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3489
+            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3490 3490
             jQuery(el).find('#gd_timer').text('00:00:01');
3491 3491
             jQuery('#gd_ie_ex_files', el).html('');
3492 3492
         }
@@ -3494,7 +3494,7 @@  discard block
 block discarded – undo
3494 3494
         jQuery.ajax({
3495 3495
             url: ajaxurl,
3496 3496
             type: "POST",
3497
-            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3497
+            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3498 3498
             dataType : 'json',
3499 3499
             cache: false,
3500 3500
             beforeSend: function (jqXHR, settings) {},
@@ -3508,11 +3508,11 @@  discard block
 block discarded – undo
3508 3508
                     } else {
3509 3509
                         if (pages < page || pages == page) {
3510 3510
                             window.clearInterval(timer_cats);
3511
-                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3511
+                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3512 3512
                         } else {
3513 3513
                             var percentage = Math.round(((page * chunk_size) / total_cats) * 100);
3514 3514
                             percentage = percentage > 100 ? 100 : percentage;
3515
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
3515
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
3516 3516
                         }
3517 3517
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3518 3518
                             var obj_files = data.files;
@@ -3569,13 +3569,13 @@  discard block
 block discarded – undo
3569 3569
 function geodir_init_filesystem()
3570 3570
 {
3571 3571
 
3572
-    if(!function_exists('get_filesystem_method')){
3572
+    if (!function_exists('get_filesystem_method')) {
3573 3573
         require_once(ABSPATH."/wp-admin/includes/file.php");
3574 3574
     }
3575 3575
     $access_type = get_filesystem_method();
3576 3576
     if ($access_type === 'direct') {
3577 3577
         /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3578
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3578
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3579 3579
 
3580 3580
         /* initialize the API */
3581 3581
         if (!WP_Filesystem($creds)) {
@@ -3588,7 +3588,7 @@  discard block
 block discarded – undo
3588 3588
         return $wp_filesystem;
3589 3589
         /* do our file manipulations below */
3590 3590
     } elseif (defined('FTP_USER')) {
3591
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3591
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3592 3592
 
3593 3593
         /* initialize the API */
3594 3594
         if (!WP_Filesystem($creds)) {
@@ -3623,7 +3623,7 @@  discard block
 block discarded – undo
3623 3623
  * @package GeoDirectory
3624 3624
  */
3625 3625
 function geodir_filesystem_notice()
3626
-{   if ( defined( 'DOING_AJAX' ) ){return;}
3626
+{   if (defined('DOING_AJAX')) {return; }
3627 3627
     $access_type = get_filesystem_method();
3628 3628
     if ($access_type === 'direct') {
3629 3629
     } elseif (!defined('FTP_USER')) {
@@ -3660,64 +3660,64 @@  discard block
 block discarded – undo
3660 3660
     // try to set higher limits for import
3661 3661
     $max_input_time = ini_get('max_input_time');
3662 3662
     $max_execution_time = ini_get('max_execution_time');
3663
-    $memory_limit= ini_get('memory_limit');
3663
+    $memory_limit = ini_get('memory_limit');
3664 3664
 
3665
-    if(!$max_input_time || $max_input_time<3000){
3665
+    if (!$max_input_time || $max_input_time < 3000) {
3666 3666
         ini_set('max_input_time', 3000);
3667 3667
     }
3668 3668
 
3669
-    if(!$max_execution_time || $max_execution_time<3000){
3669
+    if (!$max_execution_time || $max_execution_time < 3000) {
3670 3670
         ini_set('max_execution_time', 3000);
3671 3671
     }
3672 3672
 
3673
-    if($memory_limit && str_replace('M','',$memory_limit)){
3674
-        if(str_replace('M','',$memory_limit)<256){
3673
+    if ($memory_limit && str_replace('M', '', $memory_limit)) {
3674
+        if (str_replace('M', '', $memory_limit) < 256) {
3675 3675
             ini_set('memory_limit', '256M');
3676 3676
         }
3677 3677
     }
3678 3678
 
3679 3679
     $json = array();
3680 3680
 
3681
-    if ( !current_user_can( 'manage_options' ) ) {
3682
-        wp_send_json( $json );
3681
+    if (!current_user_can('manage_options')) {
3682
+        wp_send_json($json);
3683 3683
     }
3684 3684
 
3685
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3686
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3687
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3685
+    $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL;
3686
+    $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL;
3687
+    $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false;
3688 3688
 
3689
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3690
-        wp_send_json( $json );
3689
+    if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
3690
+        wp_send_json($json);
3691 3691
     }
3692 3692
 
3693
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3694
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3693
+    $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL;
3694
+    $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL;
3695 3695
     $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3696
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3696
+    $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1;
3697 3697
 
3698 3698
     $wp_filesystem = geodir_init_filesystem();
3699 3699
     if (!$wp_filesystem) {
3700
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3701
-        wp_send_json( $json );
3700
+        $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
3701
+        wp_send_json($json);
3702 3702
     }
3703 3703
 
3704 3704
     if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3705
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3706
-        wp_send_json( $json );
3705
+        $json['error'] = __('Filesystem ERROR: '.$wp_filesystem->errors->get_error_message(), 'geodirectory');
3706
+        wp_send_json($json);
3707 3707
     }
3708 3708
 
3709
-    $csv_file_dir = geodir_path_import_export( false );
3710
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3711
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3712
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3713
-            wp_send_json( $json );
3709
+    $csv_file_dir = geodir_path_import_export(false);
3710
+    if (!$wp_filesystem->is_dir($csv_file_dir)) {
3711
+        if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
3712
+            $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
3713
+            wp_send_json($json);
3714 3714
         }
3715 3715
     }
3716 3716
     
3717 3717
     $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3718 3718
     $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3719 3719
 
3720
-    switch ( $task ) {
3720
+    switch ($task) {
3721 3721
         case 'export_posts': {
3722 3722
             // WPML
3723 3723
             $is_wpml = geodir_is_wpml();
@@ -3728,36 +3728,36 @@  discard block
 block discarded – undo
3728 3728
                 $sitepress->switch_lang('all', true);
3729 3729
             }
3730 3730
             // WPML
3731
-            if ( $post_type == 'gd_event' ) {
3732
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3731
+            if ($post_type == 'gd_event') {
3732
+                add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
3733 3733
             }
3734
-            $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3734
+            $filters = !empty($_REQUEST['gd_imex']) && is_array($_REQUEST['gd_imex']) ? $_REQUEST['gd_imex'] : NULL;
3735 3735
             
3736
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3737
-            if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3738
-                $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3736
+            $file_name = $post_type.'_'.date('dmyHi');
3737
+            if ($filters && isset($filters['start_date']) && isset($filters['end_date'])) {
3738
+                $file_name = $post_type.'_'.date_i18n('dmy', strtotime($filters['start_date'])).'_'.date_i18n('dmy', strtotime($filters['end_date']));
3739 3739
             }
3740
-            $posts_count = geodir_get_posts_count( $post_type );
3741
-            $file_url_base = geodir_path_import_export() . '/';
3742
-            $file_url = $file_url_base . $file_name . '.csv';
3743
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3744
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3740
+            $posts_count = geodir_get_posts_count($post_type);
3741
+            $file_url_base = geodir_path_import_export().'/';
3742
+            $file_url = $file_url_base.$file_name.'.csv';
3743
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3744
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'_'.$nonce.'.csv';
3745 3745
             
3746 3746
             $chunk_file_paths = array();
3747 3747
 
3748
-            if ( isset( $_REQUEST['_c'] ) ) {
3748
+            if (isset($_REQUEST['_c'])) {
3749 3749
                 $json['total'] = $posts_count;
3750 3750
                 // WPML
3751 3751
                 if ($is_wpml) {
3752 3752
                     $sitepress->switch_lang($active_lang, true);
3753 3753
                 }
3754 3754
                 // WPML
3755
-                wp_send_json( $json );
3755
+                wp_send_json($json);
3756 3756
                 gd_die();
3757
-            } else if ( isset( $_REQUEST['_st'] ) ) {
3758
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3759
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3760
-                $percentage = min( $percentage, 100 );
3757
+            } else if (isset($_REQUEST['_st'])) {
3758
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3759
+                $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0;
3760
+                $percentage = min($percentage, 100);
3761 3761
                 
3762 3762
                 $json['percentage'] = $percentage;
3763 3763
                 // WPML
@@ -3765,45 +3765,45 @@  discard block
 block discarded – undo
3765 3765
                     $sitepress->switch_lang($active_lang, true);
3766 3766
                 }
3767 3767
                 // WPML
3768
-                wp_send_json( $json );
3768
+                wp_send_json($json);
3769 3769
                 gd_die();
3770 3770
             } else {
3771
-                if ( !$posts_count > 0 ) {
3772
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3771
+                if (!$posts_count > 0) {
3772
+                    $json['error'] = __('No records to export.', 'geodirectory');
3773 3773
                 } else {
3774 3774
                     $total_posts = $posts_count;
3775 3775
                     if ($chunk_per_page > $total_posts) {
3776 3776
                         $chunk_per_page = $total_posts;
3777 3777
                     }
3778
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3778
+                    $chunk_total_pages = ceil($total_posts / $chunk_per_page);
3779 3779
                     
3780 3780
                     $j = $chunk_page_no;
3781
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3781
+                    $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j);
3782 3782
                     
3783 3783
                     $per_page = 500;
3784 3784
                     if ($per_page > $chunk_per_page) {
3785 3785
                         $per_page = $chunk_per_page;
3786 3786
                     }
3787
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3787
+                    $total_pages = ceil($chunk_per_page / $per_page);
3788 3788
                     
3789
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3790
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3789
+                    for ($i = 0; $i <= $total_pages; $i++) {
3790
+                        $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page);
3791 3791
                         
3792 3792
                         $clear = $i == 0 ? true : false;
3793
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3793
+                        geodir_save_csv_data($file_path_temp, $save_posts, $clear);
3794 3794
                     }
3795 3795
                         
3796
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3797
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3798
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3799
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3800
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3796
+                    if ($wp_filesystem->exists($file_path_temp)) {
3797
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3798
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3799
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3800
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3801 3801
                         
3802
-                        $file_url = $file_url_base . $chunk_file_name;
3803
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3802
+                        $file_url = $file_url_base.$chunk_file_name;
3803
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3804 3804
                     }
3805 3805
                     
3806
-                    if ( !empty($chunk_file_paths) ) {
3806
+                    if (!empty($chunk_file_paths)) {
3807 3807
                         $json['total'] = $posts_count;
3808 3808
                         $json['files'] = $chunk_file_paths;
3809 3809
                     } else {
@@ -3811,7 +3811,7 @@  discard block
 block discarded – undo
3811 3811
                             $json['total'] = $posts_count;
3812 3812
                             $json['files'] = array();
3813 3813
                         } else {
3814
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3814
+                            $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3815 3815
                         }
3816 3816
                     }
3817 3817
                 }
@@ -3820,7 +3820,7 @@  discard block
 block discarded – undo
3820 3820
                     $sitepress->switch_lang($active_lang, true);
3821 3821
                 }
3822 3822
                 // WPML
3823
-                wp_send_json( $json );
3823
+                wp_send_json($json);
3824 3824
             }
3825 3825
         }
3826 3826
         break;
@@ -3834,20 +3834,20 @@  discard block
 block discarded – undo
3834 3834
                 $sitepress->switch_lang('all', true);
3835 3835
             }
3836 3836
             // WPML
3837
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3837
+            $file_name = $post_type.'category_'.date('dmyHi');
3838 3838
             
3839
-            $terms_count = geodir_get_terms_count( $post_type );
3840
-            $file_url_base = geodir_path_import_export() . '/';
3841
-            $file_url = $file_url_base . $file_name . '.csv';
3842
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3843
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3839
+            $terms_count = geodir_get_terms_count($post_type);
3840
+            $file_url_base = geodir_path_import_export().'/';
3841
+            $file_url = $file_url_base.$file_name.'.csv';
3842
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3843
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'category_'.$nonce.'.csv';
3844 3844
             
3845 3845
             $chunk_file_paths = array();
3846 3846
             
3847
-            if ( isset( $_REQUEST['_st'] ) ) {
3848
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3849
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3850
-                $percentage = min( $percentage, 100 );
3847
+            if (isset($_REQUEST['_st'])) {
3848
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3849
+                $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0;
3850
+                $percentage = min($percentage, 100);
3851 3851
                 
3852 3852
                 $json['percentage'] = $percentage;
3853 3853
                 // WPML
@@ -3855,48 +3855,48 @@  discard block
 block discarded – undo
3855 3855
                     $sitepress->switch_lang($active_lang, true);
3856 3856
                 }
3857 3857
                 // WPML
3858
-                wp_send_json( $json );
3858
+                wp_send_json($json);
3859 3859
             } else {
3860
-                if ( !$terms_count > 0 ) {
3861
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3860
+                if (!$terms_count > 0) {
3861
+                    $json['error'] = __('No records to export.', 'geodirectory');
3862 3862
                 } else {
3863 3863
                     $total_terms = $terms_count;
3864 3864
                     if ($chunk_per_page > $terms_count) {
3865 3865
                         $chunk_per_page = $terms_count;
3866 3866
                     }
3867
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3867
+                    $chunk_total_pages = ceil($total_terms / $chunk_per_page);
3868 3868
                     
3869 3869
                     $j = $chunk_page_no;
3870
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3870
+                    $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j);
3871 3871
                     
3872 3872
                     $per_page = 500;
3873 3873
                     if ($per_page > $chunk_per_page) {
3874 3874
                         $per_page = $chunk_per_page;
3875 3875
                     }
3876
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3876
+                    $total_pages = ceil($chunk_per_page / $per_page);
3877 3877
                     
3878
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3879
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3878
+                    for ($i = 0; $i <= $total_pages; $i++) {
3879
+                        $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page);
3880 3880
                         
3881 3881
                         $clear = $i == 0 ? true : false;
3882
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3882
+                        geodir_save_csv_data($file_path_temp, $save_terms, $clear);
3883 3883
                     }
3884 3884
                     
3885
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3886
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3887
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3888
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3889
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3885
+                    if ($wp_filesystem->exists($file_path_temp)) {
3886
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3887
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3888
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3889
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3890 3890
                         
3891
-                        $file_url = $file_url_base . $chunk_file_name;
3892
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3891
+                        $file_url = $file_url_base.$chunk_file_name;
3892
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3893 3893
                     }
3894 3894
                     
3895
-                    if ( !empty($chunk_file_paths) ) {
3895
+                    if (!empty($chunk_file_paths)) {
3896 3896
                         $json['total'] = $terms_count;
3897 3897
                         $json['files'] = $chunk_file_paths;
3898 3898
                     } else {
3899
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3899
+                        $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3900 3900
                     }
3901 3901
                 }
3902 3902
                 // WPML
@@ -3904,127 +3904,127 @@  discard block
 block discarded – undo
3904 3904
                     $sitepress->switch_lang($active_lang, true);
3905 3905
                 }
3906 3906
                 // WPML
3907
-                wp_send_json( $json );
3907
+                wp_send_json($json);
3908 3908
             }
3909 3909
         }
3910 3910
         break;
3911 3911
         case 'export_locations': {
3912
-            $file_url_base = geodir_path_import_export() . '/';
3913
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3914
-            $file_url = $file_url_base . $file_name . '.csv';
3915
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3916
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3912
+            $file_url_base = geodir_path_import_export().'/';
3913
+            $file_name = 'gd_locations_'.date('dmyHi');
3914
+            $file_url = $file_url_base.$file_name.'.csv';
3915
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3916
+            $file_path_temp = $csv_file_dir.'/gd_locations_'.$nonce.'.csv';
3917 3917
             
3918
-            $items_count = (int)geodir_location_imex_count_locations();
3918
+            $items_count = (int) geodir_location_imex_count_locations();
3919 3919
             
3920
-            if ( isset( $_REQUEST['_st'] ) ) {
3921
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3922
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3923
-                $percentage = min( $percentage, 100 );
3920
+            if (isset($_REQUEST['_st'])) {
3921
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3922
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3923
+                $percentage = min($percentage, 100);
3924 3924
                 
3925 3925
                 $json['percentage'] = $percentage;
3926
-                wp_send_json( $json );
3926
+                wp_send_json($json);
3927 3927
             } else {
3928 3928
                 $chunk_file_paths = array();
3929 3929
                 
3930
-                if ( !$items_count > 0 ) {
3931
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3930
+                if (!$items_count > 0) {
3931
+                    $json['error'] = __('No records to export.', 'geodirectory');
3932 3932
                 } else {
3933
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3934
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3933
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3934
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3935 3935
                     
3936 3936
                     $j = $chunk_page_no;
3937
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3937
+                    $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j);
3938 3938
                     
3939 3939
                     $per_page = 500;
3940
-                    $per_page = min( $per_page, $chunk_per_page );
3941
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3940
+                    $per_page = min($per_page, $chunk_per_page);
3941
+                    $total_pages = ceil($chunk_per_page / $per_page);
3942 3942
                     
3943
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3944
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3943
+                    for ($i = 0; $i <= $total_pages; $i++) {
3944
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3945 3945
                         
3946 3946
                         $clear = $i == 0 ? true : false;
3947
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3947
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3948 3948
                     }
3949 3949
                     
3950
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3951
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3952
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3953
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3954
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3950
+                    if ($wp_filesystem->exists($file_path_temp)) {
3951
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3952
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3953
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3954
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3955 3955
                         
3956
-                        $file_url = $file_url_base . $chunk_file_name;
3957
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3956
+                        $file_url = $file_url_base.$chunk_file_name;
3957
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3958 3958
                     }
3959 3959
                     
3960
-                    if ( !empty($chunk_file_paths) ) {
3960
+                    if (!empty($chunk_file_paths)) {
3961 3961
                         $json['total'] = $items_count;
3962 3962
                         $json['files'] = $chunk_file_paths;
3963 3963
                     } else {
3964
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3964
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3965 3965
                     }
3966 3966
                 }
3967
-                wp_send_json( $json );
3967
+                wp_send_json($json);
3968 3968
             }
3969 3969
         }
3970 3970
         break;
3971 3971
         case 'export_hoods': {
3972
-            $file_url_base = geodir_path_import_export() . '/';
3973
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3974
-            $file_url = $file_url_base . $file_name . '.csv';
3975
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3976
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3972
+            $file_url_base = geodir_path_import_export().'/';
3973
+            $file_name = 'gd_neighbourhoods_'.date('dmyHi');
3974
+            $file_url = $file_url_base.$file_name.'.csv';
3975
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3976
+            $file_path_temp = $csv_file_dir.'/gd_neighbourhoods_'.$nonce.'.csv';
3977 3977
             
3978
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3978
+            $items_count = (int) geodir_location_imex_count_neighbourhoods();
3979 3979
             
3980
-            if ( isset( $_REQUEST['_st'] ) ) {
3981
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3982
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3983
-                $percentage = min( $percentage, 100 );
3980
+            if (isset($_REQUEST['_st'])) {
3981
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3982
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3983
+                $percentage = min($percentage, 100);
3984 3984
                 
3985 3985
                 $json['percentage'] = $percentage;
3986
-                wp_send_json( $json );
3986
+                wp_send_json($json);
3987 3987
             } else {
3988 3988
                 $chunk_file_paths = array();
3989 3989
                 
3990
-                if ( !$items_count > 0 ) {
3991
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3990
+                if (!$items_count > 0) {
3991
+                    $json['error'] = __('No records to export.', 'geodirectory');
3992 3992
                 } else {
3993
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3994
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3993
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3994
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3995 3995
                     
3996 3996
                     $j = $chunk_page_no;
3997
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3997
+                    $chunk_save_items = geodir_location_imex_neighbourhoods_data($chunk_per_page, $j);
3998 3998
                     
3999 3999
                     $per_page = 500;
4000
-                    $per_page = min( $per_page, $chunk_per_page );
4001
-                    $total_pages = ceil( $chunk_per_page / $per_page );
4000
+                    $per_page = min($per_page, $chunk_per_page);
4001
+                    $total_pages = ceil($chunk_per_page / $per_page);
4002 4002
                     
4003
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
4004
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
4003
+                    for ($i = 0; $i <= $total_pages; $i++) {
4004
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
4005 4005
                         
4006 4006
                         $clear = $i == 0 ? true : false;
4007
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
4007
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
4008 4008
                     }
4009 4009
                     
4010
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
4011
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
4012
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
4013
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
4014
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
4010
+                    if ($wp_filesystem->exists($file_path_temp)) {
4011
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
4012
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
4013
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
4014
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
4015 4015
                         
4016
-                        $file_url = $file_url_base . $chunk_file_name;
4017
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4016
+                        $file_url = $file_url_base.$chunk_file_name;
4017
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
4018 4018
                     }
4019 4019
                     
4020
-                    if ( !empty($chunk_file_paths) ) {
4020
+                    if (!empty($chunk_file_paths)) {
4021 4021
                         $json['total'] = $items_count;
4022 4022
                         $json['files'] = $chunk_file_paths;
4023 4023
                     } else {
4024
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
4024
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
4025 4025
                     }
4026 4026
                 }
4027
-                wp_send_json( $json );
4027
+                wp_send_json($json);
4028 4028
             }
4029 4029
         }
4030 4030
         break;
@@ -4041,25 +4041,25 @@  discard block
 block discarded – undo
4041 4041
             }
4042 4042
             // WPML
4043 4043
             
4044
-            ini_set( 'auto_detect_line_endings', true );
4044
+            ini_set('auto_detect_line_endings', true);
4045 4045
             
4046 4046
             $uploads = wp_upload_dir();
4047 4047
             $uploads_dir = $uploads['path'];
4048 4048
             $uploads_subdir = $uploads['subdir'];
4049 4049
             
4050
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
4051
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
4050
+            $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL;
4051
+            $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip';
4052 4052
             
4053
-            $csv_file_arr = explode( '/', $csv_file );
4054
-            $csv_filename = end( $csv_file_arr );
4055
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
4053
+            $csv_file_arr = explode('/', $csv_file);
4054
+            $csv_filename = end($csv_file_arr);
4055
+            $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$csv_filename;
4056 4056
             
4057 4057
             $json['file'] = $csv_file;
4058
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4058
+            $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
4059 4059
             $file = array();
4060 4060
 
4061
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4062
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4061
+            if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
4062
+                $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename);
4063 4063
                 
4064 4064
                 if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4065 4065
                     $json['error'] = NULL;
@@ -4067,9 +4067,9 @@  discard block
 block discarded – undo
4067 4067
                     
4068 4068
                     $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
4069 4069
                     setlocale(LC_ALL, 'en_US.UTF-8');
4070
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4071
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4072
-                            if ( !empty( $data ) ) {
4070
+                    if (($handle = fopen($target_path, "r")) !== FALSE) {
4071
+                        while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
4072
+                            if (!empty($data)) {
4073 4073
                                 $file[] = $data;
4074 4074
                             }
4075 4075
                         }
@@ -4083,19 +4083,19 @@  discard block
 block discarded – undo
4083 4083
                         $json['error'] = __('No data found in csv file.', 'geodirectory');
4084 4084
                     }
4085 4085
                 } else {
4086
-                    wp_send_json( $json );
4086
+                    wp_send_json($json);
4087 4087
                 }
4088 4088
             } else {
4089
-                wp_send_json( $json );
4089
+                wp_send_json($json);
4090 4090
             }
4091 4091
             
4092
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4093
-                wp_send_json( $json );
4092
+            if ($task == 'prepare_import' || !empty($json['error'])) {
4093
+                wp_send_json($json);
4094 4094
             }
4095 4095
             
4096 4096
             $total = $json['rows'];
4097
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4098
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4097
+            $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1;
4098
+            $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0;
4099 4099
             
4100 4100
             $count = $limit;
4101 4101
             
@@ -4120,13 +4120,13 @@  discard block
 block discarded – undo
4120 4120
             
4121 4121
             $post_types = geodir_get_posttypes();
4122 4122
 
4123
-            if ( $task == 'import_cat' ) {
4123
+            if ($task == 'import_cat') {
4124 4124
                 if (!empty($file)) {
4125 4125
                     $columns = isset($file[0]) ? $file[0] : NULL;
4126 4126
                     
4127 4127
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4128 4128
                         $json['error'] = CSV_INVAILD_FILE;
4129
-                        wp_send_json( $json );
4129
+                        wp_send_json($json);
4130 4130
                         exit;
4131 4131
                     }
4132 4132
                     
@@ -4137,7 +4137,7 @@  discard block
 block discarded – undo
4137 4137
                         
4138 4138
                         if (isset($file[$index])) {
4139 4139
                             $row = $file[$index];
4140
-                            $row = array_map( 'trim', $row );
4140
+                            $row = array_map('trim', $row);
4141 4141
                             //$row = array_map( 'utf8_encode', $row );
4142 4142
                             
4143 4143
                             $cat_id = '';
@@ -4154,42 +4154,42 @@  discard block
 block discarded – undo
4154 4154
                             $cat_id_original = '';
4155 4155
                             
4156 4156
                             $c = 0;
4157
-                            foreach ($columns as $column ) {
4158
-                                if ( $column == 'cat_id' ) {
4159
-                                    $cat_id = (int)$row[$c];
4160
-                                } else if ( $column == 'cat_name' ) {
4157
+                            foreach ($columns as $column) {
4158
+                                if ($column == 'cat_id') {
4159
+                                    $cat_id = (int) $row[$c];
4160
+                                } else if ($column == 'cat_name') {
4161 4161
                                     $cat_name = $row[$c];
4162
-                                } else if ( $column == 'cat_slug' ) {
4162
+                                } else if ($column == 'cat_slug') {
4163 4163
                                     $cat_slug = $row[$c];
4164
-                                } else if ( $column == 'cat_posttype' ) {
4164
+                                } else if ($column == 'cat_posttype') {
4165 4165
                                     $cat_posttype = $row[$c];
4166
-                                } else if ( $column == 'cat_parent' ) {
4166
+                                } else if ($column == 'cat_parent') {
4167 4167
                                     $cat_parent = trim($row[$c]);
4168
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4168
+                                } else if ($column == 'cat_schema' && $row[$c] != '') {
4169 4169
                                     $cat_schema = $row[$c];
4170
-                                } else if ( $column == 'cat_description' ) {
4170
+                                } else if ($column == 'cat_description') {
4171 4171
                                     $cat_description = $row[$c];
4172
-                                } else if ( $column == 'cat_top_description' ) {
4172
+                                } else if ($column == 'cat_top_description') {
4173 4173
                                     $cat_top_description = $row[$c];
4174
-                                } else if ( $column == 'cat_image' ) {
4174
+                                } else if ($column == 'cat_image') {
4175 4175
                                     $cat_image = $row[$c];
4176
-                                } else if ( $column == 'cat_icon' ) {
4176
+                                } else if ($column == 'cat_icon') {
4177 4177
                                     $cat_icon = $row[$c];
4178 4178
                                 }
4179 4179
                                 // WPML
4180
-                                if ( $is_wpml ) {
4181
-                                    if ( $column == 'cat_language' ) {
4182
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
4183
-                                    } else if ( $column == 'cat_id_original' ) {
4184
-                                        $cat_id_original = (int)$row[$c];
4180
+                                if ($is_wpml) {
4181
+                                    if ($column == 'cat_language') {
4182
+                                        $cat_language = geodir_strtolower(trim($row[$c]));
4183
+                                    } else if ($column == 'cat_id_original') {
4184
+                                        $cat_id_original = (int) $row[$c];
4185 4185
                                     }
4186 4186
                                 }
4187 4187
                                 // WPML
4188 4188
                                 $c++;
4189 4189
                             }
4190 4190
                             
4191
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4192
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4191
+                            if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
4192
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
4193 4193
                                 
4194 4194
                                 $invalid++;
4195 4195
                                 continue;
@@ -4207,24 +4207,24 @@  discard block
 block discarded – undo
4207 4207
                             $term_data['description'] = $cat_description;
4208 4208
                             $term_data['cat_schema'] = $cat_schema;
4209 4209
                             $term_data['top_description'] = $cat_top_description;
4210
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4211
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4210
+                            $term_data['image'] = $cat_image != '' ? basename($cat_image) : '';
4211
+                            $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : '';
4212 4212
                             
4213 4213
                             //$term_data = array_map( 'utf8_encode', $term_data );
4214 4214
                             
4215
-                            $taxonomy = $cat_posttype . 'category';
4215
+                            $taxonomy = $cat_posttype.'category';
4216 4216
                             
4217 4217
                             $term_data['taxonomy'] = $taxonomy;
4218 4218
 
4219 4219
                             $term_parent_id = 0;
4220
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4220
+                            if ($cat_parent != "" || (int) $cat_parent > 0) {
4221 4221
                                 $term_parent = '';
4222 4222
                                 
4223
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4223
+                                if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
4224 4224
                                     //
4225
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4225
+                                } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
4226 4226
                                     //
4227
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4227
+                                } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
4228 4228
                                     //
4229 4229
                                 } else {
4230 4230
                                     $term_parent_data = array();
@@ -4232,104 +4232,104 @@  discard block
 block discarded – undo
4232 4232
                                     //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4233 4233
                                     $term_parent_data['taxonomy'] = $taxonomy;
4234 4234
                                     
4235
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4235
+                                    $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data);
4236 4236
                                 }
4237 4237
                                 
4238
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4239
-                                    $term_parent_id = (int)$term_parent->term_id;
4238
+                                if (!empty($term_parent) && !is_wp_error($term_parent)) {
4239
+                                    $term_parent_id = (int) $term_parent->term_id;
4240 4240
                                 }
4241 4241
                             }
4242
-                            $term_data['parent'] = (int)$term_parent_id;
4242
+                            $term_data['parent'] = (int) $term_parent_id;
4243 4243
 
4244 4244
                             $term_id = NULL;
4245
-                            if ( $import_choice == 'update' ) {
4246
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4245
+                            if ($import_choice == 'update') {
4246
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4247 4247
                                     $term_data['term_id'] = $term['term_id'];
4248 4248
                                     
4249
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4249
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4250 4250
                                         $updated++;
4251 4251
                                     } else {
4252 4252
                                         $invalid++;
4253
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4253
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
4254 4254
                                     }
4255
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4255
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4256 4256
                                     $term_data['term_id'] = $term['term_id'];
4257 4257
                                     
4258
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4258
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4259 4259
                                         $updated++;
4260 4260
                                     } else {
4261 4261
                                         $invalid++;
4262
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4262
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
4263 4263
                                     }
4264 4264
                                 } else {
4265
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4265
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
4266 4266
                                         $created++;
4267 4267
                                     } else {
4268 4268
                                         $invalid++;
4269
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4269
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
4270 4270
                                     }
4271 4271
                                 }
4272
-                            } else if ( $import_choice == 'skip' ) {
4273
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4272
+                            } else if ($import_choice == 'skip') {
4273
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4274 4274
                                     $skipped++;
4275
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4275
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4276 4276
                                     $skipped++;
4277 4277
                                 } else {
4278
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4278
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
4279 4279
                                         $created++;
4280 4280
                                     } else {
4281 4281
                                         $invalid++;
4282
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4282
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
4283 4283
                                     }
4284 4284
                                 }
4285 4285
                             } else {
4286 4286
                                 $invalid++;
4287
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
4287
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
4288 4288
                             }
4289 4289
                             
4290
-                            if ( $term_id ) {
4290
+                            if ($term_id) {
4291 4291
                                 // WPML
4292 4292
                                 if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4293
-                                    $wpml_element_type = 'tax_' . $taxonomy;
4294
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4293
+                                    $wpml_element_type = 'tax_'.$taxonomy;
4294
+                                    $source_language = geodir_get_language_for_element($cat_id_original, $wpml_element_type);
4295 4295
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4296 4296
 
4297
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4297
+                                    $trid = $sitepress->get_element_trid($cat_id_original, $wpml_element_type);
4298 4298
                                     
4299
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4299
+                                    $sitepress->set_element_language_details($term_id, $wpml_element_type, $trid, $cat_language, $source_language);
4300 4300
                                 }
4301 4301
                                 // WPML
4302 4302
                                 
4303
-                                if ( isset( $term_data['top_description'] ) ) {
4304
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4303
+                                if (isset($term_data['top_description'])) {
4304
+                                    update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype);
4305 4305
                                 }
4306 4306
                                 
4307
-                                if ( isset( $term_data['cat_schema'] ) ) {
4308
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4307
+                                if (isset($term_data['cat_schema'])) {
4308
+                                    update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype);
4309 4309
                                 }
4310 4310
             
4311 4311
                                 $attachment = false;
4312
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4313
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4314
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4312
+                                if (isset($term_data['image']) && $term_data['image'] != '') {
4313
+                                    $cat_image = geodir_get_default_catimage($term_id, $cat_posttype);
4314
+                                    $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : '';
4315 4315
                                     
4316
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4316
+                                    if (basename($cat_image) != $term_data['image']) {
4317 4317
                                         $attachment = true;
4318
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4318
+                                        update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'].'/'.$term_data['image']), $cat_posttype);
4319 4319
                                     }
4320 4320
                                 }
4321 4321
                                 
4322
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4323
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4324
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4322
+                                if (isset($term_data['icon']) && $term_data['icon'] != '') {
4323
+                                    $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype);
4324
+                                    $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
4325 4325
                                         
4326
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4326
+                                    if (basename($cat_icon) != $term_data['icon']) {
4327 4327
                                         $attachment = true;
4328
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4328
+                                        update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'].'/'.$term_data['icon']), $cat_posttype);
4329 4329
                                     }
4330 4330
                                 }
4331 4331
                                 
4332
-                                if ( $attachment ) {
4332
+                                if ($attachment) {
4333 4333
                                     $images++;
4334 4334
                                 }
4335 4335
                             }
@@ -4351,34 +4351,34 @@  discard block
 block discarded – undo
4351 4351
                 $json['invalid'] = $invalid;
4352 4352
                 $json['images'] = $images;
4353 4353
                 
4354
-                wp_send_json( $json );
4354
+                wp_send_json($json);
4355 4355
                 exit;
4356
-            } else if ( $task == 'import_post' ) {
4356
+            } else if ($task == 'import_post') {
4357 4357
                 //run some stuff to make the import quicker
4358
-                wp_defer_term_counting( true );
4359
-                wp_defer_comment_counting( true );
4360
-                $wpdb->query( 'SET autocommit = 0;' );
4358
+                wp_defer_term_counting(true);
4359
+                wp_defer_comment_counting(true);
4360
+                $wpdb->query('SET autocommit = 0;');
4361 4361
 
4362 4362
                 //remove_all_actions('publish_post');
4363 4363
                 //remove_all_actions('transition_post_status');
4364 4364
                 //remove_all_actions('publish_future_post');
4365 4365
 
4366 4366
                 if (!empty($file)) {
4367
-                    $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4367
+                    $is_claim_active = is_plugin_active('geodir_claim_listing/geodir_claim_listing.php') && get_option('geodir_claim_enable') === 'yes' ? true : false;
4368 4368
                     $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4369 4369
                     $default_status = 'publish';
4370
-                    $current_date = date_i18n( 'Y-m-d', time() );
4370
+                    $current_date = date_i18n('Y-m-d', time());
4371 4371
                     
4372 4372
                     $columns = isset($file[0]) ? $file[0] : NULL;
4373 4373
                     
4374 4374
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4375 4375
                         $json['error'] = CSV_INVAILD_FILE;
4376
-                        wp_send_json( $json );
4376
+                        wp_send_json($json);
4377 4377
                         exit;
4378 4378
                     }
4379 4379
 
4380 4380
                     $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4381
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4381
+                    $wp_chars_error = __('(check & remove if any invalid characters used in data)', 'geodirectory');
4382 4382
                     $processed_actual = 0;
4383 4383
                     for ($i = 1; $i <= $limit; $i++) {
4384 4384
                         $index = $processed + $i;
@@ -4387,9 +4387,9 @@  discard block
 block discarded – undo
4387 4387
                         if (isset($file[$index])) {
4388 4388
                             $processed_actual++;
4389 4389
                             $row = $file[$index];
4390
-                            $row = array_map( 'trim', $row );
4390
+                            $row = array_map('trim', $row);
4391 4391
                             //$row = array_map( 'utf8_encode', $row );
4392
-                            $row = array_map( 'addslashes_gpc', $row );
4392
+                            $row = array_map('addslashes_gpc', $row);
4393 4393
                             
4394 4394
                             $post_id = '';
4395 4395
                             $post_title = '';
@@ -4426,78 +4426,78 @@  discard block
 block discarded – undo
4426 4426
                             $original_post_id = '';
4427 4427
                             
4428 4428
                             $c = 0;
4429
-                            foreach ($columns as $column ) {
4429
+                            foreach ($columns as $column) {
4430 4430
                                 $gd_post[$column] = $row[$c];
4431 4431
                                 
4432
-                                if ( $column == 'post_id' ) {
4432
+                                if ($column == 'post_id') {
4433 4433
                                     $post_id = $row[$c];
4434
-                                } else if ( $column == 'post_title' ) {
4434
+                                } else if ($column == 'post_title') {
4435 4435
                                     $post_title = sanitize_text_field($row[$c]);
4436
-                                } else if ( $column == 'post_author' ) {
4436
+                                } else if ($column == 'post_author') {
4437 4437
                                     $post_author = $row[$c];
4438
-                                } else if ( $column == 'post_content' ) {
4438
+                                } else if ($column == 'post_content') {
4439 4439
                                     $post_content = $row[$c];
4440
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4441
-                                    $post_category_arr = explode( ',', $row[$c] );
4442
-                                } else if ( $column == 'default_category' ) {
4440
+                                } else if ($column == 'post_category' && $row[$c] != '') {
4441
+                                    $post_category_arr = explode(',', $row[$c]);
4442
+                                } else if ($column == 'default_category') {
4443 4443
                                     $default_category = wp_kses_normalize_entities($row[$c]);
4444
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4445
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4446
-                                } else if ( $column == 'post_type' ) {
4444
+                                } else if ($column == 'post_tags' && $row[$c] != '') {
4445
+                                    $post_tags = explode(',', sanitize_text_field($row[$c]));
4446
+                                } else if ($column == 'post_type') {
4447 4447
                                     $post_type = $row[$c];
4448
-                                } else if ( $column == 'post_status' ) {
4449
-                                    $post_status = sanitize_key( $row[$c] );
4450
-                                } else if ( $column == 'is_featured' ) {
4451
-                                    $is_featured = (int)$row[$c];
4452
-                                } else if ( $column == 'geodir_video' ) {
4448
+                                } else if ($column == 'post_status') {
4449
+                                    $post_status = sanitize_key($row[$c]);
4450
+                                } else if ($column == 'is_featured') {
4451
+                                    $is_featured = (int) $row[$c];
4452
+                                } else if ($column == 'geodir_video') {
4453 4453
                                     $geodir_video = $row[$c];
4454
-                                } else if ( $column == 'post_address' ) {
4454
+                                } else if ($column == 'post_address') {
4455 4455
                                     $post_address = sanitize_text_field($row[$c]);
4456
-                                } else if ( $column == 'post_city' ) {
4456
+                                } else if ($column == 'post_city') {
4457 4457
                                     $post_city = sanitize_text_field($row[$c]);
4458
-                                } else if ( $column == 'post_region' ) {
4458
+                                } else if ($column == 'post_region') {
4459 4459
                                     $post_region = sanitize_text_field($row[$c]);
4460
-                                } else if ( $column == 'post_country' ) {
4460
+                                } else if ($column == 'post_country') {
4461 4461
                                     $post_country = sanitize_text_field($row[$c]);
4462
-                                } else if ( $column == 'post_zip' ) {
4462
+                                } else if ($column == 'post_zip') {
4463 4463
                                     $post_zip = sanitize_text_field($row[$c]);
4464
-                                } else if ( $column == 'post_latitude' ) {
4464
+                                } else if ($column == 'post_latitude') {
4465 4465
                                     $post_latitude = sanitize_text_field($row[$c]);
4466
-                                } else if ( $column == 'post_longitude' ) {
4466
+                                } else if ($column == 'post_longitude') {
4467 4467
                                     $post_longitude = sanitize_text_field($row[$c]);
4468
-                                } else if ( $column == 'post_neighbourhood' ) {
4468
+                                } else if ($column == 'post_neighbourhood') {
4469 4469
                                     $post_neighbourhood = sanitize_text_field($row[$c]);
4470 4470
                                     unset($gd_post[$column]);
4471
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4471
+                                } else if ($column == 'neighbourhood_latitude') {
4472 4472
                                     $neighbourhood_latitude = sanitize_text_field($row[$c]);
4473
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4473
+                                } else if ($column == 'neighbourhood_longitude') {
4474 4474
                                     $neighbourhood_longitude = sanitize_text_field($row[$c]);
4475
-                                } else if ( $column == 'geodir_timing' ) {
4475
+                                } else if ($column == 'geodir_timing') {
4476 4476
                                     $geodir_timing = sanitize_text_field($row[$c]);
4477
-                                } else if ( $column == 'geodir_contact' ) {
4477
+                                } else if ($column == 'geodir_contact') {
4478 4478
                                     $geodir_contact = sanitize_text_field($row[$c]);
4479
-                                } else if ( $column == 'geodir_email' ) {
4479
+                                } else if ($column == 'geodir_email') {
4480 4480
                                     $geodir_email = sanitize_email($row[$c]);
4481
-                                } else if ( $column == 'geodir_website' ) {
4481
+                                } else if ($column == 'geodir_website') {
4482 4482
                                     $geodir_website = sanitize_text_field($row[$c]);
4483
-                                } else if ( $column == 'geodir_twitter' ) {
4483
+                                } else if ($column == 'geodir_twitter') {
4484 4484
                                     $geodir_twitter = sanitize_text_field($row[$c]);
4485
-                                } else if ( $column == 'geodir_facebook' ) {
4485
+                                } else if ($column == 'geodir_facebook') {
4486 4486
                                     $geodir_facebook = sanitize_text_field($row[$c]);
4487
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4487
+                                } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
4488 4488
                                     $post_images[] = $row[$c];
4489
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4490
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4491
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4489
+                                } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
4490
+                                    $expire_date = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $row[$c].' days'));
4491
+                                } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
4492 4492
                                     $row[$c] = str_replace('/', '-', $row[$c]);
4493
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4493
+                                    $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
4494 4494
                                 }
4495 4495
                                 // WPML
4496 4496
                                 if ($is_wpml) {
4497 4497
                                     if ($column == 'language') {
4498 4498
                                         $language = geodir_strtolower(trim($row[$c]));
4499 4499
                                     } else if ($column == 'original_post_id') {
4500
-                                        $original_post_id = (int)$row[$c];
4500
+                                        $original_post_id = (int) $row[$c];
4501 4501
                                     }
4502 4502
                                 }
4503 4503
                                 // WPML
@@ -4505,7 +4505,7 @@  discard block
 block discarded – undo
4505 4505
                             }
4506 4506
                             // listing claimed or not
4507 4507
                             if ($is_claim_active && isset($gd_post['claimed'])) {
4508
-                                $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4508
+                                $gd_post['claimed'] = (int) $gd_post['claimed'] == 1 ? 1 : 0;
4509 4509
                             }
4510 4510
                             
4511 4511
                             // WPML
@@ -4516,43 +4516,43 @@  discard block
 block discarded – undo
4516 4516
 
4517 4517
                             $gd_post['IMAGE'] = $post_images;
4518 4518
                             
4519
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4520
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4519
+                            $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
4520
+                            $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
4521 4521
                                                                                                                 
4522 4522
                             $valid = true;
4523 4523
                             
4524
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4524
+                            if ($post_title == '' || !in_array($post_type, $post_types)) {
4525 4525
                                 $invalid++;
4526 4526
                                 $valid = false;
4527
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4527
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
4528 4528
                             }
4529 4529
                             
4530
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4531
-                            if ( $location_allowed ) {
4530
+                            $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
4531
+                            if ($location_allowed) {
4532 4532
                                 $location_result = geodir_get_default_location();
4533
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4533
+                                if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
4534 4534
                                     $invalid_addr++;
4535 4535
                                     $valid = false;
4536
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4537
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4538
-                                    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 ) ) ) {
4536
+                                    geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'));
4537
+                                } else if (!empty($location_result) && $location_result->location_id == 0) {
4538
+                                    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))) {
4539 4539
                                         $invalid_addr++;
4540 4540
                                         $valid = false;
4541
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4541
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'));
4542 4542
                                     } else {
4543 4543
                                         if (!$location_manager) {
4544
-                                            $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.
4544
+                                            $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.
4545 4545
                                         }
4546 4546
                                     }
4547 4547
                                 }
4548 4548
                             }
4549 4549
                             
4550
-                            if ( !$valid ) {
4550
+                            if (!$valid) {
4551 4551
                                 continue;
4552 4552
                             }
4553 4553
 
4554
-                            $cat_taxonomy = $post_type . 'category';
4555
-                            $tags_taxonomy = $post_type . '_tags';
4554
+                            $cat_taxonomy = $post_type.'category';
4555
+                            $tags_taxonomy = $post_type.'_tags';
4556 4556
                             
4557 4557
                             if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4558 4558
                                 $post_category_arr = array_merge(array($default_category), $post_category_arr);
@@ -4560,29 +4560,29 @@  discard block
 block discarded – undo
4560 4560
 
4561 4561
                             $post_category = array();
4562 4562
                             $default_category_id = NULL;
4563
-                            if ( !empty( $post_category_arr ) ) {
4564
-                                foreach ( $post_category_arr as $value ) {
4565
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4563
+                            if (!empty($post_category_arr)) {
4564
+                                foreach ($post_category_arr as $value) {
4565
+                                    $category_name = wp_kses_normalize_entities(trim($value));
4566 4566
                                     
4567
-                                    if ( $category_name != '' ) {
4567
+                                    if ($category_name != '') {
4568 4568
                                         $term_category = array();
4569 4569
                                         
4570
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4570
+                                        if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
4571 4571
                                             $term_category = $term;
4572
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4572
+                                        } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
4573 4573
                                             $term_category = $term;
4574 4574
                                         } else {
4575 4575
                                             $term_data = array();
4576 4576
                                             $term_data['name'] = $category_name;
4577 4577
                                             $term_data['taxonomy'] = $cat_taxonomy;
4578 4578
                                             
4579
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4580
-                                            if ( $term_id ) {
4581
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4579
+                                            $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data);
4580
+                                            if ($term_id) {
4581
+                                                $term_category = get_term($term_id, $cat_taxonomy);
4582 4582
                                             }
4583 4583
                                         }
4584 4584
                                         
4585
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4585
+                                        if (!empty($term_category) && !is_wp_error($term_category)) {
4586 4586
                                             $post_category[] = intval($term_category->term_id);
4587 4587
                                             
4588 4588
                                             if ($category_name == $default_category) {
@@ -4603,15 +4603,15 @@  discard block
 block discarded – undo
4603 4603
                             $save_post['post_tags'] = $post_tags;
4604 4604
 
4605 4605
                             $saved_post_id = NULL;
4606
-                            if ( $import_choice == 'update' ) {
4607
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4606
+                            if ($import_choice == 'update') {
4607
+                                $gd_wp_error = __('Unable to add listing, please check the listing data.', 'geodirectory');
4608 4608
                                 
4609
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4609
+                                if ($post_id > 0 && get_post($post_id)) {
4610 4610
                                     $save_post['ID'] = $post_id;
4611 4611
                                     
4612
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4613
-                                        if ( is_wp_error( $saved_post_id ) ) {
4614
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4612
+                                    if ($saved_post_id = wp_update_post($save_post, true)) {
4613
+                                        if (is_wp_error($saved_post_id)) {
4614
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4615 4615
                                             $saved_post_id = 0;
4616 4616
                                         } else {
4617 4617
                                             $saved_post_id = $post_id;
@@ -4619,9 +4619,9 @@  discard block
 block discarded – undo
4619 4619
                                         }
4620 4620
                                     }
4621 4621
                                 } else {
4622
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4623
-                                        if ( is_wp_error( $saved_post_id ) ) {
4624
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4622
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4623
+                                        if (is_wp_error($saved_post_id)) {
4624
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4625 4625
                                             $saved_post_id = 0;
4626 4626
                                         } else {
4627 4627
                                             $created++;
@@ -4629,19 +4629,19 @@  discard block
 block discarded – undo
4629 4629
                                     }
4630 4630
                                 }
4631 4631
                                 
4632
-                                if ( !$saved_post_id > 0 ) {
4632
+                                if (!$saved_post_id > 0) {
4633 4633
                                     $invalid++;
4634
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4634
+                                    geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_wp_error);
4635 4635
                                 }
4636
-                            } else if ( $import_choice == 'skip' ) {
4637
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4636
+                            } else if ($import_choice == 'skip') {
4637
+                                if ($post_id > 0 && get_post($post_id)) {
4638 4638
                                     $skipped++;	
4639 4639
                                 } else {
4640
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4641
-                                        if ( is_wp_error( $saved_post_id ) ) {
4640
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4641
+                                        if (is_wp_error($saved_post_id)) {
4642 4642
                                             $invalid++;
4643 4643
                                             
4644
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4644
+                                            geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$saved_post_id->get_error_message().' '.$wp_chars_error);
4645 4645
                                             $saved_post_id = 0;
4646 4646
                                         } else {
4647 4647
                                             $created++;
@@ -4649,28 +4649,28 @@  discard block
 block discarded – undo
4649 4649
                                     } else {
4650 4650
                                         $invalid++;
4651 4651
                                         
4652
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4652
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error);
4653 4653
                                     }
4654 4654
                                 }
4655 4655
                             } else {
4656 4656
                                 $invalid++;
4657 4657
                                 
4658
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4658
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error);
4659 4659
                             }
4660 4660
 
4661
-                            if ( (int)$saved_post_id > 0 ) {
4661
+                            if ((int) $saved_post_id > 0) {
4662 4662
                                 // WPML
4663 4663
                                 if ($is_wpml && $original_post_id > 0 && $language != '') {
4664
-                                    $wpml_post_type = 'post_' . $post_type;
4665
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4664
+                                    $wpml_post_type = 'post_'.$post_type;
4665
+                                    $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type);
4666 4666
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4667 4667
 
4668
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4668
+                                    $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type);
4669 4669
                                     
4670
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4670
+                                    $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language);
4671 4671
                                 }
4672 4672
                                 // WPML
4673
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4673
+                                $gd_post_info = geodir_get_post_info($saved_post_id);
4674 4674
                                 
4675 4675
                                 $gd_post['post_id'] = $saved_post_id;
4676 4676
                                 $gd_post['ID'] = $saved_post_id;
@@ -4682,7 +4682,7 @@  discard block
 block discarded – undo
4682 4682
                                                     
4683 4683
                                 // post location
4684 4684
                                 $post_location_id = 0;
4685
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4685
+                                if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
4686 4686
                                     $gd_post['post_neighbourhood'] = '';
4687 4687
                                     
4688 4688
                                     $post_location_info = array(
@@ -4692,7 +4692,7 @@  discard block
 block discarded – undo
4692 4692
                                                                 'geo_lat' => $post_latitude,
4693 4693
                                                                 'geo_lng' => $post_longitude
4694 4694
                                                             );
4695
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4695
+                                    if ($location_id = (int) geodir_add_new_location($post_location_info)) {
4696 4696
                                         $post_location_id = $location_id;
4697 4697
                                     }
4698 4698
                                     
@@ -4730,14 +4730,14 @@  discard block
 block discarded – undo
4730 4730
                                 $gd_post['post_location_id'] = $post_location_id;
4731 4731
                                 
4732 4732
                                 // post package info
4733
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4733
+                                $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0;
4734 4734
                                 if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4735 4735
                                     $package_id = $gd_post_info->package_id;
4736 4736
                                 }
4737 4737
                                 
4738 4738
                                 $package_info = array();
4739 4739
                                 if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4740
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4740
+                                    $package_info = (array) geodir_get_package_info_by_id($package_id);
4741 4741
                                     
4742 4742
                                     if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4743 4743
                                         $package_info = array();
@@ -4745,18 +4745,18 @@  discard block
 block discarded – undo
4745 4745
                                 }
4746 4746
                                 
4747 4747
                                 if (empty($package_info)) {
4748
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4748
+                                    $package_info = (array) geodir_post_package_info(array(), '', $post_type);
4749 4749
                                 }
4750 4750
                                  
4751
-                                if (!empty($package_info))	 {
4751
+                                if (!empty($package_info)) {
4752 4752
                                     $package_id = $package_info['pid'];
4753 4753
                                     
4754 4754
                                     if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4755 4755
                                         $gd_post['expire_date'] = $expire_date;
4756 4756
                                     } else {
4757
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4758
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4759
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4757
+                                        if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
4758
+                                            $gd_post['alive_days'] = (int) $package_info['days'];
4759
+                                            $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $package_info['days'].' days'));
4760 4760
                                         } else {
4761 4761
                                             $gd_post['expire_date'] = 'Never';
4762 4762
                                         }
@@ -4765,7 +4765,7 @@  discard block
 block discarded – undo
4765 4765
                                     $gd_post['package_id'] = $package_id;
4766 4766
                                 }
4767 4767
 
4768
-                                $table = $plugin_prefix . $post_type . '_detail';
4768
+                                $table = $plugin_prefix.$post_type.'_detail';
4769 4769
                                 
4770 4770
                                 if ($post_type == 'gd_event') {
4771 4771
                                     $gd_post = geodir_imex_process_event_data($gd_post);
@@ -4776,28 +4776,28 @@  discard block
 block discarded – undo
4776 4776
                                 }
4777 4777
 
4778 4778
                                 // Export franchise fields
4779
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4779
+                                $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
4780 4780
                                 if ($is_franchise_active) {
4781
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4781
+                                    if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
4782 4782
                                         $gd_franchise_lock = array();
4783 4783
                                         
4784
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4785
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4786
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4787
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4784
+                                        if (isset($gd_post['gd_franchise_lock'])) {
4785
+                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
4786
+                                            $gd_franchise_lock = trim($gd_franchise_lock);
4787
+                                            $gd_franchise_lock = explode(",", $gd_franchise_lock);
4788 4788
                                         }
4789 4789
                                         
4790
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4791
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4790
+                                        update_post_meta($saved_post_id, 'gd_is_franchise', 1);
4791
+                                        update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock);
4792 4792
                                     } else {
4793
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4794
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4793
+                                        if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
4794
+                                            geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']);
4795 4795
                                         }
4796 4796
                                     }
4797 4797
                                 }
4798 4798
                                 
4799 4799
                                 if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4800
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4800
+                                    $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
4801 4801
                                     if ($default_category_id) {
4802 4802
                                         $save_post['post_default_category'] = $default_category_id;
4803 4803
                                         $gd_post['default_category'] = $default_category_id;
@@ -4806,34 +4806,34 @@  discard block
 block discarded – undo
4806 4806
                                 }
4807 4807
                                 
4808 4808
                                 // Save post info
4809
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4809
+                                geodir_save_post_info($saved_post_id, $gd_post);
4810 4810
                                 // post taxonomies
4811
-                                if ( !empty( $save_post['post_category'] ) ) {
4812
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4811
+                                if (!empty($save_post['post_category'])) {
4812
+                                    wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy);
4813 4813
                                     
4814
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4814
+                                    $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : '';
4815 4815
                                     if ($default_category_id) {
4816 4816
                                         $post_default_category = $default_category_id;
4817 4817
                                     }
4818 4818
                                     $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4819 4819
                                     $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4820
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4820
+                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']).',y:' : '';
4821 4821
                                     
4822 4822
                                     if ($post_category_str != '' && $post_default_category) {
4823
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4823
+                                        $post_category_str = str_replace($post_default_category.',y:', $post_default_category.',y,d:', $post_category_str);
4824 4824
                                     }
4825 4825
                                     
4826 4826
                                     $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4827 4827
                                     
4828
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4828
+                                    geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str);
4829 4829
                                 }
4830 4830
 
4831
-                                if ( !empty( $save_post['post_tags'] ) ) {
4832
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4831
+                                if (!empty($save_post['post_tags'])) {
4832
+                                    wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy);
4833 4833
                                 }
4834 4834
 
4835 4835
                                 // Post images
4836
-                                if ( !empty( $post_images ) ) {
4836
+                                if (!empty($post_images)) {
4837 4837
                                     $post_images = array_unique($post_images);
4838 4838
                                     
4839 4839
                                     $old_post_images_arr = array();
@@ -4841,61 +4841,61 @@  discard block
 block discarded – undo
4841 4841
                                     
4842 4842
                                     $order = 1;
4843 4843
                                     
4844
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4844
+                                    $old_post_images = geodir_get_images($saved_post_id);
4845 4845
                                     if (!empty($old_post_images)) {
4846
-                                        foreach( $old_post_images as $old_post_image ) {
4846
+                                        foreach ($old_post_images as $old_post_image) {
4847 4847
                                             if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4848 4848
                                                 $old_post_images_arr[] = $old_post_image->file;
4849 4849
                                             }
4850 4850
                                         }
4851 4851
                                     }
4852 4852
 
4853
-                                    foreach ( $post_images as $post_image ) {
4854
-                                        $image_name = basename( $post_image );
4853
+                                    foreach ($post_images as $post_image) {
4854
+                                        $image_name = basename($post_image);
4855 4855
                                         $saved_post_images_arr[] = $image_name;
4856 4856
                                         
4857
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4857
+                                        if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
4858 4858
                                             continue; // Skip if image already exists.
4859 4859
                                         }
4860 4860
                                         
4861
-                                        $image_name_parts = explode( '.', $image_name );
4862
-                                        array_pop( $image_name_parts );
4863
-                                        $proper_image_name = implode( '.', $image_name_parts );
4861
+                                        $image_name_parts = explode('.', $image_name);
4862
+                                        array_pop($image_name_parts);
4863
+                                        $proper_image_name = implode('.', $image_name_parts);
4864 4864
                                         
4865
-                                        $arr_file_type = wp_check_filetype( $image_name );
4865
+                                        $arr_file_type = wp_check_filetype($image_name);
4866 4866
                                         
4867
-                                        if ( !empty( $arr_file_type ) ) {
4867
+                                        if (!empty($arr_file_type)) {
4868 4868
                                             $uploaded_file_type = $arr_file_type['type'];
4869 4869
                                             
4870 4870
                                             $attachment = array();
4871 4871
                                             $attachment['post_id'] = $saved_post_id;
4872 4872
                                             $attachment['title'] = $proper_image_name;
4873 4873
                                             $attachment['content'] = '';
4874
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4874
+                                            $attachment['file'] = $uploads_subdir.'/'.$image_name;
4875 4875
                                             $attachment['mime_type'] = $uploaded_file_type;
4876 4876
                                             $attachment['menu_order'] = $order;
4877 4877
                                             $attachment['is_featured'] = 0;
4878 4878
 
4879 4879
                                             $attachment_set = '';
4880
-                                            foreach ( $attachment as $key => $val ) {
4881
-                                                if ( $val != '' ) {
4882
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4880
+                                            foreach ($attachment as $key => $val) {
4881
+                                                if ($val != '') {
4882
+                                                    $attachment_set .= $key." = '".$val."', ";
4883 4883
                                                 }
4884 4884
                                             }
4885
-                                            $attachment_set = trim( $attachment_set, ", " );
4885
+                                            $attachment_set = trim($attachment_set, ", ");
4886 4886
                                                                                         
4887 4887
                                             // Add new attachment
4888
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4888
+                                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
4889 4889
                                                                                         
4890 4890
                                             $order++;
4891 4891
                                         }
4892 4892
                                     }
4893 4893
 
4894
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4894
+                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/".implode("' AND file NOT LIKE '%/", $saved_post_images_arr)."' )" : '';
4895 4895
                                     // Remove previous attachment
4896
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4896
+                                    $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = ".(int) $saved_post_id." ".$saved_post_images_sql);
4897 4897
                                     
4898
-                                    if ( !empty( $saved_post_images_arr ) ) {
4898
+                                    if (!empty($saved_post_images_arr)) {
4899 4899
                                         geodir_set_wp_featured_image($saved_post_id);
4900 4900
                                         /*
4901 4901
                                         $menu_order = 1;
@@ -4912,13 +4912,13 @@  discard block
 block discarded – undo
4912 4912
                                         }*/
4913 4913
                                     }
4914 4914
                                     
4915
-                                    if ( $order > 1 ) {
4915
+                                    if ($order > 1) {
4916 4916
                                         $images++;
4917 4917
                                     }
4918 4918
                                 }
4919 4919
 
4920 4920
                                 /** This action is documented in geodirectory-functions/post-functions.php */
4921
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4921
+                                do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
4922 4922
                                 
4923 4923
                                 if (isset($is_featured)) {
4924 4924
                                     geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
@@ -4938,10 +4938,10 @@  discard block
 block discarded – undo
4938 4938
                 }
4939 4939
 
4940 4940
                 //undo some stuff to make the import quicker
4941
-                wp_defer_term_counting( false );
4942
-                wp_defer_comment_counting( false );
4943
-                $wpdb->query( 'COMMIT;' );
4944
-                $wpdb->query( 'SET autocommit = 1;' );
4941
+                wp_defer_term_counting(false);
4942
+                wp_defer_comment_counting(false);
4943
+                $wpdb->query('COMMIT;');
4944
+                $wpdb->query('SET autocommit = 1;');
4945 4945
 
4946 4946
                 $json = array();
4947 4947
                 $json['processed'] = $processed_actual;
@@ -4952,9 +4952,9 @@  discard block
 block discarded – undo
4952 4952
                 $json['invalid_addr'] = $invalid_addr;
4953 4953
                 $json['images'] = $images;
4954 4954
                 
4955
-                wp_send_json( $json );
4955
+                wp_send_json($json);
4956 4956
                 exit;
4957
-            } else if ( $task == 'import_loc' ) {
4957
+            } else if ($task == 'import_loc') {
4958 4958
                 global $gd_post_types;
4959 4959
                 $gd_post_types = $post_types;
4960 4960
                 
@@ -4963,82 +4963,82 @@  discard block
 block discarded – undo
4963 4963
                     
4964 4964
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4965 4965
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4966
-                        wp_send_json( $json );
4966
+                        wp_send_json($json);
4967 4967
                     }
4968 4968
                     
4969 4969
                     $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4970
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4970
+                    $gd_error_location = __('Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory');
4971 4971
                     for ($i = 1; $i <= $limit; $i++) {
4972 4972
                         $index = $processed + $i;
4973 4973
                         
4974 4974
                         if (isset($file[$index])) {
4975 4975
                             $row = $file[$index];
4976
-                            $row = array_map( 'trim', $row );
4976
+                            $row = array_map('trim', $row);
4977 4977
                             $data = array();
4978 4978
                             
4979
-                            foreach ($columns as $c => $column ) {
4979
+                            foreach ($columns as $c => $column) {
4980 4980
                                 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'))) {
4981 4981
                                     $data[$column] = $row[$c];
4982 4982
                                 }
4983 4983
                             }
4984 4984
 
4985
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4985
+                            if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
4986 4986
                                 $invalid++;
4987
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4987
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4988 4988
                                 continue;
4989 4989
                             }
4990 4990
                             
4991 4991
                             $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4992 4992
                             
4993
-                            if ( $import_choice == 'update' ) {
4994
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4995
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4993
+                            if ($import_choice == 'update') {
4994
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4995
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4996 4996
                                         $updated++;
4997 4997
                                     } else {
4998 4998
                                         $invalid++;
4999
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4999
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
5000 5000
                                     }
5001
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5002
-                                    $data['location_id'] = (int)$location->location_id;
5001
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
5002
+                                    $data['location_id'] = (int) $location->location_id;
5003 5003
                                     
5004
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
5005
-                                        $data['location_id'] = (int)$location->location_id;
5006
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
5007
-                                        $data['location_id'] = (int)$location->location_id;
5008
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
5009
-                                        $data['location_id'] = (int)$location->location_id;
5004
+                                    if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
5005
+                                        $data['location_id'] = (int) $location->location_id;
5006
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
5007
+                                        $data['location_id'] = (int) $location->location_id;
5008
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
5009
+                                        $data['location_id'] = (int) $location->location_id;
5010 5010
                                     }
5011 5011
                                     
5012
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
5012
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
5013 5013
                                         $updated++;
5014 5014
                                     } else {
5015 5015
                                         $invalid++;
5016
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5016
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
5017 5017
                                     }
5018 5018
                                 } else {
5019
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5019
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
5020 5020
                                         $created++;
5021 5021
                                     } else {
5022 5022
                                         $invalid++;
5023
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5023
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
5024 5024
                                     }
5025 5025
                                 }
5026
-                            } elseif ( $import_choice == 'skip' ) {
5027
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
5026
+                            } elseif ($import_choice == 'skip') {
5027
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
5028 5028
                                     $skipped++;
5029
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
5029
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
5030 5030
                                     $skipped++;
5031 5031
                                 } else {
5032
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
5032
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
5033 5033
                                         $created++;
5034 5034
                                     } else {
5035 5035
                                         $invalid++;
5036
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5036
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
5037 5037
                                     }
5038 5038
                                 }
5039 5039
                             } else {
5040 5040
                                 $invalid++;
5041
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
5041
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
5042 5042
                             }
5043 5043
                         }
5044 5044
                     }
@@ -5052,24 +5052,24 @@  discard block
 block discarded – undo
5052 5052
                 $json['invalid'] = $invalid;
5053 5053
                 $json['images'] = $images;
5054 5054
                 
5055
-                wp_send_json( $json );
5056
-            } else if ( $task == 'import_hood' ) {               
5055
+                wp_send_json($json);
5056
+            } else if ($task == 'import_hood') {               
5057 5057
                 if (!empty($file)) {
5058 5058
                     $columns = isset($file[0]) ? $file[0] : NULL;
5059 5059
                     
5060 5060
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
5061 5061
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
5062
-                        wp_send_json( $json );
5062
+                        wp_send_json($json);
5063 5063
                     }
5064 5064
                     
5065 5065
                     $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
5066
-                    $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
5066
+                    $gd_error_hood = __('Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory');
5067 5067
                     for ($i = 1; $i <= $limit; $i++) {
5068 5068
                         $index = $processed + $i;
5069 5069
                         
5070 5070
                         if (isset($file[$index])) {
5071 5071
                             $row = $file[$index];
5072
-                            $row = array_map( 'trim', $row );
5072
+                            $row = array_map('trim', $row);
5073 5073
                             $data = array();
5074 5074
                             
5075 5075
                             foreach ($columns as $c => $column) {
@@ -5080,20 +5080,20 @@  discard block
 block discarded – undo
5080 5080
 
5081 5081
                             if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5082 5082
                                 $invalid++;
5083
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5083
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5084 5084
                                 continue;
5085 5085
                             }
5086 5086
                             
5087 5087
                             $location_info = array();
5088
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5089
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5088
+                            if (!empty($data['location_id']) && (int) $data['location_id'] > 0) {
5089
+                                $location_info = geodir_get_location_by_id('', (int) $data['location_id']);
5090 5090
                             } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5091 5091
                                 $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5092 5092
                             }
5093 5093
 
5094 5094
                             if (empty($location_info)) {
5095 5095
                                 $invalid++;
5096
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5096
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5097 5097
                                 continue;
5098 5098
                             }
5099 5099
                             
@@ -5108,35 +5108,35 @@  discard block
 block discarded – undo
5108 5108
                             $hood_data['hood_longitude'] = $data['longitude'];
5109 5109
                             $hood_data['hood_location_id'] = $location_id;
5110 5110
                                     
5111
-                            if ( $import_choice == 'update' ) {
5112
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5113
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5111
+                            if ($import_choice == 'update') {
5112
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
5113
+                                    $hood_data['hood_id'] = (int) $data['neighbourhood_id'];
5114 5114
                                     
5115 5115
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5116 5116
                                         $updated++;
5117 5117
                                     } else {
5118 5118
                                         $invalid++;
5119
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5119
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5120 5120
                                     }
5121 5121
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5122
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5122
+                                    $hood_data['hood_id'] = (int) $neighbourhood->hood_id;
5123 5123
                                     
5124 5124
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5125 5125
                                         $updated++;
5126 5126
                                     } else {
5127 5127
                                         $invalid++;
5128
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5128
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5129 5129
                                     }
5130 5130
                                 } else {
5131 5131
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5132 5132
                                         $created++;
5133 5133
                                     } else {
5134 5134
                                         $invalid++;
5135
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5135
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5136 5136
                                     }
5137 5137
                                 }
5138
-                            } elseif ( $import_choice == 'skip' ) {
5139
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5138
+                            } elseif ($import_choice == 'skip') {
5139
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
5140 5140
                                     $skipped++;
5141 5141
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5142 5142
                                     $skipped++;
@@ -5146,12 +5146,12 @@  discard block
 block discarded – undo
5146 5146
                                         $created++;
5147 5147
                                     } else {
5148 5148
                                         $invalid++;
5149
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5149
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5150 5150
                                     }
5151 5151
                                 }
5152 5152
                             } else {
5153 5153
                                 $invalid++;
5154
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5154
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5155 5155
                             }
5156 5156
                         }
5157 5157
                     }
@@ -5165,7 +5165,7 @@  discard block
 block discarded – undo
5165 5165
                 $json['invalid'] = $invalid;
5166 5166
                 $json['images'] = $images;
5167 5167
                 
5168
-                wp_send_json( $json );
5168
+                wp_send_json($json);
5169 5169
             }
5170 5170
         }
5171 5171
         break;
@@ -5209,29 +5209,29 @@  discard block
 block discarded – undo
5209 5209
  * }
5210 5210
  * @return int|bool Term id when success, false when fail.
5211 5211
  */
5212
-function geodir_imex_insert_term( $taxonomy, $term_data ) {
5213
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5212
+function geodir_imex_insert_term($taxonomy, $term_data) {
5213
+	if (empty($taxonomy) || empty($term_data)) {
5214 5214
 		return false;
5215 5215
 	}
5216 5216
 	
5217
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
5217
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
5218 5218
 	$args = array();
5219
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5220
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5221
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5219
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5220
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5221
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5222 5222
 	
5223
-	if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
5224
-		$term_args = array_merge( $term_data, $args );
5225
-		$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5226
-		$term_args = wp_parse_args( $term_args, $defaults );
5227
-		$term_args = sanitize_term( $term_args, $taxonomy, 'db' );
5228
-		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5223
+	if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
5224
+		$term_args = array_merge($term_data, $args);
5225
+		$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5226
+		$term_args = wp_parse_args($term_args, $defaults);
5227
+		$term_args = sanitize_term($term_args, $taxonomy, 'db');
5228
+		$args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args);
5229 5229
 	}
5230 5230
 	
5231
-    if( !empty( $term ) ) {
5232
-		$result = wp_insert_term( $term, $taxonomy, $args );
5233
-        if( !is_wp_error( $result ) ) {
5234
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5231
+    if (!empty($term)) {
5232
+		$result = wp_insert_term($term, $taxonomy, $args);
5233
+        if (!is_wp_error($result)) {
5234
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5235 5235
         }
5236 5236
     }
5237 5237
 	
@@ -5261,36 +5261,36 @@  discard block
 block discarded – undo
5261 5261
  * }
5262 5262
  * @return int|bool Term id when success, false when fail.
5263 5263
  */
5264
-function geodir_imex_update_term( $taxonomy, $term_data ) {
5265
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5264
+function geodir_imex_update_term($taxonomy, $term_data) {
5265
+	if (empty($taxonomy) || empty($term_data)) {
5266 5266
 		return false;
5267 5267
 	}
5268 5268
 	
5269
-	$term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0;
5269
+	$term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0;
5270 5270
 	
5271 5271
 	$args = array();
5272
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5273
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5274
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5272
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5273
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5274
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5275 5275
 	
5276
-	if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
5276
+	if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
5277 5277
 		$term_data['term_id'] = $term_info['term_id'];
5278 5278
 		
5279
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5279
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5280 5280
 		
5281
-		if( !is_wp_error( $result ) ) {
5282
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5281
+		if (!is_wp_error($result)) {
5282
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5283 5283
         }
5284
-	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5284
+	} else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
5285 5285
 		$term_data['term_id'] = $term_info['term_id'];
5286 5286
 		
5287
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5287
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5288 5288
 		
5289
-		if( !is_wp_error( $result ) ) {
5290
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5289
+		if (!is_wp_error($result)) {
5290
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5291 5291
         }
5292 5292
 	} else {
5293
-		return geodir_imex_insert_term( $taxonomy, $term_data );
5293
+		return geodir_imex_insert_term($taxonomy, $term_data);
5294 5294
 	}
5295 5295
 	
5296 5296
 	return false;
@@ -5309,20 +5309,20 @@  discard block
 block discarded – undo
5309 5309
  * @param string $post_type Post type.
5310 5310
  * @return int Posts count.
5311 5311
  */
5312
-function geodir_get_posts_count( $post_type ) {
5312
+function geodir_get_posts_count($post_type) {
5313 5313
     global $wpdb, $plugin_prefix;
5314 5314
 
5315
-    if ( !post_type_exists( $post_type ) ) {
5315
+    if (!post_type_exists($post_type)) {
5316 5316
         return 0;
5317 5317
     }
5318 5318
         
5319
-    $table = $plugin_prefix . $post_type . '_detail';
5319
+    $table = $plugin_prefix.$post_type.'_detail';
5320 5320
 
5321 5321
     // Skip listing with statuses trash, auto-draft etc...
5322 5322
     $skip_statuses = geodir_imex_export_skip_statuses();
5323 5323
     $where_statuses = '';
5324
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5325
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5324
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5325
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5326 5326
     }
5327 5327
     
5328 5328
     /**
@@ -5333,11 +5333,11 @@  discard block
 block discarded – undo
5333 5333
      *
5334 5334
      * @param string $where SQL where clause part.
5335 5335
      */
5336
-    $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5336
+    $where_statuses = apply_filters('geodir_get_posts_count', $where_statuses, $post_type);
5337 5337
 
5338
-    $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5338
+    $query = $wpdb->prepare("SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ".$where_statuses, $post_type);
5339 5339
 
5340
-    $posts_count = (int)$wpdb->get_var( $query );
5340
+    $posts_count = (int) $wpdb->get_var($query);
5341 5341
     
5342 5342
     /**
5343 5343
      * Modify returned post counts for the current post type.
@@ -5348,7 +5348,7 @@  discard block
 block discarded – undo
5348 5348
      * @param int $posts_count Post counts.
5349 5349
      * @param string $post_type Post type.
5350 5350
      */
5351
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5351
+    $posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);
5352 5352
 
5353 5353
     return $posts_count;
5354 5354
 }
@@ -5369,19 +5369,19 @@  discard block
 block discarded – undo
5369 5369
  * @param int $page_no Page number. Default 0.
5370 5370
  * @return array Array of posts data.
5371 5371
  */
5372
-function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {	
5372
+function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {	
5373 5373
 	global $wp_filesystem;
5374 5374
 
5375
-	$posts = geodir_get_export_posts( $post_type, $per_page, $page_no );
5375
+	$posts = geodir_get_export_posts($post_type, $per_page, $page_no);
5376 5376
 
5377 5377
 	$csv_rows = array();
5378 5378
 	
5379
-	if ( !empty( $posts ) ) {
5380
-		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5379
+	if (!empty($posts)) {
5380
+		$is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
5381 5381
         $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5382
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5382
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
5383 5383
         $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5384
-        $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
5384
+        $is_claim_active = is_plugin_active('geodir_claim_listing/geodir_claim_listing.php') && get_option('geodir_claim_enable') === 'yes' ? true : false;
5385 5385
 		
5386 5386
 		$csv_row = array();
5387 5387
 		$csv_row[] = 'post_id';
@@ -5392,7 +5392,7 @@  discard block
 block discarded – undo
5392 5392
 		$csv_row[] = 'default_category';
5393 5393
 		$csv_row[] = 'post_tags';
5394 5394
 		$csv_row[] = 'post_type';
5395
-		if ( $post_type == 'gd_event' ) {
5395
+		if ($post_type == 'gd_event') {
5396 5396
 			$csv_row[] = 'event_date';
5397 5397
 			$csv_row[] = 'event_enddate';
5398 5398
 			$csv_row[] = 'starttime';
@@ -5451,15 +5451,15 @@  discard block
 block discarded – undo
5451 5451
 		}
5452 5452
 		// WPML
5453 5453
 
5454
-		$custom_fields = geodir_imex_get_custom_fields( $post_type );
5455
-		if ( !empty( $custom_fields ) ) {
5456
-			foreach ( $custom_fields as $custom_field ) {
5454
+		$custom_fields = geodir_imex_get_custom_fields($post_type);
5455
+		if (!empty($custom_fields)) {
5456
+			foreach ($custom_fields as $custom_field) {
5457 5457
 				$csv_row[] = $custom_field->htmlvar_name;
5458 5458
 			}
5459 5459
 		}
5460 5460
 
5461 5461
 		// Export franchise fields
5462
-		$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5462
+		$is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
5463 5463
 		if ($is_franchise_active) {
5464 5464
 			$csv_row[] = 'gd_is_franchise';
5465 5465
 			$csv_row[] = 'gd_franchise_lock';
@@ -5480,28 +5480,28 @@  discard block
 block discarded – undo
5480 5480
 		$csv_rows[] = $csv_row;
5481 5481
 
5482 5482
 		$images_count = 5;
5483
-        $xx=0;
5484
-		foreach ( $posts as $post ) {$xx++;
5483
+        $xx = 0;
5484
+		foreach ($posts as $post) {$xx++;
5485 5485
 			$post_id = $post['ID'];
5486 5486
 			
5487
-			$gd_post_info = geodir_get_post_info( $post_id );
5488
-			$post_info = (array)$gd_post_info;
5487
+			$gd_post_info = geodir_get_post_info($post_id);
5488
+			$post_info = (array) $gd_post_info;
5489 5489
 						
5490
-			$taxonomy_category = $post_type . 'category';
5491
-			$taxonomy_tags = $post_type . '_tags';
5490
+			$taxonomy_category = $post_type.'category';
5491
+			$taxonomy_tags = $post_type.'_tags';
5492 5492
 			
5493 5493
 			$post_category = '';
5494 5494
 			$default_category_id = $gd_post_info->default_category;
5495 5495
 			$default_category = '';
5496 5496
 			$post_tags = '';
5497
-			$terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) );
5497
+			$terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags));
5498 5498
 			
5499
-			if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
5499
+			if (!empty($terms) && !is_wp_error($terms)) {
5500 5500
 				$post_category = array();
5501 5501
 				$post_tags = array();
5502 5502
 			
5503
-				foreach ( $terms as $term ) {
5504
-					if ( $term->taxonomy == $taxonomy_category ) {
5503
+				foreach ($terms as $term) {
5504
+					if ($term->taxonomy == $taxonomy_category) {
5505 5505
 						$post_category[] = $term->name;
5506 5506
 						
5507 5507
 						if ($default_category_id == $term->term_id) {
@@ -5509,7 +5509,7 @@  discard block
 block discarded – undo
5509 5509
 						}
5510 5510
 					}
5511 5511
 					
5512
-					if ( $term->taxonomy == $taxonomy_tags ) {
5512
+					if ($term->taxonomy == $taxonomy_tags) {
5513 5513
 						$post_tags[] = $term->name;
5514 5514
 					}
5515 5515
 				}
@@ -5517,47 +5517,47 @@  discard block
 block discarded – undo
5517 5517
 				if (empty($default_category) && !empty($post_category)) {
5518 5518
 					$default_category = $post_category[0]; // Set first one as default category.
5519 5519
 				}
5520
-				$post_category = !empty( $post_category ) ? implode( ',', $post_category ) : '';
5521
-				$post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : '';
5520
+				$post_category = !empty($post_category) ? implode(',', $post_category) : '';
5521
+				$post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
5522 5522
 			}
5523 5523
 
5524 5524
 			// Franchise data
5525
-			if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
5525
+			if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
5526 5526
 				$franchise_id = $post_info['franchise'];
5527 5527
 				$gd_franchise_info = geodir_get_post_info($franchise_id);
5528 5528
 
5529 5529
 				if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
5530
-					$franchise_info = (array)$gd_franchise_info;
5530
+					$franchise_info = (array) $gd_franchise_info;
5531 5531
 					$locked_fields = geodir_franchise_get_locked_fields($franchise_id, true);
5532 5532
 					
5533 5533
 					if (!empty($locked_fields)) {
5534
-						foreach( $locked_fields as $locked_field) {
5534
+						foreach ($locked_fields as $locked_field) {
5535 5535
 							if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
5536 5536
 								$post_info[$locked_field] = $franchise_info[$locked_field];
5537 5537
 							}
5538 5538
 							
5539 5539
 							if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
5540
-								$franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) );
5540
+								$franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags));
5541 5541
 			
5542
-								if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
5542
+								if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
5543 5543
 									$franchise_post_category = array();
5544 5544
 									$franchise_post_tags = array();
5545 5545
 								
5546
-									foreach ( $franchise_terms as $franchise_term ) {
5547
-										if ( $franchise_term->taxonomy == $taxonomy_category ) {
5546
+									foreach ($franchise_terms as $franchise_term) {
5547
+										if ($franchise_term->taxonomy == $taxonomy_category) {
5548 5548
 											$franchise_post_category[] = $franchise_term->name;
5549 5549
 										}
5550 5550
 										
5551
-										if ( $franchise_term->taxonomy == $taxonomy_tags ) {
5551
+										if ($franchise_term->taxonomy == $taxonomy_tags) {
5552 5552
 											$franchise_post_tags[] = $franchise_term->name;
5553 5553
 										}
5554 5554
 									}
5555 5555
 									
5556 5556
 									if (in_array($taxonomy_category, $locked_fields)) {
5557
-										$post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : '';
5557
+										$post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
5558 5558
 									}
5559 5559
 									if (in_array('post_tags', $locked_fields)) {
5560
-										$post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : '';
5560
+										$post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
5561 5561
 									}
5562 5562
 								}
5563 5563
 							}
@@ -5566,18 +5566,18 @@  discard block
 block discarded – undo
5566 5566
 				}
5567 5567
 			}
5568 5568
 						
5569
-			$post_images = geodir_get_images( $post_id );
5569
+			$post_images = geodir_get_images($post_id);
5570 5570
 			$current_images = array();
5571
-			if ( !empty( $post_images ) ) {
5572
-				foreach ( $post_images as $post_image ) {
5573
-					$post_image = (array)$post_image;
5574
-					$image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : '';
5575
-					if ( $image ) {
5571
+			if (!empty($post_images)) {
5572
+				foreach ($post_images as $post_image) {
5573
+					$post_image = (array) $post_image;
5574
+					$image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : '';
5575
+					if ($image) {
5576 5576
 						$current_images[] = $image;
5577 5577
 					}
5578 5578
 				}
5579 5579
 				
5580
-				$images_count = max( $images_count, count( $current_images ) );
5580
+				$images_count = max($images_count, count($current_images));
5581 5581
 			}
5582 5582
 
5583 5583
 			$csv_row = array();
@@ -5589,7 +5589,7 @@  discard block
 block discarded – undo
5589 5589
 			$csv_row[] = $default_category; // default_category
5590 5590
 			$csv_row[] = $post_tags; // post_tags
5591 5591
 			$csv_row[] = $post_type; // post_type
5592
-			if ( $post_type == 'gd_event' ) {
5592
+			if ($post_type == 'gd_event') {
5593 5593
 				$event_data = geodir_imex_get_event_data($post, $gd_post_info);
5594 5594
 				$csv_row[] = $event_data['event_date']; // event_date
5595 5595
 				$csv_row[] = $event_data['event_enddate']; // enddate
@@ -5610,12 +5610,12 @@  discard block
 block discarded – undo
5610 5610
 				$csv_row[] = $event_data['recurring_end_date']; // repeat_end
5611 5611
 			}
5612 5612
 			$csv_row[] = $post_info['post_status']; // post_status
5613
-			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5613
+			$csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5614 5614
             if ($is_claim_active) {
5615
-                $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5615
+                $csv_row[] = !empty($post_info['claimed']) && (int) $post_info['claimed'] == 1 ? 1 : ''; // claimed
5616 5616
             }
5617 5617
 			if ($is_payment_plugin) {
5618
-				$csv_row[] = (int)$post_info['package_id']; // package_id
5618
+				$csv_row[] = (int) $post_info['package_id']; // package_id
5619 5619
 				$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
5620 5620
 			}
5621 5621
             $csv_row[] = $post_info['post_date']; // post_date
@@ -5652,14 +5652,14 @@  discard block
 block discarded – undo
5652 5652
 			$csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers
5653 5653
 			// WPML
5654 5654
 			if ($is_wpml) {
5655
-				$csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type );
5656
-				$csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type );
5655
+				$csv_row[] = geodir_get_language_for_element($post_id, 'post_'.$post_type);
5656
+				$csv_row[] = geodir_imex_original_post_id($post_id, 'post_'.$post_type);
5657 5657
 			}
5658 5658
 			// WPML
5659 5659
 			
5660
-			if ( !empty( $custom_fields ) ) {
5661
-				foreach ( $custom_fields as $custom_field ) {
5662
-					$csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : '';
5660
+			if (!empty($custom_fields)) {
5661
+				foreach ($custom_fields as $custom_field) {
5662
+					$csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : '';
5663 5663
 				}
5664 5664
 			}
5665 5665
 			
@@ -5670,15 +5670,15 @@  discard block
 block discarded – undo
5670 5670
 				$franchise = '';
5671 5671
 					
5672 5672
 				if (geodir_franchise_pkg_is_active($gd_post_info)) {
5673
-					$gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true );
5674
-					$locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : '';
5673
+					$gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true);
5674
+					$locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : '';
5675 5675
 					$locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
5676
-					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id
5676
+					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id
5677 5677
 				}
5678 5678
 				
5679
-				$csv_row[] = (int)$gd_is_franchise; // gd_is_franchise
5679
+				$csv_row[] = (int) $gd_is_franchise; // gd_is_franchise
5680 5680
 				$csv_row[] = $locaked_fields; // gd_franchise_lock fields
5681
-				$csv_row[] = (int)$franchise; // franchise id
5681
+				$csv_row[] = (int) $franchise; // franchise id
5682 5682
 			}
5683 5683
             
5684 5684
             /**
@@ -5692,15 +5692,15 @@  discard block
 block discarded – undo
5692 5692
              */
5693 5693
             $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5694 5694
 			
5695
-			for ( $c = 0; $c < $images_count; $c++ ) {
5696
-				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
5695
+			for ($c = 0; $c < $images_count; $c++) {
5696
+				$csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE
5697 5697
 			}
5698 5698
 			
5699 5699
 			$csv_rows[] = $csv_row;
5700 5700
 
5701 5701
 		}
5702 5702
 
5703
-		for ( $c = 0; $c < $images_count; $c++ ) {
5703
+		for ($c = 0; $c < $images_count; $c++) {
5704 5704
 			$csv_rows[0][] = 'IMAGE';
5705 5705
 		}
5706 5706
 	}
@@ -5722,30 +5722,30 @@  discard block
 block discarded – undo
5722 5722
  * @param int $page_no Page number. Default 0.
5723 5723
  * @return array Array of posts data.
5724 5724
  */
5725
-function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5725
+function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
5726 5726
     global $wpdb, $plugin_prefix;
5727 5727
 
5728
-    if ( ! post_type_exists( $post_type ) )
5728
+    if (!post_type_exists($post_type))
5729 5729
         return new stdClass;
5730 5730
         
5731
-    $table = $plugin_prefix . $post_type . '_detail';
5731
+    $table = $plugin_prefix.$post_type.'_detail';
5732 5732
 
5733 5733
     $limit = '';
5734
-    if ( $per_page > 0 && $page_no > 0 ) {
5735
-        $offset = ( $page_no - 1 ) * $per_page;
5734
+    if ($per_page > 0 && $page_no > 0) {
5735
+        $offset = ($page_no - 1) * $per_page;
5736 5736
         
5737
-        if ( $offset > 0 ) {
5738
-            $limit = " LIMIT " . $offset . "," . $per_page;
5737
+        if ($offset > 0) {
5738
+            $limit = " LIMIT ".$offset.",".$per_page;
5739 5739
         } else {
5740
-            $limit = " LIMIT " . $per_page;
5740
+            $limit = " LIMIT ".$per_page;
5741 5741
         }
5742 5742
     }
5743 5743
 
5744 5744
     // Skip listing with statuses trash, auto-draft etc...
5745 5745
     $skip_statuses = geodir_imex_export_skip_statuses();
5746 5746
     $where_statuses = '';
5747
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5748
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5747
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5748
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5749 5749
     }
5750 5750
     
5751 5751
     /**
@@ -5756,9 +5756,9 @@  discard block
 block discarded – undo
5756 5756
      *
5757 5757
      * @param string $where SQL where clause part.
5758 5758
      */
5759
-    $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5759
+    $where_statuses = apply_filters('geodir_get_export_posts', $where_statuses, $post_type);
5760 5760
 
5761
-    $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5761
+    $query = $wpdb->prepare("SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ".$where_statuses." ORDER BY {$wpdb->posts}.ID ASC".$limit, $post_type);
5762 5762
     /**
5763 5763
      * Modify returned posts SQL query for the current post type.
5764 5764
      *
@@ -5768,8 +5768,8 @@  discard block
 block discarded – undo
5768 5768
      * @param int $query The SQL query.
5769 5769
      * @param string $post_type Post type.
5770 5770
      */
5771
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5772
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5771
+    $query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
5772
+    $results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A);
5773 5773
 
5774 5774
     /**
5775 5775
      * Modify returned post results for the current post type.
@@ -5780,7 +5780,7 @@  discard block
 block discarded – undo
5780 5780
      * @param object $results An object containing all post ids.
5781 5781
      * @param string $post_type Post type.
5782 5782
      */
5783
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5783
+    return apply_filters('geodir_export_posts', $results, $post_type);
5784 5784
 }
5785 5785
 
5786 5786
 /**
@@ -5798,24 +5798,24 @@  discard block
 block discarded – undo
5798 5798
  * @param string $post_type Post type.
5799 5799
  * @return string The SQL query.
5800 5800
  */
5801
-function geodir_imex_get_events_query( $query, $post_type ) {
5802
-    if ( $post_type == 'gd_event' ) {
5801
+function geodir_imex_get_events_query($query, $post_type) {
5802
+    if ($post_type == 'gd_event') {
5803 5803
         global $wpdb, $plugin_prefix;
5804 5804
         
5805
-        $table = $plugin_prefix . $post_type . '_detail';
5805
+        $table = $plugin_prefix.$post_type.'_detail';
5806 5806
         $schedule_table = EVENT_SCHEDULE;
5807 5807
         
5808 5808
         // Skip listing with statuses trash, auto-draft etc...
5809 5809
         $skip_statuses = geodir_imex_export_skip_statuses();
5810 5810
         $where_statuses = '';
5811
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5812
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5811
+        if (!empty($skip_statuses) && is_array($skip_statuses)) {
5812
+            $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5813 5813
         }
5814 5814
         
5815 5815
         /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5816
-        $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5816
+        $where_statuses = apply_filters('geodir_get_export_posts', $where_statuses, $post_type);
5817 5817
 
5818
-        $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime 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 " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5818
+        $query = $wpdb->prepare("SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime 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 ".$where_statuses." GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type);
5819 5819
     }
5820 5820
 
5821 5821
     return $query;
@@ -5839,35 +5839,35 @@  discard block
 block discarded – undo
5839 5839
  * @param  string $post_type Post type.
5840 5840
  * @return int Total terms count.
5841 5841
  */
5842
-function geodir_get_terms_count( $post_type ) {
5843
-    $args = array( 'hide_empty' => 0 );
5842
+function geodir_get_terms_count($post_type) {
5843
+    $args = array('hide_empty' => 0);
5844 5844
 
5845
-    remove_all_filters( 'get_terms' );
5845
+    remove_all_filters('get_terms');
5846 5846
 
5847
-    $taxonomy = $post_type . 'category';
5847
+    $taxonomy = $post_type.'category';
5848 5848
 
5849 5849
     // WPML
5850 5850
     $is_wpml = geodir_is_wpml();
5851 5851
     $active_lang = 'all';
5852
-    if ( $is_wpml ) {
5852
+    if ($is_wpml) {
5853 5853
         global $sitepress;
5854 5854
         $active_lang = $sitepress->get_current_language();
5855 5855
         
5856
-        if ( $active_lang != 'all' ) {
5857
-            $sitepress->switch_lang( 'all', true );
5856
+        if ($active_lang != 'all') {
5857
+            $sitepress->switch_lang('all', true);
5858 5858
         }
5859 5859
     }
5860 5860
     // WPML
5861 5861
             
5862
-    $count_terms = wp_count_terms( $taxonomy, $args );
5862
+    $count_terms = wp_count_terms($taxonomy, $args);
5863 5863
 
5864 5864
     // WPML
5865
-    if ( $is_wpml && $active_lang !== 'all' ) {
5865
+    if ($is_wpml && $active_lang !== 'all') {
5866 5866
         global $sitepress;
5867
-        $sitepress->switch_lang( $active_lang, true );
5867
+        $sitepress->switch_lang($active_lang, true);
5868 5868
     }
5869 5869
     // WPML
5870
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5870
+    $count_terms = !is_wp_error($count_terms) ? $count_terms : 0;
5871 5871
      
5872 5872
     return $count_terms;
5873 5873
 }
@@ -5884,23 +5884,23 @@  discard block
 block discarded – undo
5884 5884
  * @param int $page_no Page number. Default 0.
5885 5885
  * @return array Array of terms data.
5886 5886
  */
5887
-function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
5888
-	$args = array( 'hide_empty' => 0, 'orderby' => 'id' );
5887
+function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
5888
+	$args = array('hide_empty' => 0, 'orderby' => 'id');
5889 5889
 	
5890
-	remove_all_filters( 'get_terms' );
5890
+	remove_all_filters('get_terms');
5891 5891
 	
5892
-	$taxonomy = $post_type . 'category';
5892
+	$taxonomy = $post_type.'category';
5893 5893
 	
5894
-	if ( $per_page > 0 && $page_no > 0 ) {
5895
-		$args['offset'] = ( $page_no - 1 ) * $per_page;
5894
+	if ($per_page > 0 && $page_no > 0) {
5895
+		$args['offset'] = ($page_no - 1) * $per_page;
5896 5896
 		$args['number'] = $per_page;
5897 5897
 	}
5898 5898
 	
5899
-	$terms = get_terms( $taxonomy, $args );
5899
+	$terms = get_terms($taxonomy, $args);
5900 5900
 
5901 5901
 	$csv_rows = array();
5902 5902
 	
5903
-	if ( !empty( $terms ) ) {
5903
+	if (!empty($terms)) {
5904 5904
 		$csv_row = array();
5905 5905
 		$csv_row[] = 'cat_id';
5906 5906
 		$csv_row[] = 'cat_name';
@@ -5922,16 +5922,16 @@  discard block
 block discarded – undo
5922 5922
 		
5923 5923
 		$csv_rows[] = $csv_row;
5924 5924
 		
5925
-		foreach ( $terms as $term ) {
5926
-			$cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type );
5927
-			$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5925
+		foreach ($terms as $term) {
5926
+			$cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type);
5927
+			$cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
5928 5928
 			
5929
-			$cat_image = geodir_get_default_catimage( $term->term_id, $post_type );
5930
-			$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; 
5929
+			$cat_image = geodir_get_default_catimage($term->term_id, $post_type);
5930
+			$cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; 
5931 5931
 			
5932 5932
 			$cat_parent = '';
5933
-			if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
5934
-				$parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy );
5933
+			if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
5934
+				$parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
5935 5935
 				$cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : '';
5936 5936
 			}
5937 5937
 			
@@ -5941,15 +5941,15 @@  discard block
 block discarded – undo
5941 5941
 			$csv_row[] = $term->slug;
5942 5942
 			$csv_row[] = $post_type;
5943 5943
 			$csv_row[] = $cat_parent;
5944
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5944
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type);
5945 5945
             // WPML
5946 5946
 			if ($is_wpml) {
5947
-				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5948
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5947
+				$csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_'.$taxonomy);
5948
+                $csv_row[] = geodir_imex_original_post_id($term->term_id, 'tax_'.$taxonomy);
5949 5949
 			}
5950 5950
 			// WPML
5951 5951
 			$csv_row[] = $term->description;
5952
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type );
5952
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type);
5953 5953
 			$csv_row[] = $cat_image;
5954 5954
 			$csv_row[] = $cat_icon;
5955 5955
 			
@@ -5968,10 +5968,10 @@  discard block
 block discarded – undo
5968 5968
  * @param  bool $relative True for relative path & False for absolute path.
5969 5969
  * @return string Path to the cache directory.
5970 5970
  */
5971
-function geodir_path_import_export( $relative = true ) {
5971
+function geodir_path_import_export($relative = true) {
5972 5972
 	$upload_dir = wp_upload_dir();
5973 5973
 	
5974
-	return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache';
5974
+	return $relative ? $upload_dir['baseurl'].'/cache' : $upload_dir['basedir'].'/cache';
5975 5975
 }
5976 5976
 
5977 5977
 /**
@@ -5987,8 +5987,8 @@  discard block
 block discarded – undo
5987 5987
  * @param  bool $clear If true then it overwrite data otherwise add rows at the end of file.
5988 5988
  * @return bool true if success otherwise false.
5989 5989
  */
5990
-function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
5991
-	if ( empty( $csv_data ) ) {
5990
+function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
5991
+	if (empty($csv_data)) {
5992 5992
 		return false;
5993 5993
 	}
5994 5994
 	
@@ -5996,17 +5996,17 @@  discard block
 block discarded – undo
5996 5996
 	
5997 5997
 	$mode = $clear ? 'w+' : 'a+';
5998 5998
 	
5999
-	if ( function_exists( 'fputcsv' ) ) {
6000
-		$file = fopen( $file_path, $mode );
6001
-		foreach( $csv_data as $csv_row ) {
5999
+	if (function_exists('fputcsv')) {
6000
+		$file = fopen($file_path, $mode);
6001
+		foreach ($csv_data as $csv_row) {
6002 6002
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
6003
-			$write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' );
6003
+			$write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"');
6004 6004
 		}
6005
-		fclose( $file );
6005
+		fclose($file);
6006 6006
 	} else {
6007
-		foreach( $csv_data as $csv_row ) {
6007
+		foreach ($csv_data as $csv_row) {
6008 6008
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
6009
-			$wp_filesystem->put_contents( $file_path, $csv_row );
6009
+			$wp_filesystem->put_contents($file_path, $csv_row);
6010 6010
 		}
6011 6011
 	}
6012 6012
 		
@@ -6024,14 +6024,14 @@  discard block
 block discarded – undo
6024 6024
  * @param  string $file Full path to file.
6025 6025
  * @return int No of file rows.
6026 6026
  */
6027
-function geodir_import_export_line_count( $file ) {
6027
+function geodir_import_export_line_count($file) {
6028 6028
 	global $wp_filesystem;
6029 6029
 	
6030
-	if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
6031
-		$contents = $wp_filesystem->get_contents_array( $file );
6030
+	if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
6031
+		$contents = $wp_filesystem->get_contents_array($file);
6032 6032
 		
6033
-		if ( !empty( $contents ) && is_array( $contents ) ) {
6034
-			return count( $contents ) - 1;
6033
+		if (!empty($contents) && is_array($contents)) {
6034
+			return count($contents) - 1;
6035 6035
 		}
6036 6036
 	}
6037 6037
 	
@@ -6048,11 +6048,11 @@  discard block
 block discarded – undo
6048 6048
  * @param string $post_type The post type.
6049 6049
  * @return object Queried object.
6050 6050
  */
6051
-function geodir_imex_get_custom_fields( $post_type ) {
6051
+function geodir_imex_get_custom_fields($post_type) {
6052 6052
 	global $wpdb;
6053 6053
 	 
6054
-	$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 ) );
6055
-	$rows = $wpdb->get_results( $sql );
6054
+	$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));
6055
+	$rows = $wpdb->get_results($sql);
6056 6056
 	 
6057 6057
 	return $rows;
6058 6058
 }
@@ -6131,14 +6131,14 @@  discard block
 block discarded – undo
6131 6131
 	global $wpdb, $plugin_prefix;
6132 6132
 	
6133 6133
 	$post_type = get_post_type($master_post_id);
6134
-	$post_table = $plugin_prefix . $post_type . '_detail';
6134
+	$post_table = $plugin_prefix.$post_type.'_detail';
6135 6135
 	
6136
-	$query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
6137
-	$data = (array)$wpdb->get_row($query);
6136
+	$query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
6137
+	$data = (array) $wpdb->get_row($query);
6138 6138
 	
6139
-	if ( !empty( $data ) ) {
6139
+	if (!empty($data)) {
6140 6140
 		$data['post_id'] = $tr_post_id;
6141
-		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
6141
+		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
6142 6142
 		
6143 6143
 		$wpdb->update($post_table, $data, array('post_id' => $tr_post_id));		
6144 6144
 		return true;
@@ -6164,7 +6164,7 @@  discard block
 block discarded – undo
6164 6164
 	global $sitepress, $wpdb;
6165 6165
 	$post_type = get_post_type($master_post_id);
6166 6166
 	
6167
-	remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
6167
+	remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
6168 6168
 
6169 6169
 	$taxonomies = get_object_taxonomies($post_type);
6170 6170
 	foreach ($taxonomies as $taxonomy) {
@@ -6173,9 +6173,9 @@  discard block
 block discarded – undo
6173 6173
 		
6174 6174
 		if ($terms) {
6175 6175
 			foreach ($terms as $term) {
6176
-				$tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
6176
+				$tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
6177 6177
 				
6178
-				if (!is_null($tr_id)){
6178
+				if (!is_null($tr_id)) {
6179 6179
 					// not using get_term - unfiltered get_term
6180 6180
 					$translated_term = $wpdb->get_row($wpdb->prepare("
6181 6181
 						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));
@@ -6184,14 +6184,14 @@  discard block
 block discarded – undo
6184 6184
 				}
6185 6185
 			}
6186 6186
 
6187
-			if (!is_taxonomy_hierarchical($taxonomy)){
6188
-				$terms_array = array_unique( array_map( 'intval', $terms_array ) );
6187
+			if (!is_taxonomy_hierarchical($taxonomy)) {
6188
+				$terms_array = array_unique(array_map('intval', $terms_array));
6189 6189
 			}
6190 6190
 
6191 6191
 			wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
6192 6192
 			
6193
-			if ($taxonomy == $post_type . 'category') {
6194
-				geodir_set_postcat_structure($tr_post_id, $post_type . 'category');
6193
+			if ($taxonomy == $post_type.'category') {
6194
+				geodir_set_postcat_structure($tr_post_id, $post_type.'category');
6195 6195
 			}
6196 6196
 		}
6197 6197
 	}
@@ -6212,15 +6212,15 @@  discard block
 block discarded – undo
6212 6212
 function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
6213 6213
 	global $wpdb;
6214 6214
 	
6215
-	$query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
6215
+	$query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
6216 6216
 	$wpdb->query($query);
6217 6217
 	
6218
-	$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));
6218
+	$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));
6219 6219
 	$post_images = $wpdb->get_results($query);
6220 6220
 	
6221
-	if ( !empty( $post_images ) ) {
6222
-		foreach ( $post_images as $post_image) {
6223
-			$image_data = (array)$post_image;
6221
+	if (!empty($post_images)) {
6222
+		foreach ($post_images as $post_image) {
6223
+			$image_data = (array) $post_image;
6224 6224
 			unset($image_data['ID']);
6225 6225
 			$image_data['post_id'] = $tr_post_id;
6226 6226
 			
@@ -6246,10 +6246,10 @@  discard block
 block discarded – undo
6246 6246
  * @return array Event data array.
6247 6247
  */
6248 6248
 function geodir_imex_get_event_data($post, $gd_post_info) {
6249
-	$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'] ) ) : '';
6249
+	$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'])) : '';
6250 6250
 	$event_enddate = $event_date;
6251
-	$starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : '';
6252
-	$endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : '';
6251
+	$starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
6252
+	$endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
6253 6253
 	
6254 6254
 	$is_recurring_event = '';
6255 6255
 	$event_duration_days = '';
@@ -6266,15 +6266,15 @@  discard block
 block discarded – undo
6266 6266
 		
6267 6267
 	$recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array();
6268 6268
 	if (!empty($recurring_data)) {
6269
-		$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;
6270
-		$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;
6271
-		$starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime;
6272
-		$endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime;
6269
+		$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;
6270
+		$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;
6271
+		$starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
6272
+		$endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
6273 6273
 		$is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : '';
6274 6274
 		$different_times = !empty($recurring_data['different_times']) ? true : false;
6275 6275
 	
6276
-		$recurring_pkg = geodir_event_recurring_pkg( $gd_post_info );
6277
-		$is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true;
6276
+		$recurring_pkg = geodir_event_recurring_pkg($gd_post_info);
6277
+		$is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true;
6278 6278
 			
6279 6279
 		if ($recurring_pkg && $is_recurring) {
6280 6280
 			$recurring_dates = $event_date;
@@ -6284,13 +6284,13 @@  discard block
 block discarded – undo
6284 6284
 			$recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
6285 6285
 			
6286 6286
 			if (!empty($recurring_data['event_recurring_dates'])) {
6287
-				$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
6287
+				$event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
6288 6288
 				
6289 6289
 				if (!empty($event_recurring_dates)) {
6290 6290
 					$recurring_dates = array();
6291 6291
 					
6292 6292
 					foreach ($event_recurring_dates as $date) {
6293
-						$recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) );
6293
+						$recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
6294 6294
 					}
6295 6295
 					
6296 6296
 					$recurring_dates = implode(",", $recurring_dates);
@@ -6306,7 +6306,7 @@  discard block
 block discarded – undo
6306 6306
 						$times = array();
6307 6307
 						
6308 6308
 						foreach ($recurring_data['starttimes'] as $time) {
6309
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6309
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6310 6310
 						}
6311 6311
 						
6312 6312
 						$event_starttimes = implode(",", $times);
@@ -6316,7 +6316,7 @@  discard block
 block discarded – undo
6316 6316
 						$times = array();
6317 6317
 						
6318 6318
 						foreach ($recurring_data['endtimes'] as $time) {
6319
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6319
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6320 6320
 						}
6321 6321
 						
6322 6322
 						$event_endtimes = implode(",", $times);
@@ -6328,8 +6328,8 @@  discard block
 block discarded – undo
6328 6328
 					}
6329 6329
 				}
6330 6330
 			} else {
6331
-				$event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1;
6332
-				$recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6331
+				$event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1;
6332
+				$recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6333 6333
 				
6334 6334
 				if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
6335 6335
 					$week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
@@ -6345,11 +6345,11 @@  discard block
 block discarded – undo
6345 6345
 				}
6346 6346
 				
6347 6347
 				$recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
6348
-				if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
6349
-					$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'] ) ) : '';
6348
+				if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
6349
+					$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'])) : '';
6350 6350
 					$max_recurring_count = empty($recurring_end_date) ? 1 : '';
6351 6351
 				} else {
6352
-					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1);
6352
+					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1);
6353 6353
 				}
6354 6354
 			}
6355 6355
 		}
@@ -6413,9 +6413,9 @@  discard block
 block discarded – undo
6413 6413
  * @return array Event data array.
6414 6414
  */
6415 6415
 function geodir_imex_process_event_data($gd_post) {
6416
-	$recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post );
6416
+	$recurring_pkg = geodir_event_recurring_pkg((object) $gd_post);
6417 6417
 
6418
-	$is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true;
6418
+	$is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true;
6419 6419
 	$event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : '';
6420 6420
 	$event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date;
6421 6421
 	$all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false;
@@ -6462,17 +6462,17 @@  discard block
 block discarded – undo
6462 6462
 				$event_recurring_dates = implode(",", $event_recurring_dates);
6463 6463
 			}
6464 6464
 		} else {
6465
-			$duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1;
6466
-			$repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1;
6467
-			$max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1;
6468
-			$repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6465
+			$duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1;
6466
+			$repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1;
6467
+			$max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1;
6468
+			$repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6469 6469
 			
6470 6470
 			$repeat_end_type = $repeat_end != '' ? 1 : 0;
6471 6471
 			$max_repeat = $repeat_end != '' ? '' : $max_repeat;
6472 6472
 			
6473 6473
 			$week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
6474 6474
 			
6475
-			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6475
+			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6476 6476
 			$repeat_days = array();
6477 6477
 			if (!empty($a_repeat_days)) {
6478 6478
 				foreach ($a_repeat_days as $repeat_day) {
@@ -6490,7 +6490,7 @@  discard block
 block discarded – undo
6490 6490
 			$repeat_weeks = array();
6491 6491
 			if (!empty($a_repeat_weeks)) {
6492 6492
 				foreach ($a_repeat_weeks as $repeat_week) {
6493
-					$repeat_weeks[] = (int)$repeat_week;
6493
+					$repeat_weeks[] = (int) $repeat_week;
6494 6494
 				}
6495 6495
 				
6496 6496
 				$repeat_weeks = array_unique($repeat_weeks);
@@ -6554,7 +6554,7 @@  discard block
 block discarded – undo
6554 6554
 
6555 6555
     $page_found = $wpdb->get_var(
6556 6556
         $wpdb->prepare(
6557
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6557
+            "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
6558 6558
             array($slug)
6559 6559
         )
6560 6560
     );
@@ -6609,7 +6609,7 @@  discard block
 block discarded – undo
6609 6609
  */
6610 6610
 function geodir_admin_upgrade_notice() {
6611 6611
     $class = "error";
6612
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6612
+    $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
6613 6613
     echo"<div class=\"$class\"> <p>$message</p></div>";
6614 6614
 }
6615 6615
 
@@ -6621,7 +6621,7 @@  discard block
 block discarded – undo
6621 6621
  * @param (object) $r
6622 6622
  * @return (string) $output
6623 6623
  */
6624
-function geodire_admin_upgrade_notice( $plugin_data, $r )
6624
+function geodire_admin_upgrade_notice($plugin_data, $r)
6625 6625
 {
6626 6626
     // readme contents
6627 6627
     $args = array(
@@ -6629,7 +6629,7 @@  discard block
 block discarded – undo
6629 6629
         'redirection' => 5
6630 6630
     );
6631 6631
     $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6632
-    $data       = wp_remote_get( $url, $args );
6632
+    $data = wp_remote_get($url, $args);
6633 6633
 
6634 6634
     if (!is_wp_error($data) && $data['response']['code'] == 200) {
6635 6635
 
@@ -6644,20 +6644,20 @@  discard block
 block discarded – undo
6644 6644
 function geodir_in_plugin_update_message($content) {
6645 6645
     // Output Upgrade Notice
6646 6646
     $matches        = null;
6647
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6647
+    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote(GEODIRECTORY_VERSION).'\s*=|$)~Uis';
6648 6648
     $upgrade_notice = '';
6649
-    if ( preg_match( $regexp, $content, $matches ) ) {
6650
-        if(empty($matches)){return;}
6649
+    if (preg_match($regexp, $content, $matches)) {
6650
+        if (empty($matches)) {return; }
6651 6651
 
6652
-        $version = trim( $matches[1] );
6653
-        if($version && $version>GEODIRECTORY_VERSION){
6652
+        $version = trim($matches[1]);
6653
+        if ($version && $version > GEODIRECTORY_VERSION) {
6654 6654
 
6655 6655
 
6656
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6657
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6656
+        $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
6657
+        if (version_compare(GEODIRECTORY_VERSION, $version, '<')) {
6658 6658
             $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6659
-            foreach ( $notices as $index => $line ) {
6660
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6659
+            foreach ($notices as $index => $line) {
6660
+                $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
6661 6661
             }
6662 6662
             $upgrade_notice .= '</div> ';
6663 6663
         }
@@ -6681,7 +6681,7 @@  discard block
 block discarded – undo
6681 6681
 		$default_language = $sitepress->get_default_language();
6682 6682
 		if ($current_language != 'all' && $current_language != $default_language) {
6683 6683
 	?>
6684
-	<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>
6684
+	<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>
6685 6685
 	<?php
6686 6686
 		}
6687 6687
 	}
@@ -6696,7 +6696,7 @@  discard block
 block discarded – undo
6696 6696
  * @param array Listing statuses to be skipped.
6697 6697
  */
6698 6698
 function geodir_imex_export_skip_statuses() {
6699
-    $statuses = array( 'trash', 'auto-draft' );
6699
+    $statuses = array('trash', 'auto-draft');
6700 6700
     
6701 6701
     /**
6702 6702
      * Filter the statuses to skip during GD export listings.
@@ -6706,7 +6706,7 @@  discard block
 block discarded – undo
6706 6706
      *
6707 6707
      * @param array $statuses Listing statuses to be skipped.
6708 6708
      */
6709
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6709
+    $statuses = apply_filters('geodir_imex_export_skip_statuses', $statuses);
6710 6710
      
6711 6711
     return $statuses;
6712 6712
 }
@@ -6746,16 +6746,16 @@  discard block
 block discarded – undo
6746 6746
 function geodir_imex_get_filter_where($where = '', $post_type = '') {
6747 6747
     global $wpdb;
6748 6748
     
6749
-    $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6749
+    $filters = !empty($_REQUEST['gd_imex']) && is_array($_REQUEST['gd_imex']) ? $_REQUEST['gd_imex'] : NULL;
6750 6750
     
6751
-    if ( !empty( $filters ) ) {
6752
-        foreach ( $filters as $field => $value ) {
6751
+    if (!empty($filters)) {
6752
+        foreach ($filters as $field => $value) {
6753 6753
             switch ($field) {
6754 6754
                 case 'start_date':
6755
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6755
+                    $where .= " AND `".$wpdb->posts."`.`post_date` >= '".sanitize_text_field($value)." 00:00:00'";
6756 6756
                 break;
6757 6757
                 case 'end_date':
6758
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6758
+                    $where .= " AND `".$wpdb->posts."`.`post_date` <= '".sanitize_text_field($value)." 23:59:59'";
6759 6759
                 break;
6760 6760
             }
6761 6761
         }
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   +207 added lines, -207 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
 
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 
227 227
         // Filter-Payment-Manager
228 228
 
229
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
229
+        add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
230 230
 
231
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
231
+        add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
232 232
 
233 233
         // no need of this box as all fields moved to main information box
234 234
         //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 }
239 239
 
240
-add_action('save_post', 'geodir_post_information_save',10,2);
240
+add_action('save_post', 'geodir_post_information_save', 10, 2);
241 241
 
242 242
 
243 243
 
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 
265 265
             $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
266 266
 
267
-            if(!empty($gd_taxonomy)) {
267
+            if (!empty($gd_taxonomy)) {
268 268
                 foreach ($gd_taxonomy as $tax) {
269 269
 
270
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
270
+                    remove_meta_box($tax.'div', $geodir_post_type, 'normal');
271 271
 
272 272
                 }
273 273
             }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     global $wpdb;
417 417
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
418 418
     ?>
419
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
419
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
420 420
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
421 421
     <ul>
422 422
     <?php
@@ -427,18 +427,18 @@  discard block
 block discarded – undo
427 427
 
428 428
             $check_html_variable = $wpdb->get_var(
429 429
                 $wpdb->prepare(
430
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
430
+                    "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
431 431
                     array($val['htmlvar_name'], $listing_type, $val['field_type'])
432 432
                 )
433 433
             );
434 434
             
435 435
             $display = $check_html_variable ? ' style="display:none;"' : '';
436 436
             ?>
437
-            <li <?php echo $display;?>>
438
-            <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>"
439
-               title="<?php echo $val['site_title'];?>"
440
-               class="gt-draggable-form-items gt-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>"
441
-               href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a>
437
+            <li <?php echo $display; ?>>
438
+            <a id="gt-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>"
439
+               title="<?php echo $val['site_title']; ?>"
440
+               class="gt-draggable-form-items gt-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>"
441
+               href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory'); ?></a>
442 442
             </li>
443 443
             <?php
444 444
         }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
     <?php 
464 464
         global $wpdb;
465 465
         
466
-        $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
+        $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)));
467 467
 
468 468
         if (!empty($fields)) {
469 469
             foreach ($fields as $field) {
@@ -492,39 +492,39 @@  discard block
 block discarded – undo
492 492
 {
493 493
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
494 494
     ?>
495
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
495
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
496 496
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
497 497
     <ul class="full">
498
-        <li><a id="gt-fieldset" class="gt-draggable-form-items gt-fieldset" href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory');?></a></li>
498
+        <li><a id="gt-fieldset" class="gt-draggable-form-items gt-fieldset" href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory'); ?></a></li>
499 499
     </ul>
500 500
     <ul>
501 501
         <li><a id="gt-text" class="gt-draggable-form-items gt-text"
502
-               href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory');?></a></li>
502
+               href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory'); ?></a></li>
503 503
         <li><a id="gt-datepicker" class="gt-draggable-form-items gt-datepicker"
504
-               href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory');?></a></li>
504
+               href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory'); ?></a></li>
505 505
         <li><a id="gt-textarea" class="gt-draggable-form-items gt-textarea"
506
-               href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory');?></a></li>
506
+               href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory'); ?></a></li>
507 507
         <li><a id="gt-time" class="gt-draggable-form-items gt-time"
508
-               href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory');?></a></li>
508
+               href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory'); ?></a></li>
509 509
         <li><a id="gt-checkbox" class="gt-draggable-form-items gt-checkbox"
510
-               href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory');?></a></li>
510
+               href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory'); ?></a></li>
511 511
         <li><a id="gt-phone" class="gt-draggable-form-items gt-phone"
512
-               href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory');?></a></li>
512
+               href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory'); ?></a></li>
513 513
         <li><a id="gt-radio" class="gt-draggable-form-items gt-radio"
514
-               href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory');?></a></li>
514
+               href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory'); ?></a></li>
515 515
         <li><a id="gt-email" class="gt-draggable-form-items gt-email"
516
-               href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory');?></a></li>
516
+               href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory'); ?></a></li>
517 517
         <li><a id="gt-select" class="gt-draggable-form-items gt-select"
518
-               href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory');?></a></li>
519
-        <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory');?></a></li>-->
518
+               href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory'); ?></a></li>
519
+        <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory'); ?></a></li>-->
520 520
         <li><a id="gt-multiselect" class="gt-draggable-form-items gt-multiselect"
521
-               href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory');?></a></li>
521
+               href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory'); ?></a></li>
522 522
         <li><a id="gt-url" class="gt-draggable-form-items gt-url"
523
-               href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory');?></a></li>
523
+               href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory'); ?></a></li>
524 524
         <li><a id="gt-html" class="gt-draggable-form-items gt-html"
525
-               href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory');?></a></li>
525
+               href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory'); ?></a></li>
526 526
         <li><a id="gt-file" class="gt-draggable-form-items gt-file"
527
-               href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory');?></a></li>
527
+               href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory'); ?></a></li>
528 528
 
529 529
     </ul>
530 530
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     <ul class="core">
549 549
     <?php 
550 550
         global $wpdb;
551
-        $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
+        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
552 552
 
553 553
         if (!empty($fields)) {
554 554
             foreach ($fields as $field) {
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 
636 636
     switch ($sub_tab) {
637 637
         case 'custom_fields':
638
-            $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
+            $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)); ;
639 639
             break;
640 640
 
641 641
         case 'sorting_options':
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 
690 690
     switch ($sub_tab) {
691 691
         case 'custom_fields':
692
-            $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
+            $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)); ;
693 693
             break;
694 694
 
695 695
         case 'sorting_options':
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 
717 717
     if (!get_option('geodir_remove_unnecessary_fields')) {
718 718
 
719
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
720
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
719
+        if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'"))
720
+            $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`");
721 721
 
722 722
         update_option('geodir_remove_unnecessary_fields', '1');
723 723
 
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
             case 'diagnosis' :
746 746
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
747 747
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
748
-                call_user_func('geodir_diagnose_' . $diagnose_this);
748
+                call_user_func('geodir_diagnose_'.$diagnose_this);
749 749
                 exit();
750 750
                 break;
751 751
 
752 752
             case 'diagnosis-fix' :
753 753
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
754 754
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
755
-                call_user_func('geodir_diagnose_' . $diagnose_this);
755
+                call_user_func('geodir_diagnose_'.$diagnose_this);
756 756
                 exit();
757 757
                 break;
758 758
         }
@@ -777,50 +777,50 @@  discard block
 block discarded – undo
777 777
 {
778 778
     global $wpdb;
779 779
     //$filter_arr['output_str'] .='###'.$table.'###';
780
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
781
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
780
+    if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) {
781
+        $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>";
782 782
         $filter_arr['is_error_during_diagnose'] = true;
783 783
 
784
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
785
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
784
+    } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
785
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>";
786 786
         $filter_arr['is_error_during_diagnose'] = true;
787
-        $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['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>";
788 788
         $filter_arr['is_error_during_diagnose'] = true;
789 789
 
790 790
         if ($fix) {
791
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
792
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
791
+            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count
792
+            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count
793 793
 
794 794
             if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
795 795
                 //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
796 796
 
797
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
797
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table
798 798
 
799
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
800
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
799
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
800
+                    $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>";
801 801
                 } else {
802
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
802
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
803 803
                 }
804 804
 
805 805
             } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
806 806
 
807
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
808
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
807
+                $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2
808
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table
809 809
 
810
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
811
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
810
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
811
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>";
812 812
                 } else {
813
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
813
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
814 814
                 }
815 815
 
816 816
             } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
817 817
 
818
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
818
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2
819 819
 
820
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
821
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
820
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
821
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>";
822 822
                 } else {
823
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
823
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
824 824
                 }
825 825
 
826 826
             }
@@ -828,54 +828,54 @@  discard block
 block discarded – undo
828 828
         }
829 829
 
830 830
 
831
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
832
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
831
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
832
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>";
833 833
         $filter_arr['is_error_during_diagnose'] = true;
834 834
 
835 835
         if ($fix) {
836 836
             if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
837 837
                 if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
838
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
838
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>";
839 839
                 } else {
840
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
840
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>";
841 841
                 }
842 842
 
843
-            } 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
844
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
845
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
843
+            } 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
844
+                if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) {
845
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>";
846 846
                 } else {
847
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
847
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>";
848 848
                 }
849
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
850
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
849
+                if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
850
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
851 851
                 } else {
852
-                    $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
+                    $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>";
853 853
                 }
854 854
             } else {// else rename the original table to _ms_bak
855
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
856
-                    $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>";
855
+                if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
856
+                    $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>";
857 857
                 } else {
858
-                    $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
+                    $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>";
859 859
                 }
860 860
             }
861 861
         }
862 862
 
863
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
864
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
863
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
864
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>";
865 865
         $filter_arr['is_error_during_diagnose'] = true;
866 866
 
867 867
         if ($fix) {
868 868
             // if original table exists but new does not, rename
869
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
870
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
869
+            if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
870
+                $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
871 871
             } else {
872
-                $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
+                $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>";
873 873
             }
874 874
 
875 875
         }
876 876
 
877
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
878
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
877
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
878
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>";
879 879
         $filter_arr['is_error_during_diagnose'] = true;
880 880
 
881 881
         if ($fix) {
@@ -889,11 +889,11 @@  discard block
 block discarded – undo
889 889
             delete_option('geodir_custom_posts_db_version');
890 890
             delete_option('geodir_reviewratings_db_version');
891 891
             delete_option('geodiradvancesearch_db_version');
892
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
892
+            $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>";
893 893
         }
894 894
 
895 895
     } else {
896
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
896
+        $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>";
897 897
     }
898 898
     return $filter_arr;
899 899
 }
@@ -922,23 +922,23 @@  discard block
 block discarded – undo
922 922
     if (!empty($all_postypes)) {
923 923
         foreach ($all_postypes as $key) {
924 924
             // update each GD CPT
925
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
925
+            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d");
926 926
 
927 927
             if (!empty($posts)) {
928 928
 
929 929
                 foreach ($posts as $p) {
930 930
                     $p->post_type = $key;
931
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
931
+                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
932 932
                     if (empty($raw_tags)) {
933 933
                         $post_tags = '';
934 934
                     } else {
935 935
                         $post_tags = implode(",", $raw_tags);
936 936
                     }
937
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
938
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
937
+                    $tablename = $plugin_prefix.$p->post_type.'_detail';
938
+                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
939 939
 
940 940
                 }
941
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
941
+                $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
942 942
             }
943 943
 
944 944
         }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 
948 948
     if ($is_error_during_diagnose) {
949 949
         $info_div_class = "geodir_problem_info";
950
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
950
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
951 951
     } else {
952 952
         $info_div_class = "geodir_noproblem_info";
953 953
         $fix_button_txt = '';
@@ -984,29 +984,29 @@  discard block
 block discarded – undo
984 984
     if (!empty($all_postypes)) {
985 985
         foreach ($all_postypes as $key) {
986 986
             // update each GD CTP
987
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
987
+            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' ");
988 988
 
989 989
             if (!empty($posts)) {
990 990
 
991 991
                 foreach ($posts as $p) {
992 992
                     $p->post_type = $key;
993
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
993
+                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids'));
994 994
 
995 995
                     if (empty($raw_cats)) {
996 996
                         $post_categories = get_post_meta($p->post_id, 'post_categories', true);
997 997
 
998
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
999
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1000
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
998
+                        if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) {
999
+                            $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']);
1000
+                            foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) {
1001 1001
                                 if (is_numeric($cat_part)) {
1002
-                                    $raw_cats[] = (int)$cat_part;
1002
+                                    $raw_cats[] = (int) $cat_part;
1003 1003
                                 }
1004 1004
                             }
1005 1005
 
1006 1006
                         }
1007 1007
 
1008 1008
                         if (!empty($raw_cats)) {
1009
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1009
+                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category');
1010 1010
 
1011 1011
                         }
1012 1012
 
@@ -1016,14 +1016,14 @@  discard block
 block discarded – undo
1016 1016
                     if (empty($raw_cats)) {
1017 1017
                         $post_cats = '';
1018 1018
                     } else {
1019
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1019
+                        $post_cats = ','.implode(",", $raw_cats).',';
1020 1020
                     }
1021
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1022
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1021
+                    $tablename = $plugin_prefix.$p->post_type.'_detail';
1022
+                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1023 1023
                 }
1024 1024
 
1025 1025
             }
1026
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1026
+            $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
1027 1027
 
1028 1028
         }
1029 1029
 
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
     if ($is_error_during_diagnose) {
1033 1033
         $info_div_class = "geodir_problem_info";
1034
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1034
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1035 1035
     } else {
1036 1036
         $info_div_class = "geodir_noproblem_info";
1037 1037
         $fix_button_txt = '';
@@ -1084,15 +1084,15 @@  discard block
 block discarded – undo
1084 1084
     if (!empty($ver_arr)) {
1085 1085
         foreach ($ver_arr as $key => $val) {
1086 1086
             if (delete_option($val)) {
1087
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1087
+                $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>";
1088 1088
             } else {
1089
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1089
+                $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>";
1090 1090
             }
1091 1091
 
1092 1092
         }
1093 1093
 
1094 1094
         if ($output_str) {
1095
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1095
+            $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>";
1096 1096
         }
1097 1097
 
1098 1098
     }
@@ -1129,43 +1129,43 @@  discard block
 block discarded – undo
1129 1129
     $output_str = '';
1130 1130
 
1131 1131
     // check review locations
1132
-    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")) {
1133
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1132
+    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")) {
1133
+        $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>";
1134 1134
         $is_error_during_diagnose = true;
1135 1135
 
1136 1136
         if ($fix) {
1137 1137
             if (geodir_fix_review_location()) {
1138
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1138
+                $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>";
1139 1139
             } else {
1140
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1140
+                $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>";
1141 1141
             }
1142 1142
         }
1143 1143
 
1144 1144
     } else {
1145
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1145
+        $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>";
1146 1146
     }
1147 1147
 
1148 1148
     // check review content
1149
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1150
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1149
+    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) {
1150
+        $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>";
1151 1151
         $is_error_during_diagnose = true;
1152 1152
 
1153 1153
         if ($fix) {
1154 1154
             if (geodir_fix_review_content()) {
1155
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1155
+                $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>";
1156 1156
             } else {
1157
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1157
+                $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>";
1158 1158
             }
1159 1159
         }
1160 1160
 
1161 1161
     } else {
1162
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1162
+        $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>";
1163 1163
     }
1164 1164
 
1165 1165
 
1166 1166
     if ($is_error_during_diagnose) {
1167 1167
         $info_div_class = "geodir_problem_info";
1168
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1168
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1169 1169
     } else {
1170 1170
         $info_div_class = "geodir_noproblem_info";
1171 1171
         $fix_button_txt = '';
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 
1230 1230
     if ($is_error_during_diagnose) {
1231 1231
         $info_div_class = "geodir_problem_info";
1232
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1232
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1233 1233
     } else {
1234 1234
         $info_div_class = "geodir_noproblem_info";
1235 1235
         $fix_button_txt = '';
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
     else {
1264 1264
         $page_found = $wpdb->get_var(
1265 1265
             $wpdb->prepare(
1266
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1266
+                "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
1267 1267
                 array($slug)
1268 1268
             )
1269 1269
         );
@@ -1309,18 +1309,18 @@  discard block
 block discarded – undo
1309 1309
     //////////////////////////////////
1310 1310
     $option_value = get_option('geodir_home_page');
1311 1311
     $page = get_post($option_value);
1312
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1312
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1313 1313
 
1314
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1315
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1314
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1315
+        $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>";
1316 1316
     else {
1317 1317
         $is_error_during_diagnose = true;
1318
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1318
+        $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>";
1319 1319
         if ($fix) {
1320 1320
             if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1321
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1321
+                $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>";
1322 1322
             } else {
1323
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1323
+                $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>";
1324 1324
             }
1325 1325
         }
1326 1326
     }
@@ -1334,18 +1334,18 @@  discard block
 block discarded – undo
1334 1334
     //////////////////////////////////
1335 1335
     $option_value = get_option('geodir_add_listing_page');
1336 1336
     $page = get_post($option_value);
1337
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1337
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1338 1338
 
1339
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1340
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1339
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1340
+        $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>";
1341 1341
     else {
1342 1342
         $is_error_during_diagnose = true;
1343
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1343
+        $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>";
1344 1344
         if ($fix) {
1345 1345
             if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1346
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1346
+                $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>";
1347 1347
             } else {
1348
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1348
+                $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>";
1349 1349
             }
1350 1350
         }
1351 1351
     }
@@ -1360,18 +1360,18 @@  discard block
 block discarded – undo
1360 1360
     //////////////////////////////////
1361 1361
     $option_value = get_option('geodir_preview_page');
1362 1362
     $page = get_post($option_value);
1363
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1363
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1364 1364
 
1365
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1366
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1365
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1366
+        $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>";
1367 1367
     else {
1368 1368
         $is_error_during_diagnose = true;
1369
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1369
+        $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>";
1370 1370
         if ($fix) {
1371 1371
             if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1372
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1372
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>";
1373 1373
             } else {
1374
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1374
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>";
1375 1375
             }
1376 1376
         }
1377 1377
     }
@@ -1385,18 +1385,18 @@  discard block
 block discarded – undo
1385 1385
     //////////////////////////////////
1386 1386
     $option_value = get_option('geodir_success_page');
1387 1387
     $page = get_post($option_value);
1388
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1388
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1389 1389
 
1390
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1391
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1390
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1391
+        $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>";
1392 1392
     else {
1393 1393
         $is_error_during_diagnose = true;
1394
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1394
+        $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>";
1395 1395
         if ($fix) {
1396 1396
             if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1397
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1397
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>";
1398 1398
             } else {
1399
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1399
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>";
1400 1400
             }
1401 1401
         }
1402 1402
     }
@@ -1410,18 +1410,18 @@  discard block
 block discarded – undo
1410 1410
     //////////////////////////////////
1411 1411
     $option_value = get_option('geodir_info_page');
1412 1412
     $page = get_post($option_value);
1413
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1413
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1414 1414
 
1415
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1416
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1415
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1416
+        $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>";
1417 1417
     else {
1418 1418
         $is_error_during_diagnose = true;
1419
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1419
+        $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>";
1420 1420
         if ($fix) {
1421 1421
             if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1422
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1422
+                $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>";
1423 1423
             } else {
1424
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1424
+                $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>";
1425 1425
             }
1426 1426
         }
1427 1427
     }
@@ -1435,18 +1435,18 @@  discard block
 block discarded – undo
1435 1435
     //////////////////////////////////
1436 1436
     $option_value = get_option('geodir_login_page');
1437 1437
     $page = get_post($option_value);
1438
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1438
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1439 1439
 
1440
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1441
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1440
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1441
+        $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>";
1442 1442
     else {
1443 1443
         $is_error_during_diagnose = true;
1444
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1444
+        $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>";
1445 1445
         if ($fix) {
1446 1446
             if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1447
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1447
+                $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>";
1448 1448
             } else {
1449
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1449
+                $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>";
1450 1450
             }
1451 1451
         }
1452 1452
     }
@@ -1460,18 +1460,18 @@  discard block
 block discarded – undo
1460 1460
     //////////////////////////////////
1461 1461
     $option_value = get_option('geodir_location_page');
1462 1462
     $page = get_post($option_value);
1463
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1463
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1464 1464
 
1465
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1466
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1465
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1466
+        $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>";
1467 1467
     else {
1468 1468
         $is_error_during_diagnose = true;
1469
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1469
+        $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>";
1470 1470
         if ($fix) {
1471 1471
             if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1472
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1472
+                $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>";
1473 1473
             } else {
1474
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1474
+                $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>";
1475 1475
             }
1476 1476
         }
1477 1477
     }
@@ -1480,13 +1480,13 @@  discard block
 block discarded – undo
1480 1480
     /* Diagnose Location Page Ends */
1481 1481
     ////////////////////////////////
1482 1482
 
1483
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1483
+    $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
1484 1484
     /**
1485 1485
      * This action is called at the end of the GD Tools page check function.
1486 1486
      *
1487 1487
      * @since 1.5.2
1488 1488
      */
1489
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1489
+    $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
1490 1490
 
1491 1491
     $output_str = $page_chk_arr['output_str'];
1492 1492
     $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
             flush_rewrite_rules();
1497 1497
         }
1498 1498
         $info_div_class = "geodir_problem_info";
1499
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1499
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1500 1500
     } else {
1501 1501
         $info_div_class = "geodir_noproblem_info";
1502 1502
         $fix_button_txt = '';
@@ -1523,10 +1523,10 @@  discard block
 block discarded – undo
1523 1523
     $output_str = '';
1524 1524
 
1525 1525
     if ($is_error_during_diagnose) {
1526
-        $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
+        $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>";
1527 1527
 		$info_div_class = "geodir_problem_info";
1528 1528
     } else {
1529
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1529
+        $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>";
1530 1530
 		$info_div_class = "geodir_noproblem_info";
1531 1531
         $fix_button_txt = '';
1532 1532
     }
@@ -1568,17 +1568,17 @@  discard block
 block discarded – undo
1568 1568
     global $wpdb, $wp_query, $plugin_prefix;
1569 1569
 
1570 1570
     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'])) {
1571
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1571
+        $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail';
1572 1572
 
1573
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1573
+        $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)';
1574 1574
         $clauses['join'] = $join;
1575 1575
 
1576
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1576
+        $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : '';
1577 1577
         $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';
1578 1578
         $clauses['fields'] = $fields;
1579 1579
 
1580 1580
         $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1581
-        $orderby = 'gd_expire ' . $order;
1581
+        $orderby = 'gd_expire '.$order;
1582 1582
         $clauses['orderby'] = $orderby;
1583 1583
     }
1584 1584
     return $clauses;
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
         global $current_user;
1622 1622
         $upload_dir = wp_upload_dir();
1623 1623
 
1624
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1624
+        $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv';
1625 1625
         $handle = fopen($file, 'w');
1626 1626
 
1627 1627
         fwrite($handle, $input);
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
     $uploads_dir = $uploads['path'];
1667 1667
     $image_name_arr = explode('/', $filename);
1668 1668
     $filename = end($image_name_arr);
1669
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1669
+    $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1670 1670
     $return = array();
1671 1671
     $return['file'] = $uploadedFile;
1672 1672
     $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
@@ -1683,8 +1683,8 @@  discard block
 block discarded – undo
1683 1683
 
1684 1684
                 if (($handle = fopen($target_path, "r")) !== FALSE) {
1685 1685
                     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1686
-                        if(is_array($data) && !empty($data)) {
1687
-                            $file[] = '"' . implode('","', $data) . '"';
1686
+                        if (is_array($data) && !empty($data)) {
1687
+                            $file[] = '"'.implode('","', $data).'"';
1688 1688
                         }
1689 1689
                     }
1690 1690
                     fclose($handle);
@@ -1801,10 +1801,10 @@  discard block
 block discarded – undo
1801 1801
                     $tag_arr = explode(',', $post_tags);
1802 1802
                 }
1803 1803
 
1804
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1804
+                $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database
1805 1805
 
1806 1806
                 $error = '';
1807
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1807
+                if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) {
1808 1808
                     $invalid_post_type++;
1809 1809
                     continue;
1810 1810
                 }
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
                             if ($buffer[$c] != '0' && $buffer[$c] != '') {
1831 1831
                                 $submitdata = date('Y-m-d');
1832 1832
 
1833
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1833
+                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days"));
1834 1834
                             } else {
1835 1835
                                 $gd_post_info['expire_date'] = 'Never';
1836 1836
                             }
@@ -1858,7 +1858,7 @@  discard block
 block discarded – undo
1858 1858
 						
1859 1859
 						// Post status
1860 1860
 						if ($customKeyarray[$c] == 'post_status') {
1861
-                            $post_status = sanitize_key( $buffer[$c] );
1861
+                            $post_status = sanitize_key($buffer[$c]);
1862 1862
                         }
1863 1863
                     }
1864 1864
 
@@ -1876,8 +1876,8 @@  discard block
 block discarded – undo
1876 1876
 					
1877 1877
 					// Default post status
1878 1878
 					$default_status = 'publish';
1879
-					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
1880
-					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
1879
+					$post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
1880
+					$post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
1881 1881
 
1882 1882
                     $my_post['post_title'] = $post_title;
1883 1883
                     $my_post['post_content'] = $post_desc;
@@ -1921,7 +1921,7 @@  discard block
 block discarded – undo
1921 1921
                     $payment_info = array();
1922 1922
                     $package_info = array();
1923 1923
 
1924
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1924
+                    $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]);
1925 1925
                     $package_id = '';
1926 1926
                     if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1927 1927
                         $package_id = $gd_post_info['package_id'];
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
                         $payment_info['package_id'] = $package_info['pid'];
1932 1932
 
1933 1933
                         if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1934
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1934
+                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days"));
1935 1935
                         } else {
1936 1936
                             $payment_info['expire_date'] = 'Never';
1937 1937
                         }
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
 
1944 1944
                     $post_type = get_post_type($last_postid);
1945 1945
 
1946
-                    $table = $plugin_prefix . $post_type . '_detail';
1946
+                    $table = $plugin_prefix.$post_type.'_detail';
1947 1947
 
1948 1948
                     geodir_save_post_info($last_postid, $gd_post_info);
1949 1949
 
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
                             $attachment['post_id'] = $last_postid;
1965 1965
                             $attachment['title'] = $img_name_arr[0];
1966 1966
                             $attachment['content'] = '';
1967
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
1967
+                            $attachment['file'] = $sub_dir.'/'.$image_name;
1968 1968
                             $attachment['mime_type'] = $uploaded_file_type;
1969 1969
                             $attachment['menu_order'] = $menu_order;
1970 1970
                             $attachment['is_featured'] = 0;
@@ -1973,15 +1973,15 @@  discard block
 block discarded – undo
1973 1973
 
1974 1974
                             foreach ($attachment as $key => $val) {
1975 1975
                                 if ($val != '')
1976
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1976
+                                    $attachment_set .= $key." = '".$val."', ";
1977 1977
                             }
1978 1978
                             $attachment_set = trim($attachment_set, ", ");
1979 1979
 
1980
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1980
+                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
1981 1981
 
1982 1982
                             if ($menu_order == 1) {
1983 1983
                                 $post_type = get_post_type($last_postid);
1984
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1984
+                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid)));
1985 1985
                             }
1986 1986
                             $menu_order++;
1987 1987
                         }
@@ -2022,11 +2022,11 @@  discard block
 block discarded – undo
2022 2022
 }
2023 2023
 
2024 2024
 // Add the tab in left sidebar menu fro import & export page.
2025
-add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 );
2025
+add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
2026 2026
 
2027 2027
 // Handle ajax request for import/export.
2028
-add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' );
2029
-add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' );
2028
+add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
2029
+add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
2030 2030
 
2031 2031
 
2032 2032
 /**
@@ -2037,40 +2037,40 @@  discard block
 block discarded – undo
2037 2037
  * @param $post_id int $post_id The post ID of the post being saved.
2038 2038
  * @param $post object $post The post object of the post being saved.
2039 2039
  */
2040
-function geodir_update_location_prefix($post_id,$post){
2041
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2042
-        update_option('geodir_location_prefix',$post->post_name);
2040
+function geodir_update_location_prefix($post_id, $post) {
2041
+    if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
2042
+        update_option('geodir_location_prefix', $post->post_name);
2043 2043
     }
2044 2044
 
2045 2045
 }
2046 2046
 
2047
-add_action('save_post', 'geodir_update_location_prefix',10,2);
2047
+add_action('save_post', 'geodir_update_location_prefix', 10, 2);
2048 2048
 
2049
-add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' );
2049
+add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
2050 2050
 
2051
-function geodir_ga_callback(){
2051
+function geodir_ga_callback() {
2052 2052
 
2053
-if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2053
+if (isset($_REQUEST['code']) && $_REQUEST['code']) {
2054 2054
     $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2055 2055
     $code = "code=".$_REQUEST['code'];
2056 2056
     $grant_type = "&grant_type=authorization_code";
2057
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2057
+    $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
2058 2058
     $client_id = "&client_id=".get_option('geodir_ga_client_id');
2059 2059
     $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2060 2060
 
2061
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2061
+    $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret;
2062 2062
 
2063 2063
     $response = wp_remote_post($auth_url, array('timeout' => 15));
2064 2064
 
2065 2065
     //print_r($response);
2066 2066
 
2067
-    $error_msg =  __('Something went wrong','geodirectory');
2068
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2067
+    $error_msg = __('Something went wrong', 'geodirectory');
2068
+    if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
2069 2069
 
2070 2070
         $parts = json_decode($response['body']);
2071 2071
         //print_r($parts);
2072
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2073
-        else{
2072
+        if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; }
2073
+        else {
2074 2074
 
2075 2075
             update_option('gd_ga_access_token', $parts->access_token);
2076 2076
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2079,25 +2079,25 @@  discard block
 block discarded – undo
2079 2079
 
2080 2080
 
2081 2081
     }
2082
-    elseif(!empty($response['response']['code'])) {
2082
+    elseif (!empty($response['response']['code'])) {
2083 2083
         $parts = json_decode($response['body']);
2084 2084
 
2085
-        if(isset($parts->error)){
2086
-            echo $parts->error.": ".$parts->error_description;exit;
2087
-        }else{
2088
-            echo $error_msg." - #2";exit;
2085
+        if (isset($parts->error)) {
2086
+            echo $parts->error.": ".$parts->error_description; exit;
2087
+        } else {
2088
+            echo $error_msg." - #2"; exit;
2089 2089
         }
2090 2090
 
2091
-    }else{
2091
+    } else {
2092 2092
 
2093
-        echo $error_msg." - #3";exit;
2093
+        echo $error_msg." - #3"; exit;
2094 2094
 
2095 2095
     }
2096 2096
 }
2097 2097
     exit;
2098 2098
 }
2099 2099
 
2100
-add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
2100
+add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
2101 2101
 
2102 2102
 if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
2103 2103
 	add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
Please login to merge, or discard this patch.
Braces   +58 added lines, -50 removed lines patch added patch discarded remove patch
@@ -24,8 +24,11 @@  discard block
 block discarded – undo
24 24
             global $current_tab;
25 25
             geodir_redirect_to_admin_panel_on_installed();
26 26
             $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
27
+            if (!(isset($_REQUEST['action']))) {
28
+            	// this will avoid Ajax requests
29
+                geodir_handle_option_form_submit($current_tab);
30
+            }
31
+            // located in admin function.php
29 32
             /**
30 33
              * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31 34
              *
@@ -314,8 +317,9 @@  discard block
 block discarded – undo
314 317
     if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
315 318
 
316 319
         foreach ($notification as $key => $value) {
317
-            if ($value['type'] == 'textarea')
318
-                $notification[$key]['type'] = 'editor';
320
+            if ($value['type'] == 'textarea') {
321
+                            $notification[$key]['type'] = 'editor';
322
+            }
319 323
         }
320 324
 
321 325
     }
@@ -340,8 +344,9 @@  discard block
 block discarded – undo
340 344
     if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
341 345
 
342 346
         foreach ($design_setting as $key => $value) {
343
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
344
-                $design_setting[$key]['type'] = 'editor';
347
+            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') {
348
+                            $design_setting[$key]['type'] = 'editor';
349
+            }
345 350
         }
346 351
 
347 352
     }
@@ -716,8 +721,9 @@  discard block
 block discarded – undo
716 721
 
717 722
     if (!get_option('geodir_remove_unnecessary_fields')) {
718 723
 
719
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
720
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
724
+        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) {
725
+                    $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
726
+        }
721 727
 
722 728
         update_option('geodir_remove_unnecessary_fields', '1');
723 729
 
@@ -743,15 +749,17 @@  discard block
 block discarded – undo
743 749
         $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
744 750
         switch ($geodir_admin_ajax_action) {
745 751
             case 'diagnosis' :
746
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
747
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
752
+                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
753
+                                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
754
+                }
748 755
                 call_user_func('geodir_diagnose_' . $diagnose_this);
749 756
                 exit();
750 757
                 break;
751 758
 
752 759
             case 'diagnosis-fix' :
753
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
754
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
760
+                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
761
+                                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
762
+                }
755 763
                 call_user_func('geodir_diagnose_' . $diagnose_this);
756 764
                 exit();
757 765
                 break;
@@ -1309,11 +1317,11 @@  discard block
 block discarded – undo
1309 1317
     //////////////////////////////////
1310 1318
     $option_value = get_option('geodir_home_page');
1311 1319
     $page = get_post($option_value);
1312
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1320
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1313 1321
 
1314
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1315
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1316
-    else {
1322
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1323
+            $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1324
+    } else {
1317 1325
         $is_error_during_diagnose = true;
1318 1326
         $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1319 1327
         if ($fix) {
@@ -1334,11 +1342,11 @@  discard block
 block discarded – undo
1334 1342
     //////////////////////////////////
1335 1343
     $option_value = get_option('geodir_add_listing_page');
1336 1344
     $page = get_post($option_value);
1337
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1345
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1338 1346
 
1339
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1340
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1341
-    else {
1347
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1348
+            $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1349
+    } else {
1342 1350
         $is_error_during_diagnose = true;
1343 1351
         $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1344 1352
         if ($fix) {
@@ -1360,11 +1368,11 @@  discard block
 block discarded – undo
1360 1368
     //////////////////////////////////
1361 1369
     $option_value = get_option('geodir_preview_page');
1362 1370
     $page = get_post($option_value);
1363
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1371
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1364 1372
 
1365
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1366
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1367
-    else {
1373
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1374
+            $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1375
+    } else {
1368 1376
         $is_error_during_diagnose = true;
1369 1377
         $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1370 1378
         if ($fix) {
@@ -1385,11 +1393,11 @@  discard block
 block discarded – undo
1385 1393
     //////////////////////////////////
1386 1394
     $option_value = get_option('geodir_success_page');
1387 1395
     $page = get_post($option_value);
1388
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1396
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1389 1397
 
1390
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1391
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1392
-    else {
1398
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1399
+            $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1400
+    } else {
1393 1401
         $is_error_during_diagnose = true;
1394 1402
         $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1395 1403
         if ($fix) {
@@ -1410,11 +1418,11 @@  discard block
 block discarded – undo
1410 1418
     //////////////////////////////////
1411 1419
     $option_value = get_option('geodir_info_page');
1412 1420
     $page = get_post($option_value);
1413
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1421
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1414 1422
 
1415
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1416
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1417
-    else {
1423
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1424
+            $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1425
+    } else {
1418 1426
         $is_error_during_diagnose = true;
1419 1427
         $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1420 1428
         if ($fix) {
@@ -1435,11 +1443,11 @@  discard block
 block discarded – undo
1435 1443
     //////////////////////////////////
1436 1444
     $option_value = get_option('geodir_login_page');
1437 1445
     $page = get_post($option_value);
1438
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1446
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1439 1447
 
1440
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1441
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1442
-    else {
1448
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1449
+            $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1450
+    } else {
1443 1451
         $is_error_during_diagnose = true;
1444 1452
         $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1445 1453
         if ($fix) {
@@ -1460,11 +1468,11 @@  discard block
 block discarded – undo
1460 1468
     //////////////////////////////////
1461 1469
     $option_value = get_option('geodir_location_page');
1462 1470
     $page = get_post($option_value);
1463
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1471
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1464 1472
 
1465
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1466
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1467
-    else {
1473
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1474
+            $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1475
+    } else {
1468 1476
         $is_error_during_diagnose = true;
1469 1477
         $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1470 1478
         if ($fix) {
@@ -1908,8 +1916,9 @@  discard block
 block discarded – undo
1908 1916
                             );
1909 1917
 
1910 1918
                             $post_location_info = $request_info['post_location'];
1911
-                            if ($location_id = geodir_add_new_location($post_location_info))
1912
-                                $post_location_id = $location_id;
1919
+                            if ($location_id = geodir_add_new_location($post_location_info)) {
1920
+                                                            $post_location_id = $location_id;
1921
+                            }
1913 1922
                         } else {
1914 1923
                             $post_location_id = 0;
1915 1924
                         }
@@ -1972,8 +1981,9 @@  discard block
 block discarded – undo
1972 1981
                             $attachment_set = '';
1973 1982
 
1974 1983
                             foreach ($attachment as $key => $val) {
1975
-                                if ($val != '')
1976
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1984
+                                if ($val != '') {
1985
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
1986
+                                }
1977 1987
                             }
1978 1988
                             $attachment_set = trim($attachment_set, ", ");
1979 1989
 
@@ -2069,8 +2079,7 @@  discard block
 block discarded – undo
2069 2079
 
2070 2080
         $parts = json_decode($response['body']);
2071 2081
         //print_r($parts);
2072
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2073
-        else{
2082
+        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{
2074 2083
 
2075 2084
             update_option('gd_ga_access_token', $parts->access_token);
2076 2085
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2078,17 +2087,16 @@  discard block
 block discarded – undo
2078 2087
         }
2079 2088
 
2080 2089
 
2081
-    }
2082
-    elseif(!empty($response['response']['code'])) {
2090
+    } elseif(!empty($response['response']['code'])) {
2083 2091
         $parts = json_decode($response['body']);
2084 2092
 
2085 2093
         if(isset($parts->error)){
2086 2094
             echo $parts->error.": ".$parts->error_description;exit;
2087
-        }else{
2095
+        } else{
2088 2096
             echo $error_msg." - #2";exit;
2089 2097
         }
2090 2098
 
2091
-    }else{
2099
+    } else{
2092 2100
 
2093 2101
         echo $error_msg." - #3";exit;
2094 2102
 
Please login to merge, or discard this patch.
Indentation   +1300 added lines, -1300 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 
11 11
 add_action('admin_init', 'geodir_admin_init');
12 12
 if (!function_exists('geodir_admin_init')) {
13
-    /**
14
-     * Adds GD setting pages in admin.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global string $current_tab The current settings tab name.
19
-     */
20
-    function geodir_admin_init()
21
-    {
22
-
23
-        if (is_admin()):
24
-            global $current_tab;
25
-            geodir_redirect_to_admin_panel_on_installed();
26
-            $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
-            /**
30
-             * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
-             *
32
-             * @since 1.0.0
33
-             */
34
-            do_action('admin_panel_init');
35
-            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
-
37
-
38
-        endif;
39
-    }
13
+	/**
14
+	 * Adds GD setting pages in admin.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global string $current_tab The current settings tab name.
19
+	 */
20
+	function geodir_admin_init()
21
+	{
22
+
23
+		if (is_admin()):
24
+			global $current_tab;
25
+			geodir_redirect_to_admin_panel_on_installed();
26
+			$current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
+			if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
+				geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
+			/**
30
+			 * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
+			 *
32
+			 * @since 1.0.0
33
+			 */
34
+			do_action('admin_panel_init');
35
+			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
+
37
+
38
+		endif;
39
+	}
40 40
 }
41 41
 
42 42
 /**
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_redirect_to_admin_panel_on_installed()
49 49
 {
50
-    if (get_option('geodir_installation_redirect', false)) {
51
-        delete_option('geodir_installation_redirect');
52
-        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
-    }
50
+	if (get_option('geodir_installation_redirect', false)) {
51
+		delete_option('geodir_installation_redirect');
52
+		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
+	}
54 54
 }
55 55
 
56 56
 /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+	geodir_admin_option_form($current_tab);// defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_conditional_admin_script_load()
87 87
 {
88
-    global $pagenow;
88
+	global $pagenow;
89 89
 	
90 90
 	// Get the current post type
91 91
 	$post_type = geodir_admin_current_post_type();
92 92
 	$geodir_post_types = geodir_get_posttypes();
93 93
     
94 94
 	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
95
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
-        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
-    }
95
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
+		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
+	}
99 99
 
100
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
100
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
101 101
 
102 102
 }
103 103
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function create_default_admin_main_nav()
133 133
 {
134
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
134
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
140 140
 
141 141
 }
142 142
 
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function geodir_admin_list_columns()
151 151
 {
152
-    if ($post_types = geodir_get_posttypes()) {
152
+	if ($post_types = geodir_get_posttypes()) {
153 153
 
154
-        foreach ($post_types as $post_type):
155
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
-            //Filter-Payment-Manager to show Package
157
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
154
+		foreach ($post_types as $post_type):
155
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
+			//Filter-Payment-Manager to show Package
157
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
158 158
 
159
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
-        endforeach;
161
-    }
159
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
+		endforeach;
161
+	}
162 162
 }
163 163
 
164 164
 /**
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function geodir_default_admin_main_tabs($tabs)
173 173
 {
174
-    return $tabs = array(
175
-        'general_settings' => array('label' => __('General', 'geodirectory')),
176
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
177
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
-
182
-    );
174
+	return $tabs = array(
175
+		'general_settings' => array('label' => __('General', 'geodirectory')),
176
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
177
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
+
182
+	);
183 183
 }
184 184
 
185 185
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
  */
193 193
 function geodir_remove_image_box()
194 194
 {
195
-    global $post;
195
+	global $post;
196 196
 
197
-    $geodir_posttypes = geodir_get_posttypes();
197
+	$geodir_posttypes = geodir_get_posttypes();
198 198
 
199
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
199
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
200 200
 
201
-        remove_meta_box('postimagediv', $post->post_type, 'side');
202
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
201
+		remove_meta_box('postimagediv', $post->post_type, 'side');
202
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
203 203
 
204
-    endif;
204
+	endif;
205 205
 
206 206
 }
207 207
 
@@ -216,26 +216,26 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function geodir_meta_box_add()
218 218
 {
219
-    global $post;
219
+	global $post;
220 220
 
221
-    $geodir_post_types = geodir_get_posttypes('array');
222
-    $geodir_posttypes = array_keys($geodir_post_types);
221
+	$geodir_post_types = geodir_get_posttypes('array');
222
+	$geodir_posttypes = array_keys($geodir_post_types);
223 223
 
224
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
224
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
225 225
 
226
-        $geodir_posttype = $post->post_type;
227
-        $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
226
+		$geodir_posttype = $post->post_type;
227
+		$post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
228 228
 
229
-        // Filter-Payment-Manager
229
+		// Filter-Payment-Manager
230 230
 
231
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
231
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
232 232
 
233
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
233
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
234 234
 
235
-        // no need of this box as all fields moved to main information box
236
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
235
+		// no need of this box as all fields moved to main information box
236
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
237 237
 
238
-    endif;
238
+	endif;
239 239
 
240 240
 }
241 241
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
 function geodir_hide_post_taxonomy_meta_boxes()
260 260
 {
261 261
 
262
-    $geodir_post_types = get_option('geodir_post_types');
262
+	$geodir_post_types = get_option('geodir_post_types');
263 263
 
264
-    if (!empty($geodir_post_types)) {
265
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
264
+	if (!empty($geodir_post_types)) {
265
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
266 266
 
267
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
267
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
268 268
 
269
-            if(!empty($gd_taxonomy)) {
270
-                foreach ($gd_taxonomy as $tax) {
269
+			if(!empty($gd_taxonomy)) {
270
+				foreach ($gd_taxonomy as $tax) {
271 271
 
272
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
272
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
273 273
 
274
-                }
275
-            }
274
+				}
275
+			}
276 276
 
277
-        }
278
-    }
277
+		}
278
+	}
279 279
 }
280 280
 
281 281
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
  */
290 290
 function geodir_add_listing_map_restrict($map_restirct)
291 291
 {
292
-    if (is_admin()) {
293
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
-            $map_restirct = false;
295
-        }
296
-    }
297
-    return $map_restirct;
292
+	if (is_admin()) {
293
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
+			$map_restirct = false;
295
+		}
296
+	}
297
+	return $map_restirct;
298 298
 }
299 299
 
300 300
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 function geodir_enable_editor_on_notifications($notification)
314 314
 {
315 315
 
316
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
316
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
317 317
 
318
-        foreach ($notification as $key => $value) {
319
-            if ($value['type'] == 'textarea')
320
-                $notification[$key]['type'] = 'editor';
321
-        }
318
+		foreach ($notification as $key => $value) {
319
+			if ($value['type'] == 'textarea')
320
+				$notification[$key]['type'] = 'editor';
321
+		}
322 322
 
323
-    }
323
+	}
324 324
 
325
-    return $notification;
325
+	return $notification;
326 326
 }
327 327
 
328 328
 
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 function geodir_enable_editor_on_design_settings($design_setting)
340 340
 {
341 341
 
342
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
342
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
343 343
 
344
-        foreach ($design_setting as $key => $value) {
345
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
-                $design_setting[$key]['type'] = 'editor';
347
-        }
344
+		foreach ($design_setting as $key => $value) {
345
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
+				$design_setting[$key]['type'] = 'editor';
347
+		}
348 348
 
349
-    }
349
+	}
350 350
 
351
-    return $design_setting;
351
+	return $design_setting;
352 352
 }
353 353
 
354 354
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 function geodir_manage_available_fields($sub_tab)
370 370
 {
371 371
 
372
-    switch ($sub_tab) {
373
-        case 'custom_fields':
374
-            geodir_custom_available_fields();
375
-            break;
372
+	switch ($sub_tab) {
373
+		case 'custom_fields':
374
+			geodir_custom_available_fields();
375
+			break;
376 376
 
377
-        case 'sorting_options':
378
-            geodir_sorting_options_available_fields();
379
-            break;
377
+		case 'sorting_options':
378
+			geodir_sorting_options_available_fields();
379
+			break;
380 380
 
381
-    }
381
+	}
382 382
 }
383 383
 
384 384
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 function geodir_manage_selected_fields($sub_tab)
395 395
 {
396 396
 
397
-    switch ($sub_tab) {
398
-        case 'custom_fields':
399
-            geodir_custom_selected_fields();
400
-            break;
397
+	switch ($sub_tab) {
398
+		case 'custom_fields':
399
+			geodir_custom_selected_fields();
400
+			break;
401 401
 
402
-        case 'sorting_options':
403
-            geodir_sorting_options_selected_fields();
404
-            break;
402
+		case 'sorting_options':
403
+			geodir_sorting_options_selected_fields();
404
+			break;
405 405
 
406
-    }
406
+	}
407 407
 }
408 408
 
409 409
 /**
@@ -415,27 +415,27 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function geodir_sorting_options_available_fields()
417 417
 {
418
-    global $wpdb;
419
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
420
-    ?>
418
+	global $wpdb;
419
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
420
+	?>
421 421
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
422 422
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
423 423
     <ul>
424 424
     <?php
425
-        $sort_options = geodir_get_custom_sort_options($listing_type);
425
+		$sort_options = geodir_get_custom_sort_options($listing_type);
426 426
         
427
-        foreach ($sort_options as $key => $val) {
428
-            $val = stripslashes_deep($val); // strip slashes
429
-
430
-            $check_html_variable = $wpdb->get_var(
431
-                $wpdb->prepare(
432
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
433
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
434
-                )
435
-            );
427
+		foreach ($sort_options as $key => $val) {
428
+			$val = stripslashes_deep($val); // strip slashes
429
+
430
+			$check_html_variable = $wpdb->get_var(
431
+				$wpdb->prepare(
432
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
433
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
434
+				)
435
+			);
436 436
             
437
-            $display = $check_html_variable ? ' style="display:none;"' : '';
438
-            ?>
437
+			$display = $check_html_variable ? ' style="display:none;"' : '';
438
+			?>
439 439
             <li <?php echo $display;?>>
440 440
             <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>"
441 441
                title="<?php echo $val['site_title'];?>"
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
                href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a>
444 444
             </li>
445 445
             <?php
446
-        }
447
-    ?>
446
+		}
447
+	?>
448 448
     </ul>
449 449
     <?php
450 450
 }
@@ -458,28 +458,28 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_sorting_options_selected_fields()
460 460
 {
461
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
462
-    ?>
461
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
462
+	?>
463 463
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
464 464
     <ul class="core">
465 465
     <?php 
466
-        global $wpdb;
466
+		global $wpdb;
467 467
         
468
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
468
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
469 469
 
470
-        if (!empty($fields)) {
471
-            foreach ($fields as $field) {
472
-                //$result_str = $field->id;
473
-                $result_str = $field;
474
-                $field_type = $field->field_type;
475
-                $field_ins_upd = 'display';
470
+		if (!empty($fields)) {
471
+			foreach ($fields as $field) {
472
+				//$result_str = $field->id;
473
+				$result_str = $field;
474
+				$field_type = $field->field_type;
475
+				$field_ins_upd = 'display';
476 476
 
477
-                $default = false;
477
+				$default = false;
478 478
 
479
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
480
-            }
481
-        }
482
-    ?>
479
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
480
+			}
481
+		}
482
+	?>
483 483
     </ul>
484 484
     <?php
485 485
 }
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
  */
493 493
 function geodir_custom_available_fields()
494 494
 {
495
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
496
-    ?>
495
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
496
+	?>
497 497
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
498 498
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
499 499
     <ul class="full">
@@ -544,25 +544,25 @@  discard block
 block discarded – undo
544 544
  */
545 545
 function geodir_custom_selected_fields()
546 546
 {
547
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
548
-    ?>
547
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
548
+	?>
549 549
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
550 550
     <ul class="core">
551 551
     <?php 
552
-        global $wpdb;
553
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
554
-
555
-        if (!empty($fields)) {
556
-            foreach ($fields as $field) {
557
-                //$result_str = $field->id;
558
-                $result_str = $field;
559
-                $field_type = $field->field_type;
560
-                $field_ins_upd = 'display';
561
-
562
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
563
-            }
564
-        }
565
-        ?></ul>
552
+		global $wpdb;
553
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
554
+
555
+		if (!empty($fields)) {
556
+			foreach ($fields as $field) {
557
+				//$result_str = $field->id;
558
+				$result_str = $field;
559
+				$field_type = $field->field_type;
560
+				$field_ins_upd = 'display';
561
+
562
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
563
+			}
564
+		}
565
+		?></ul>
566 566
 <?php
567 567
 
568 568
 }
@@ -581,16 +581,16 @@  discard block
 block discarded – undo
581 581
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
582 582
 {
583 583
 
584
-    switch ($sub_tab) {
585
-        case 'custom_fields':
586
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
587
-            break;
584
+	switch ($sub_tab) {
585
+		case 'custom_fields':
586
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
587
+			break;
588 588
 
589
-        case 'sorting_options':
590
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
591
-            break;
592
-    }
593
-    return $heading;
589
+		case 'sorting_options':
590
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
591
+			break;
592
+	}
593
+	return $heading;
594 594
 }
595 595
 
596 596
 
@@ -608,16 +608,16 @@  discard block
 block discarded – undo
608 608
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
609 609
 {
610 610
 
611
-    switch ($sub_tab) {
612
-        case 'custom_fields':
613
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
614
-            break;
611
+	switch ($sub_tab) {
612
+		case 'custom_fields':
613
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
614
+			break;
615 615
 
616
-        case 'sorting_options':
617
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
618
-            break;
619
-    }
620
-    return $heading;
616
+		case 'sorting_options':
617
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
618
+			break;
619
+	}
620
+	return $heading;
621 621
 }
622 622
 
623 623
 
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
636 636
 {
637 637
 
638
-    switch ($sub_tab) {
639
-        case 'custom_fields':
640
-            $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));;
641
-            break;
638
+	switch ($sub_tab) {
639
+		case 'custom_fields':
640
+			$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));;
641
+			break;
642 642
 
643
-        case 'sorting_options':
644
-            $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));
645
-            break;
646
-    }
647
-    return $note;
643
+		case 'sorting_options':
644
+			$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));
645
+			break;
646
+	}
647
+	return $note;
648 648
 }
649 649
 
650 650
 
@@ -662,16 +662,16 @@  discard block
 block discarded – undo
662 662
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
663 663
 {
664 664
 
665
-    switch ($sub_tab) {
666
-        case 'custom_fields':
667
-            $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
668
-            break;
665
+	switch ($sub_tab) {
666
+		case 'custom_fields':
667
+			$heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
668
+			break;
669 669
 
670
-        case 'sorting_options':
671
-            $heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
672
-            break;
673
-    }
674
-    return $heading;
670
+		case 'sorting_options':
671
+			$heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
672
+			break;
673
+	}
674
+	return $heading;
675 675
 }
676 676
 
677 677
 
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
690 690
 {
691 691
 
692
-    switch ($sub_tab) {
693
-        case 'custom_fields':
694
-            $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));;
695
-            break;
692
+	switch ($sub_tab) {
693
+		case 'custom_fields':
694
+			$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));;
695
+			break;
696 696
 
697
-        case 'sorting_options':
698
-            $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));
699
-            break;
700
-    }
701
-    return $note;
697
+		case 'sorting_options':
698
+			$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));
699
+			break;
700
+	}
701
+	return $note;
702 702
 }
703 703
 
704 704
 
@@ -714,16 +714,16 @@  discard block
 block discarded – undo
714 714
  */
715 715
 function geodir_remove_unnecessary_fields()
716 716
 {
717
-    global $wpdb, $plugin_prefix;
717
+	global $wpdb, $plugin_prefix;
718 718
 
719
-    if (!get_option('geodir_remove_unnecessary_fields')) {
719
+	if (!get_option('geodir_remove_unnecessary_fields')) {
720 720
 
721
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
722
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
721
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
722
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
723 723
 
724
-        update_option('geodir_remove_unnecessary_fields', '1');
724
+		update_option('geodir_remove_unnecessary_fields', '1');
725 725
 
726
-    }
726
+	}
727 727
 
728 728
 }
729 729
 
@@ -741,25 +741,25 @@  discard block
 block discarded – undo
741 741
  */
742 742
 function geodir_admin_ajax_handler()
743 743
 {
744
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
745
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
746
-        switch ($geodir_admin_ajax_action) {
747
-            case 'diagnosis' :
748
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
749
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
750
-                call_user_func('geodir_diagnose_' . $diagnose_this);
751
-                exit();
752
-                break;
753
-
754
-            case 'diagnosis-fix' :
755
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
756
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
757
-                call_user_func('geodir_diagnose_' . $diagnose_this);
758
-                exit();
759
-                break;
760
-        }
761
-    }
762
-    exit();
744
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
745
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
746
+		switch ($geodir_admin_ajax_action) {
747
+			case 'diagnosis' :
748
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
749
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
750
+				call_user_func('geodir_diagnose_' . $diagnose_this);
751
+				exit();
752
+				break;
753
+
754
+			case 'diagnosis-fix' :
755
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
756
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
757
+				call_user_func('geodir_diagnose_' . $diagnose_this);
758
+				exit();
759
+				break;
760
+		}
761
+	}
762
+	exit();
763 763
 }
764 764
 
765 765
 
@@ -777,127 +777,127 @@  discard block
 block discarded – undo
777 777
  */
778 778
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
779 779
 {
780
-    global $wpdb;
781
-    //$filter_arr['output_str'] .='###'.$table.'###';
782
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
783
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
784
-        $filter_arr['is_error_during_diagnose'] = true;
785
-
786
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
787
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
788
-        $filter_arr['is_error_during_diagnose'] = true;
789
-        $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>";
790
-        $filter_arr['is_error_during_diagnose'] = true;
791
-
792
-        if ($fix) {
793
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
794
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
795
-
796
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
797
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
798
-
799
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
800
-
801
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
802
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
803
-                } else {
804
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
805
-                }
806
-
807
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
808
-
809
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
810
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
811
-
812
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
813
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
814
-                } else {
815
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
816
-                }
817
-
818
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
819
-
820
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
821
-
822
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
823
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
824
-                } else {
825
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
826
-                }
827
-
828
-            }
829
-
830
-        }
831
-
832
-
833
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
834
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
835
-        $filter_arr['is_error_during_diagnose'] = true;
836
-
837
-        if ($fix) {
838
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
839
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
840
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
841
-                } else {
842
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
843
-                }
844
-
845
-            } 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
846
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
847
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
848
-                } else {
849
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
850
-                }
851
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
852
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
853
-                } else {
854
-                    $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>";
855
-                }
856
-            } else {// else rename the original table to _ms_bak
857
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
858
-                    $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>";
859
-                } else {
860
-                    $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>";
861
-                }
862
-            }
863
-        }
864
-
865
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
866
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
867
-        $filter_arr['is_error_during_diagnose'] = true;
868
-
869
-        if ($fix) {
870
-            // if original table exists but new does not, rename
871
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
872
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
873
-            } else {
874
-                $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>";
875
-            }
876
-
877
-        }
878
-
879
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
880
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
881
-        $filter_arr['is_error_during_diagnose'] = true;
882
-
883
-        if ($fix) {
884
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
885
-            delete_option('geodirlocation_db_version');
886
-            delete_option('geodirevents_db_version');
887
-            delete_option('geodir_reviewrating_db_version');
888
-            delete_option('gdevents_db_version');
889
-            delete_option('geodirectory_db_version');
890
-            delete_option('geodirclaim_db_version');
891
-            delete_option('geodir_custom_posts_db_version');
892
-            delete_option('geodir_reviewratings_db_version');
893
-            delete_option('geodiradvancesearch_db_version');
894
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
895
-        }
896
-
897
-    } else {
898
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
899
-    }
900
-    return $filter_arr;
780
+	global $wpdb;
781
+	//$filter_arr['output_str'] .='###'.$table.'###';
782
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
783
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
784
+		$filter_arr['is_error_during_diagnose'] = true;
785
+
786
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
787
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
788
+		$filter_arr['is_error_during_diagnose'] = true;
789
+		$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>";
790
+		$filter_arr['is_error_during_diagnose'] = true;
791
+
792
+		if ($fix) {
793
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
794
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
795
+
796
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
797
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
798
+
799
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
800
+
801
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
802
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
803
+				} else {
804
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
805
+				}
806
+
807
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
808
+
809
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
810
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
811
+
812
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
813
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
814
+				} else {
815
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
816
+				}
817
+
818
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
819
+
820
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
821
+
822
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
823
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
824
+				} else {
825
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
826
+				}
827
+
828
+			}
829
+
830
+		}
831
+
832
+
833
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
834
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
835
+		$filter_arr['is_error_during_diagnose'] = true;
836
+
837
+		if ($fix) {
838
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
839
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
840
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
841
+				} else {
842
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
843
+				}
844
+
845
+			} 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
846
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
847
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
848
+				} else {
849
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
850
+				}
851
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
852
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
853
+				} else {
854
+					$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>";
855
+				}
856
+			} else {// else rename the original table to _ms_bak
857
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
858
+					$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>";
859
+				} else {
860
+					$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>";
861
+				}
862
+			}
863
+		}
864
+
865
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
866
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
867
+		$filter_arr['is_error_during_diagnose'] = true;
868
+
869
+		if ($fix) {
870
+			// if original table exists but new does not, rename
871
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
872
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
873
+			} else {
874
+				$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>";
875
+			}
876
+
877
+		}
878
+
879
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
880
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
881
+		$filter_arr['is_error_during_diagnose'] = true;
882
+
883
+		if ($fix) {
884
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
885
+			delete_option('geodirlocation_db_version');
886
+			delete_option('geodirevents_db_version');
887
+			delete_option('geodir_reviewrating_db_version');
888
+			delete_option('gdevents_db_version');
889
+			delete_option('geodirectory_db_version');
890
+			delete_option('geodirclaim_db_version');
891
+			delete_option('geodir_custom_posts_db_version');
892
+			delete_option('geodir_reviewratings_db_version');
893
+			delete_option('geodiradvancesearch_db_version');
894
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
895
+		}
896
+
897
+	} else {
898
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
899
+	}
900
+	return $filter_arr;
901 901
 }
902 902
 
903 903
 
@@ -911,53 +911,53 @@  discard block
 block discarded – undo
911 911
  */
912 912
 function geodir_diagnose_tags_sync()
913 913
 {
914
-    global $wpdb, $plugin_prefix;
915
-    $fix = isset($_POST['fix']) ? true : false;
916
-
917
-    //if($fix){echo 'true';}else{echo 'false';}
918
-    $is_error_during_diagnose = false;
919
-    $output_str = '';
920
-
921
-
922
-    $all_postypes = geodir_get_posttypes();
923
-
924
-    if (!empty($all_postypes)) {
925
-        foreach ($all_postypes as $key) {
926
-            // update each GD CPT
927
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
928
-
929
-            if (!empty($posts)) {
930
-
931
-                foreach ($posts as $p) {
932
-                    $p->post_type = $key;
933
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
934
-                    if (empty($raw_tags)) {
935
-                        $post_tags = '';
936
-                    } else {
937
-                        $post_tags = implode(",", $raw_tags);
938
-                    }
939
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
940
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
941
-
942
-                }
943
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
944
-            }
945
-
946
-        }
947
-
948
-    }
949
-
950
-    if ($is_error_during_diagnose) {
951
-        $info_div_class = "geodir_problem_info";
952
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
953
-    } else {
954
-        $info_div_class = "geodir_noproblem_info";
955
-        $fix_button_txt = '';
956
-    }
957
-    echo "<ul class='$info_div_class'>";
958
-    echo $output_str;
959
-    echo $fix_button_txt;
960
-    echo "</ul>";
914
+	global $wpdb, $plugin_prefix;
915
+	$fix = isset($_POST['fix']) ? true : false;
916
+
917
+	//if($fix){echo 'true';}else{echo 'false';}
918
+	$is_error_during_diagnose = false;
919
+	$output_str = '';
920
+
921
+
922
+	$all_postypes = geodir_get_posttypes();
923
+
924
+	if (!empty($all_postypes)) {
925
+		foreach ($all_postypes as $key) {
926
+			// update each GD CPT
927
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
928
+
929
+			if (!empty($posts)) {
930
+
931
+				foreach ($posts as $p) {
932
+					$p->post_type = $key;
933
+					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
934
+					if (empty($raw_tags)) {
935
+						$post_tags = '';
936
+					} else {
937
+						$post_tags = implode(",", $raw_tags);
938
+					}
939
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
940
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
941
+
942
+				}
943
+				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
944
+			}
945
+
946
+		}
947
+
948
+	}
949
+
950
+	if ($is_error_during_diagnose) {
951
+		$info_div_class = "geodir_problem_info";
952
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
953
+	} else {
954
+		$info_div_class = "geodir_noproblem_info";
955
+		$fix_button_txt = '';
956
+	}
957
+	echo "<ul class='$info_div_class'>";
958
+	echo $output_str;
959
+	echo $fix_button_txt;
960
+	echo "</ul>";
961 961
 
962 962
 }
963 963
 
@@ -973,75 +973,75 @@  discard block
 block discarded – undo
973 973
  */
974 974
 function geodir_diagnose_cats_sync()
975 975
 {
976
-    global $wpdb, $plugin_prefix;
977
-    $fix = isset($_POST['fix']) ? true : false;
976
+	global $wpdb, $plugin_prefix;
977
+	$fix = isset($_POST['fix']) ? true : false;
978 978
 
979
-    //if($fix){echo 'true';}else{echo 'false';}
980
-    $is_error_during_diagnose = false;
981
-    $output_str = '';
979
+	//if($fix){echo 'true';}else{echo 'false';}
980
+	$is_error_during_diagnose = false;
981
+	$output_str = '';
982 982
 
983 983
 
984
-    $all_postypes = geodir_get_posttypes();
984
+	$all_postypes = geodir_get_posttypes();
985 985
 
986
-    if (!empty($all_postypes)) {
987
-        foreach ($all_postypes as $key) {
988
-            // update each GD CTP
989
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
986
+	if (!empty($all_postypes)) {
987
+		foreach ($all_postypes as $key) {
988
+			// update each GD CTP
989
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
990 990
 
991
-            if (!empty($posts)) {
991
+			if (!empty($posts)) {
992 992
 
993
-                foreach ($posts as $p) {
994
-                    $p->post_type = $key;
995
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
993
+				foreach ($posts as $p) {
994
+					$p->post_type = $key;
995
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
996 996
 
997
-                    if (empty($raw_cats)) {
998
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
997
+					if (empty($raw_cats)) {
998
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
999 999
 
1000
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1001
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1002
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1003
-                                if (is_numeric($cat_part)) {
1004
-                                    $raw_cats[] = (int)$cat_part;
1005
-                                }
1006
-                            }
1000
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1001
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1002
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1003
+								if (is_numeric($cat_part)) {
1004
+									$raw_cats[] = (int)$cat_part;
1005
+								}
1006
+							}
1007 1007
 
1008
-                        }
1008
+						}
1009 1009
 
1010
-                        if (!empty($raw_cats)) {
1011
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1010
+						if (!empty($raw_cats)) {
1011
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1012 1012
 
1013
-                        }
1013
+						}
1014 1014
 
1015
-                    }
1015
+					}
1016 1016
 
1017 1017
 
1018
-                    if (empty($raw_cats)) {
1019
-                        $post_cats = '';
1020
-                    } else {
1021
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1022
-                    }
1023
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1024
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1025
-                }
1018
+					if (empty($raw_cats)) {
1019
+						$post_cats = '';
1020
+					} else {
1021
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1022
+					}
1023
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1024
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1025
+				}
1026 1026
 
1027
-            }
1028
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1027
+			}
1028
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1029 1029
 
1030
-        }
1030
+		}
1031 1031
 
1032
-    }
1032
+	}
1033 1033
 
1034
-    if ($is_error_during_diagnose) {
1035
-        $info_div_class = "geodir_problem_info";
1036
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1037
-    } else {
1038
-        $info_div_class = "geodir_noproblem_info";
1039
-        $fix_button_txt = '';
1040
-    }
1041
-    echo "<ul class='$info_div_class'>";
1042
-    echo $output_str;
1043
-    echo $fix_button_txt;
1044
-    echo "</ul>";
1034
+	if ($is_error_during_diagnose) {
1035
+		$info_div_class = "geodir_problem_info";
1036
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1037
+	} else {
1038
+		$info_div_class = "geodir_noproblem_info";
1039
+		$fix_button_txt = '';
1040
+	}
1041
+	echo "<ul class='$info_div_class'>";
1042
+	echo $output_str;
1043
+	echo $fix_button_txt;
1044
+	echo "</ul>";
1045 1045
 
1046 1046
 }
1047 1047
 
@@ -1055,61 +1055,61 @@  discard block
 block discarded – undo
1055 1055
  */
1056 1056
 function geodir_diagnose_version_clear()
1057 1057
 {
1058
-    global $wpdb, $plugin_prefix;
1059
-    $fix = isset($_POST['fix']) ? true : false;
1060
-
1061
-    //if($fix){echo 'true';}else{echo 'false';}
1062
-    $is_error_during_diagnose = false;
1063
-    $output_str = '';
1064
-
1065
-
1066
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1067
-        'Payment Manager' => 'geodir_payments_db_version',
1068
-        'GeoDirectory Framework' => 'gdf_db_version',
1069
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1070
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1071
-        'Claim Manager' => 'geodirclaim_db_version',
1072
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1073
-        'Location Manager' => 'geodirlocation_db_version',
1074
-        'Payment Manager' => 'geodir_payments_db_version',
1075
-        'Events Manager' => 'geodirevents_db_version',
1076
-    );
1077
-
1078
-    /**
1079
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1080
-     *
1081
-     * @since 1.0.0
1082
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1083
-     */
1084
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1085
-
1086
-    if (!empty($ver_arr)) {
1087
-        foreach ($ver_arr as $key => $val) {
1088
-            if (delete_option($val)) {
1089
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1090
-            } else {
1091
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1092
-            }
1093
-
1094
-        }
1095
-
1096
-        if ($output_str) {
1097
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1098
-        }
1099
-
1100
-    }
1101
-
1102
-    if ($is_error_during_diagnose) {
1103
-        $info_div_class = "geodir_problem_info";
1104
-        $fix_button_txt = "";
1105
-    } else {
1106
-        $info_div_class = "geodir_noproblem_info";
1107
-        $fix_button_txt = '';
1108
-    }
1109
-    echo "<ul class='$info_div_class'>";
1110
-    echo $output_str;
1111
-    echo $fix_button_txt;
1112
-    echo "</ul>";
1058
+	global $wpdb, $plugin_prefix;
1059
+	$fix = isset($_POST['fix']) ? true : false;
1060
+
1061
+	//if($fix){echo 'true';}else{echo 'false';}
1062
+	$is_error_during_diagnose = false;
1063
+	$output_str = '';
1064
+
1065
+
1066
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1067
+		'Payment Manager' => 'geodir_payments_db_version',
1068
+		'GeoDirectory Framework' => 'gdf_db_version',
1069
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1070
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1071
+		'Claim Manager' => 'geodirclaim_db_version',
1072
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1073
+		'Location Manager' => 'geodirlocation_db_version',
1074
+		'Payment Manager' => 'geodir_payments_db_version',
1075
+		'Events Manager' => 'geodirevents_db_version',
1076
+	);
1077
+
1078
+	/**
1079
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1080
+	 *
1081
+	 * @since 1.0.0
1082
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1083
+	 */
1084
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1085
+
1086
+	if (!empty($ver_arr)) {
1087
+		foreach ($ver_arr as $key => $val) {
1088
+			if (delete_option($val)) {
1089
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1090
+			} else {
1091
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1092
+			}
1093
+
1094
+		}
1095
+
1096
+		if ($output_str) {
1097
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1098
+		}
1099
+
1100
+	}
1101
+
1102
+	if ($is_error_during_diagnose) {
1103
+		$info_div_class = "geodir_problem_info";
1104
+		$fix_button_txt = "";
1105
+	} else {
1106
+		$info_div_class = "geodir_noproblem_info";
1107
+		$fix_button_txt = '';
1108
+	}
1109
+	echo "<ul class='$info_div_class'>";
1110
+	echo $output_str;
1111
+	echo $fix_button_txt;
1112
+	echo "</ul>";
1113 1113
 
1114 1114
 }
1115 1115
 
@@ -1123,59 +1123,59 @@  discard block
 block discarded – undo
1123 1123
  */
1124 1124
 function geodir_diagnose_ratings()
1125 1125
 {
1126
-    global $wpdb;
1127
-    $fix = isset($_POST['fix']) ? true : false;
1128
-
1129
-    //if($fix){echo 'true';}else{echo 'false';}
1130
-    $is_error_during_diagnose = false;
1131
-    $output_str = '';
1132
-
1133
-    // check review locations
1134
-    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")) {
1135
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1136
-        $is_error_during_diagnose = true;
1137
-
1138
-        if ($fix) {
1139
-            if (geodir_fix_review_location()) {
1140
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1141
-            } else {
1142
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1143
-            }
1144
-        }
1145
-
1146
-    } else {
1147
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1148
-    }
1149
-
1150
-    // check review content
1151
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1152
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1153
-        $is_error_during_diagnose = true;
1154
-
1155
-        if ($fix) {
1156
-            if (geodir_fix_review_content()) {
1157
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1158
-            } else {
1159
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1160
-            }
1161
-        }
1162
-
1163
-    } else {
1164
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1165
-    }
1166
-
1167
-
1168
-    if ($is_error_during_diagnose) {
1169
-        $info_div_class = "geodir_problem_info";
1170
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1171
-    } else {
1172
-        $info_div_class = "geodir_noproblem_info";
1173
-        $fix_button_txt = '';
1174
-    }
1175
-    echo "<ul class='$info_div_class'>";
1176
-    echo $output_str;
1177
-    echo $fix_button_txt;
1178
-    echo "</ul>";
1126
+	global $wpdb;
1127
+	$fix = isset($_POST['fix']) ? true : false;
1128
+
1129
+	//if($fix){echo 'true';}else{echo 'false';}
1130
+	$is_error_during_diagnose = false;
1131
+	$output_str = '';
1132
+
1133
+	// check review locations
1134
+	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")) {
1135
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1136
+		$is_error_during_diagnose = true;
1137
+
1138
+		if ($fix) {
1139
+			if (geodir_fix_review_location()) {
1140
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1141
+			} else {
1142
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1143
+			}
1144
+		}
1145
+
1146
+	} else {
1147
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1148
+	}
1149
+
1150
+	// check review content
1151
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1152
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1153
+		$is_error_during_diagnose = true;
1154
+
1155
+		if ($fix) {
1156
+			if (geodir_fix_review_content()) {
1157
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1158
+			} else {
1159
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1160
+			}
1161
+		}
1162
+
1163
+	} else {
1164
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1165
+	}
1166
+
1167
+
1168
+	if ($is_error_during_diagnose) {
1169
+		$info_div_class = "geodir_problem_info";
1170
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1171
+	} else {
1172
+		$info_div_class = "geodir_noproblem_info";
1173
+		$fix_button_txt = '';
1174
+	}
1175
+	echo "<ul class='$info_div_class'>";
1176
+	echo $output_str;
1177
+	echo $fix_button_txt;
1178
+	echo "</ul>";
1179 1179
 
1180 1180
 }
1181 1181
 
@@ -1189,57 +1189,57 @@  discard block
 block discarded – undo
1189 1189
  */
1190 1190
 function geodir_diagnose_multisite_conversion()
1191 1191
 {
1192
-    global $wpdb;
1193
-    $fix = isset($_POST['fix']) ? true : false;
1194
-    //if($fix){echo 'true';}else{echo 'false';}
1195
-    $is_error_during_diagnose = false;
1196
-    $output_str = '';
1197
-
1198
-    $filter_arr = array();
1199
-    $filter_arr['output_str'] = $output_str;
1200
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1201
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1202
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1203
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1204
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1205
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1206
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1207
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1208
-    );
1209
-
1210
-    // allow other addons to hook in and add their checks
1211
-
1212
-    /**
1213
-     * Filter the array of tables.
1214
-     *
1215
-     * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1216
-     *
1217
-     * @since 1.0.0
1218
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1219
-     */
1220
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1221
-
1222
-    foreach ($table_arr as $table => $table_name) {
1223
-        // Diagnose table
1224
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1225
-    }
1226
-
1227
-
1228
-    $output_str = $filter_arr['output_str'];
1229
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1230
-
1231
-
1232
-    if ($is_error_during_diagnose) {
1233
-        $info_div_class = "geodir_problem_info";
1234
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1235
-    } else {
1236
-        $info_div_class = "geodir_noproblem_info";
1237
-        $fix_button_txt = '';
1238
-    }
1239
-    echo "<ul class='$info_div_class'>";
1240
-    echo $output_str;
1241
-    echo $fix_button_txt;
1242
-    echo "</ul>";
1192
+	global $wpdb;
1193
+	$fix = isset($_POST['fix']) ? true : false;
1194
+	//if($fix){echo 'true';}else{echo 'false';}
1195
+	$is_error_during_diagnose = false;
1196
+	$output_str = '';
1197
+
1198
+	$filter_arr = array();
1199
+	$filter_arr['output_str'] = $output_str;
1200
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1201
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1202
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1203
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1204
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1205
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1206
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1207
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1208
+	);
1209
+
1210
+	// allow other addons to hook in and add their checks
1211
+
1212
+	/**
1213
+	 * Filter the array of tables.
1214
+	 *
1215
+	 * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1216
+	 *
1217
+	 * @since 1.0.0
1218
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1219
+	 */
1220
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1221
+
1222
+	foreach ($table_arr as $table => $table_name) {
1223
+		// Diagnose table
1224
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1225
+	}
1226
+
1227
+
1228
+	$output_str = $filter_arr['output_str'];
1229
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1230
+
1231
+
1232
+	if ($is_error_during_diagnose) {
1233
+		$info_div_class = "geodir_problem_info";
1234
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1235
+	} else {
1236
+		$info_div_class = "geodir_noproblem_info";
1237
+		$fix_button_txt = '';
1238
+	}
1239
+	echo "<ul class='$info_div_class'>";
1240
+	echo $output_str;
1241
+	echo $fix_button_txt;
1242
+	echo "</ul>";
1243 1243
 }
1244 1244
 
1245 1245
 /**
@@ -1257,39 +1257,39 @@  discard block
 block discarded – undo
1257 1257
  */
1258 1258
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1259 1259
 {
1260
-    global $wpdb, $current_user;
1261
-
1262
-    if (!empty($old_id)) {
1263
-        wp_delete_post($old_id, true);
1264
-    }//delete post if already there
1265
-    else {
1266
-        $page_found = $wpdb->get_var(
1267
-            $wpdb->prepare(
1268
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1269
-                array($slug)
1270
-            )
1271
-        );
1272
-        wp_delete_post($page_found, true);
1273
-
1274
-    }
1275
-
1276
-    $page_data = array(
1277
-        'post_status' => 'publish',
1278
-        'post_type' => 'page',
1279
-        'post_author' => $current_user->ID,
1280
-        'post_name' => $slug,
1281
-        'post_title' => $page_title,
1282
-        'post_content' => '',
1283
-        'post_parent' => 0,
1284
-        'comment_status' => 'closed'
1285
-    );
1286
-    $page_id = wp_insert_post($page_data);
1287
-    update_option($option, $page_id);
1288
-    if ($page_id) {
1289
-        return true;
1290
-    } else {
1291
-        return false;
1292
-    }
1260
+	global $wpdb, $current_user;
1261
+
1262
+	if (!empty($old_id)) {
1263
+		wp_delete_post($old_id, true);
1264
+	}//delete post if already there
1265
+	else {
1266
+		$page_found = $wpdb->get_var(
1267
+			$wpdb->prepare(
1268
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1269
+				array($slug)
1270
+			)
1271
+		);
1272
+		wp_delete_post($page_found, true);
1273
+
1274
+	}
1275
+
1276
+	$page_data = array(
1277
+		'post_status' => 'publish',
1278
+		'post_type' => 'page',
1279
+		'post_author' => $current_user->ID,
1280
+		'post_name' => $slug,
1281
+		'post_title' => $page_title,
1282
+		'post_content' => '',
1283
+		'post_parent' => 0,
1284
+		'comment_status' => 'closed'
1285
+	);
1286
+	$page_id = wp_insert_post($page_data);
1287
+	update_option($option, $page_id);
1288
+	if ($page_id) {
1289
+		return true;
1290
+	} else {
1291
+		return false;
1292
+	}
1293 1293
 }
1294 1294
 
1295 1295
 /**
@@ -1301,212 +1301,212 @@  discard block
 block discarded – undo
1301 1301
  */
1302 1302
 function geodir_diagnose_default_pages()
1303 1303
 {
1304
-    global $wpdb;
1305
-    $is_error_during_diagnose = false;
1306
-    $output_str = '';
1307
-    $fix = isset($_POST['fix']) ? true : false;
1308
-
1309
-    //////////////////////////////////
1310
-    /* Diagnose GD Home Page Starts */
1311
-    //////////////////////////////////
1312
-    $option_value = get_option('geodir_home_page');
1313
-    $page = get_post($option_value);
1314
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1315
-
1316
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1317
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1318
-    else {
1319
-        $is_error_during_diagnose = true;
1320
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1321
-        if ($fix) {
1322
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1323
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1324
-            } else {
1325
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1326
-            }
1327
-        }
1328
-    }
1329
-
1330
-    ////////////////////////////////
1331
-    /* Diagnose GD Home Page Ends */
1332
-    ////////////////////////////////
1333
-
1334
-    //////////////////////////////////
1335
-    /* Diagnose Add Listing Page Starts */
1336
-    //////////////////////////////////
1337
-    $option_value = get_option('geodir_add_listing_page');
1338
-    $page = get_post($option_value);
1339
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1340
-
1341
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1342
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1343
-    else {
1344
-        $is_error_during_diagnose = true;
1345
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1346
-        if ($fix) {
1347
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1348
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1349
-            } else {
1350
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1351
-            }
1352
-        }
1353
-    }
1354
-
1355
-    ////////////////////////////////
1356
-    /* Diagnose Add Listing Page Ends */
1357
-    ////////////////////////////////
1358
-
1359
-
1360
-    //////////////////////////////////
1361
-    /* Diagnose Listing Preview Page Starts */
1362
-    //////////////////////////////////
1363
-    $option_value = get_option('geodir_preview_page');
1364
-    $page = get_post($option_value);
1365
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1366
-
1367
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1368
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1369
-    else {
1370
-        $is_error_during_diagnose = true;
1371
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1372
-        if ($fix) {
1373
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1374
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1375
-            } else {
1376
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1377
-            }
1378
-        }
1379
-    }
1380
-
1381
-    ////////////////////////////////
1382
-    /* Diagnose Listing Preview Page Ends */
1383
-    ////////////////////////////////
1384
-
1385
-    //////////////////////////////////
1386
-    /* Diagnose Listing Success Page Starts */
1387
-    //////////////////////////////////
1388
-    $option_value = get_option('geodir_success_page');
1389
-    $page = get_post($option_value);
1390
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1391
-
1392
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1393
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1394
-    else {
1395
-        $is_error_during_diagnose = true;
1396
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1397
-        if ($fix) {
1398
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1399
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1400
-            } else {
1401
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1402
-            }
1403
-        }
1404
-    }
1405
-
1406
-    ////////////////////////////////
1407
-    /* Diagnose Listing Sucess Page Ends */
1408
-    ////////////////////////////////
1409
-
1410
-    //////////////////////////////////
1411
-    /* Diagnose Info Page Starts */
1412
-    //////////////////////////////////
1413
-    $option_value = get_option('geodir_info_page');
1414
-    $page = get_post($option_value);
1415
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1416
-
1417
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1418
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1419
-    else {
1420
-        $is_error_during_diagnose = true;
1421
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1422
-        if ($fix) {
1423
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1424
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1425
-            } else {
1426
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1427
-            }
1428
-        }
1429
-    }
1430
-
1431
-    ////////////////////////////////
1432
-    /* Diagnose Info Page Ends */
1433
-    ////////////////////////////////
1434
-
1435
-    //////////////////////////////////
1436
-    /* Diagnose Login Page Starts */
1437
-    //////////////////////////////////
1438
-    $option_value = get_option('geodir_login_page');
1439
-    $page = get_post($option_value);
1440
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1441
-
1442
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1443
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1444
-    else {
1445
-        $is_error_during_diagnose = true;
1446
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1447
-        if ($fix) {
1448
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1449
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1450
-            } else {
1451
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1452
-            }
1453
-        }
1454
-    }
1455
-
1456
-    ////////////////////////////////
1457
-    /* Diagnose Info Page Ends */
1458
-    ////////////////////////////////
1459
-
1460
-    //////////////////////////////////
1461
-    /* Diagnose Location Page Starts */
1462
-    //////////////////////////////////
1463
-    $option_value = get_option('geodir_location_page');
1464
-    $page = get_post($option_value);
1465
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1466
-
1467
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1468
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1469
-    else {
1470
-        $is_error_during_diagnose = true;
1471
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1472
-        if ($fix) {
1473
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1474
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1475
-            } else {
1476
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1477
-            }
1478
-        }
1479
-    }
1480
-
1481
-    ////////////////////////////////
1482
-    /* Diagnose Location Page Ends */
1483
-    ////////////////////////////////
1484
-
1485
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1486
-    /**
1487
-     * This action is called at the end of the GD Tools page check function.
1488
-     *
1489
-     * @since 1.5.2
1490
-     */
1491
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1492
-
1493
-    $output_str = $page_chk_arr['output_str'];
1494
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1495
-
1496
-    if ($is_error_during_diagnose) {
1497
-        if ($fix) {
1498
-            flush_rewrite_rules();
1499
-        }
1500
-        $info_div_class = "geodir_problem_info";
1501
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1502
-    } else {
1503
-        $info_div_class = "geodir_noproblem_info";
1504
-        $fix_button_txt = '';
1505
-    }
1506
-    echo "<ul class='$info_div_class'>";
1507
-    echo $output_str;
1508
-    echo $fix_button_txt;
1509
-    echo "</ul>";
1304
+	global $wpdb;
1305
+	$is_error_during_diagnose = false;
1306
+	$output_str = '';
1307
+	$fix = isset($_POST['fix']) ? true : false;
1308
+
1309
+	//////////////////////////////////
1310
+	/* Diagnose GD Home Page Starts */
1311
+	//////////////////////////////////
1312
+	$option_value = get_option('geodir_home_page');
1313
+	$page = get_post($option_value);
1314
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1315
+
1316
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1317
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1318
+	else {
1319
+		$is_error_during_diagnose = true;
1320
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1321
+		if ($fix) {
1322
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1323
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1324
+			} else {
1325
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1326
+			}
1327
+		}
1328
+	}
1329
+
1330
+	////////////////////////////////
1331
+	/* Diagnose GD Home Page Ends */
1332
+	////////////////////////////////
1333
+
1334
+	//////////////////////////////////
1335
+	/* Diagnose Add Listing Page Starts */
1336
+	//////////////////////////////////
1337
+	$option_value = get_option('geodir_add_listing_page');
1338
+	$page = get_post($option_value);
1339
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1340
+
1341
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1342
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1343
+	else {
1344
+		$is_error_during_diagnose = true;
1345
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1346
+		if ($fix) {
1347
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1348
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1349
+			} else {
1350
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1351
+			}
1352
+		}
1353
+	}
1354
+
1355
+	////////////////////////////////
1356
+	/* Diagnose Add Listing Page Ends */
1357
+	////////////////////////////////
1358
+
1359
+
1360
+	//////////////////////////////////
1361
+	/* Diagnose Listing Preview Page Starts */
1362
+	//////////////////////////////////
1363
+	$option_value = get_option('geodir_preview_page');
1364
+	$page = get_post($option_value);
1365
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1366
+
1367
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1368
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1369
+	else {
1370
+		$is_error_during_diagnose = true;
1371
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1372
+		if ($fix) {
1373
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1374
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1375
+			} else {
1376
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1377
+			}
1378
+		}
1379
+	}
1380
+
1381
+	////////////////////////////////
1382
+	/* Diagnose Listing Preview Page Ends */
1383
+	////////////////////////////////
1384
+
1385
+	//////////////////////////////////
1386
+	/* Diagnose Listing Success Page Starts */
1387
+	//////////////////////////////////
1388
+	$option_value = get_option('geodir_success_page');
1389
+	$page = get_post($option_value);
1390
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1391
+
1392
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1393
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1394
+	else {
1395
+		$is_error_during_diagnose = true;
1396
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1397
+		if ($fix) {
1398
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1399
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1400
+			} else {
1401
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1402
+			}
1403
+		}
1404
+	}
1405
+
1406
+	////////////////////////////////
1407
+	/* Diagnose Listing Sucess Page Ends */
1408
+	////////////////////////////////
1409
+
1410
+	//////////////////////////////////
1411
+	/* Diagnose Info Page Starts */
1412
+	//////////////////////////////////
1413
+	$option_value = get_option('geodir_info_page');
1414
+	$page = get_post($option_value);
1415
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1416
+
1417
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1418
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1419
+	else {
1420
+		$is_error_during_diagnose = true;
1421
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1422
+		if ($fix) {
1423
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1424
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1425
+			} else {
1426
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1427
+			}
1428
+		}
1429
+	}
1430
+
1431
+	////////////////////////////////
1432
+	/* Diagnose Info Page Ends */
1433
+	////////////////////////////////
1434
+
1435
+	//////////////////////////////////
1436
+	/* Diagnose Login Page Starts */
1437
+	//////////////////////////////////
1438
+	$option_value = get_option('geodir_login_page');
1439
+	$page = get_post($option_value);
1440
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1441
+
1442
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1443
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1444
+	else {
1445
+		$is_error_during_diagnose = true;
1446
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1447
+		if ($fix) {
1448
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1449
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1450
+			} else {
1451
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1452
+			}
1453
+		}
1454
+	}
1455
+
1456
+	////////////////////////////////
1457
+	/* Diagnose Info Page Ends */
1458
+	////////////////////////////////
1459
+
1460
+	//////////////////////////////////
1461
+	/* Diagnose Location Page Starts */
1462
+	//////////////////////////////////
1463
+	$option_value = get_option('geodir_location_page');
1464
+	$page = get_post($option_value);
1465
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1466
+
1467
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1468
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1469
+	else {
1470
+		$is_error_during_diagnose = true;
1471
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1472
+		if ($fix) {
1473
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1474
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1475
+			} else {
1476
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1477
+			}
1478
+		}
1479
+	}
1480
+
1481
+	////////////////////////////////
1482
+	/* Diagnose Location Page Ends */
1483
+	////////////////////////////////
1484
+
1485
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1486
+	/**
1487
+	 * This action is called at the end of the GD Tools page check function.
1488
+	 *
1489
+	 * @since 1.5.2
1490
+	 */
1491
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1492
+
1493
+	$output_str = $page_chk_arr['output_str'];
1494
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1495
+
1496
+	if ($is_error_during_diagnose) {
1497
+		if ($fix) {
1498
+			flush_rewrite_rules();
1499
+		}
1500
+		$info_div_class = "geodir_problem_info";
1501
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1502
+	} else {
1503
+		$info_div_class = "geodir_noproblem_info";
1504
+		$fix_button_txt = '';
1505
+	}
1506
+	echo "<ul class='$info_div_class'>";
1507
+	echo $output_str;
1508
+	echo $fix_button_txt;
1509
+	echo "</ul>";
1510 1510
 
1511 1511
 }
1512 1512
 
@@ -1518,26 +1518,26 @@  discard block
 block discarded – undo
1518 1518
  * @global object $wpdb WordPress Database object.
1519 1519
  */
1520 1520
 function geodir_diagnose_load_db_language() {
1521
-    global $wpdb;
1521
+	global $wpdb;
1522 1522
 	
1523 1523
 	$is_error_during_diagnose = geodirectory_load_db_language();
1524 1524
 
1525
-    $output_str = '';
1526
-    $fix_button_txt = '';
1525
+	$output_str = '';
1526
+	$fix_button_txt = '';
1527 1527
 
1528
-    if ($is_error_during_diagnose) {
1529
-        $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>";
1528
+	if ($is_error_during_diagnose) {
1529
+		$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>";
1530 1530
 		$info_div_class = "geodir_problem_info";
1531
-    } else {
1532
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1531
+	} else {
1532
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1533 1533
 		$info_div_class = "geodir_noproblem_info";
1534
-        $fix_button_txt = '';
1535
-    }
1534
+		$fix_button_txt = '';
1535
+	}
1536 1536
     
1537 1537
 	echo "<ul class='$info_div_class'>";
1538
-    echo $output_str;
1539
-    echo $fix_button_txt;
1540
-    echo "</ul>";
1538
+	echo $output_str;
1539
+	echo $fix_button_txt;
1540
+	echo "</ul>";
1541 1541
 
1542 1542
 }
1543 1543
 
@@ -1568,23 +1568,23 @@  discard block
 block discarded – undo
1568 1568
  */
1569 1569
 function geodir_posts_clauses_request($clauses)
1570 1570
 {
1571
-    global $wpdb, $wp_query, $plugin_prefix;
1571
+	global $wpdb, $wp_query, $plugin_prefix;
1572 1572
 
1573
-    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'])) {
1574
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1573
+	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'])) {
1574
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1575 1575
 
1576
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1577
-        $clauses['join'] = $join;
1576
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1577
+		$clauses['join'] = $join;
1578 1578
 
1579
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1580
-        $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';
1581
-        $clauses['fields'] = $fields;
1579
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1580
+		$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';
1581
+		$clauses['fields'] = $fields;
1582 1582
 
1583
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1584
-        $orderby = 'gd_expire ' . $order;
1585
-        $clauses['orderby'] = $orderby;
1586
-    }
1587
-    return $clauses;
1583
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1584
+		$orderby = 'gd_expire ' . $order;
1585
+		$clauses['orderby'] = $orderby;
1586
+	}
1587
+	return $clauses;
1588 1588
 }
1589 1589
 
1590 1590
 
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
  */
1606 1606
 function gd_theme_switch_compat_check()
1607 1607
 {
1608
-    gd_set_theme_compat();
1608
+	gd_set_theme_compat();
1609 1609
 }
1610 1610
 
1611 1611
 /**
@@ -1618,27 +1618,27 @@  discard block
 block discarded – undo
1618 1618
  */
1619 1619
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1620 1620
 {
1621
-    if (function_exists('str_getcsv')) {
1622
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1623
-    } else {
1624
-        global $current_user;
1625
-        $upload_dir = wp_upload_dir();
1626
-
1627
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1628
-        $handle = fopen($file, 'w');
1629
-
1630
-        fwrite($handle, $input);
1631
-        fclose($handle);
1632
-
1633
-        $handle = fopen($file, 'rt');
1634
-        if (PHP_VERSION >= '5.3.0') {
1635
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1636
-        } else {
1637
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1638
-        }
1639
-        fclose($handle);
1640
-    }
1641
-    return $fgetcsv;
1621
+	if (function_exists('str_getcsv')) {
1622
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1623
+	} else {
1624
+		global $current_user;
1625
+		$upload_dir = wp_upload_dir();
1626
+
1627
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1628
+		$handle = fopen($file, 'w');
1629
+
1630
+		fwrite($handle, $input);
1631
+		fclose($handle);
1632
+
1633
+		$handle = fopen($file, 'rt');
1634
+		if (PHP_VERSION >= '5.3.0') {
1635
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1636
+		} else {
1637
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1638
+		}
1639
+		fclose($handle);
1640
+	}
1641
+	return $fgetcsv;
1642 1642
 }
1643 1643
 
1644 1644
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1653,375 +1653,375 @@  discard block
 block discarded – undo
1653 1653
  */
1654 1654
 function geodir_ajax_import_csv()
1655 1655
 {
1656
-    error_reporting(0); // hide error to get clean json response
1656
+	error_reporting(0); // hide error to get clean json response
1657 1657
 
1658
-    global $wpdb, $plugin_prefix, $current_user;
1659
-    $uploads = wp_upload_dir();
1660
-    ini_set('auto_detect_line_endings', true);
1658
+	global $wpdb, $plugin_prefix, $current_user;
1659
+	$uploads = wp_upload_dir();
1660
+	ini_set('auto_detect_line_endings', true);
1661 1661
 	
1662 1662
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1663 1663
 
1664
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1665
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1666
-    $filename = $uploadedFile;
1667
-
1668
-    $uploads = wp_upload_dir();
1669
-    $uploads_dir = $uploads['path'];
1670
-    $image_name_arr = explode('/', $filename);
1671
-    $filename = end($image_name_arr);
1672
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1673
-    $return = array();
1674
-    $return['file'] = $uploadedFile;
1675
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1676
-
1677
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1678
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1679
-
1680
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1681
-            $return['error'] = NULL;
1682
-
1683
-            $return['rows'] = 0;
1684
-
1685
-
1686
-
1687
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1688
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1689
-                        if(is_array($data) && !empty($data)) {
1690
-                            $file[] = '"' . implode('","', $data) . '"';
1691
-                        }
1692
-                    }
1693
-                    fclose($handle);
1694
-                    $file = $file;
1695
-                }
1696
-
1697
-
1698
-
1699
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1700
-
1701
-
1702
-            if (!$return['rows'] > 0) {
1703
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
1704
-            }
1705
-        }
1706
-    }
1707
-    if ($task == 'prepare' || !empty($return['error'])) {
1708
-        echo json_encode($return);
1709
-        exit;
1710
-    }
1711
-
1712
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1713
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1714
-    $count = $importlimit;
1715
-    $requested_limit = $importlimit;
1716
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1717
-
1718
-    if ($count < $totRecords) {
1719
-        $count = $tmpCnt + $count;
1720
-        if ($count > $totRecords) {
1721
-            $count = $totRecords;
1722
-        }
1723
-    } else {
1724
-        $count = $totRecords;
1725
-    }
1726
-
1727
-    $total_records = 0;
1728
-    $rowcount = 0;
1729
-    $address_invalid = 0;
1730
-    $blank_address = 0;
1731
-    $upload_files = 0;
1732
-    $invalid_post_type = 0;
1733
-    $invalid_title = 0;
1734
-    $customKeyarray = array();
1735
-    $gd_post_info = array();
1736
-    $post_location = array();
1737
-    $countpost = 0;
1738
-
1739
-    if (!empty($file)) {
1740
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1741
-        $customKeyarray = $columns;
1742
-
1743
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1744
-            $return['error'] = CSV_INVAILD_FILE;
1745
-            echo json_encode($return);
1746
-            exit;
1747
-        }
1748
-
1749
-        for ($i = 1; $i <= $importlimit; $i++) {
1750
-            $current_index = $tmpCnt + $i;
1751
-            if (isset($file[$current_index])) {
1752
-                $total_records++;
1753
-
1754
-                $buffer = geodir_str_getcsv($file[$current_index]);
1755
-                $post_title = addslashes($buffer[0]);
1756
-                $current_post_author = $buffer[1];
1757
-                $post_desc = addslashes($buffer[2]);
1758
-                $post_cat = array();
1759
-                $catids_arr = array();
1760
-                $post_cat = trim($buffer[3]); // comma seperated category name
1761
-
1762
-                if ($post_cat) {
1763
-                    $post_cat_arr = explode(',', $post_cat);
1764
-
1765
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
1766
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1767
-
1768
-                        if (!empty($buffer[5])) {
1769
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
1770
-
1771
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1772
-
1773
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
1774
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1775
-                                    $catids_arr[] = $cat->slug;
1776
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1777
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1778
-                                    $catids_arr[] = $cat->slug;
1779
-                                } else {
1780
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
1781
-                                    if ($ret && !is_wp_error($ret)) {
1782
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
1783
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1784
-                                            $catids_arr[] = $cat->slug;
1785
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1786
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1787
-                                            $catids_arr[] = $cat->slug;
1788
-                                        }
1789
-                                    }
1790
-                                }
1791
-                            }
1792
-                        }
1793
-                    }
1794
-                }
1795
-
1796
-                if (!$catids_arr) {
1797
-                    $catids_arr[] = 1;
1798
-                }
1799
-
1800
-                $post_tags = trim($buffer[4]); // comma seperated tags
1801
-
1802
-                $tag_arr = '';
1803
-                if ($post_tags) {
1804
-                    $tag_arr = explode(',', $post_tags);
1805
-                }
1806
-
1807
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1808
-
1809
-                $error = '';
1810
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1811
-                    $invalid_post_type++;
1812
-                    continue;
1813
-                }
1814
-
1815
-                if ($post_title != '') {
1816
-                    $menu_order = 0;
1817
-                    $image_folder_name = 'uplaod/';
1818
-
1819
-                    $image_names = array();
1820
-
1821
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
1822
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1823
-
1824
-                        if ($customKeyarray[$c] == 'IMAGE') {
1825
-                            $buffer[$c] = trim($buffer[$c]);
1826
-
1827
-                            if (!empty($buffer[$c])) {
1828
-                                $image_names[] = $buffer[$c];
1829
-                            }
1830
-                        }
1831
-
1832
-                        if ($customKeyarray[$c] == 'alive_days') {
1833
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
1834
-                                $submitdata = date('Y-m-d');
1835
-
1836
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1837
-                            } else {
1838
-                                $gd_post_info['expire_date'] = 'Never';
1839
-                            }
1840
-                        }
1841
-
1842
-                        if ($customKeyarray[$c] == 'post_city') {
1843
-                            $post_city = addslashes($buffer[$c]);
1844
-                        }
1845
-
1846
-                        if ($customKeyarray[$c] == 'post_region') {
1847
-                            $post_region = addslashes($buffer[$c]);
1848
-                        }
1849
-
1850
-                        if ($customKeyarray[$c] == 'post_country') {
1851
-                            $post_country = addslashes($buffer[$c]);
1852
-                        }
1853
-
1854
-                        if ($customKeyarray[$c] == 'post_latitude') {
1855
-                            $post_latitude = addslashes($buffer[$c]);
1856
-                        }
1857
-
1858
-                        if ($customKeyarray[$c] == 'post_longitude') {
1859
-                            $post_longitude = addslashes($buffer[$c]);
1860
-                        }
1664
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1665
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1666
+	$filename = $uploadedFile;
1667
+
1668
+	$uploads = wp_upload_dir();
1669
+	$uploads_dir = $uploads['path'];
1670
+	$image_name_arr = explode('/', $filename);
1671
+	$filename = end($image_name_arr);
1672
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1673
+	$return = array();
1674
+	$return['file'] = $uploadedFile;
1675
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1676
+
1677
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1678
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1679
+
1680
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1681
+			$return['error'] = NULL;
1682
+
1683
+			$return['rows'] = 0;
1684
+
1685
+
1686
+
1687
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1688
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1689
+						if(is_array($data) && !empty($data)) {
1690
+							$file[] = '"' . implode('","', $data) . '"';
1691
+						}
1692
+					}
1693
+					fclose($handle);
1694
+					$file = $file;
1695
+				}
1696
+
1697
+
1698
+
1699
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1700
+
1701
+
1702
+			if (!$return['rows'] > 0) {
1703
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
1704
+			}
1705
+		}
1706
+	}
1707
+	if ($task == 'prepare' || !empty($return['error'])) {
1708
+		echo json_encode($return);
1709
+		exit;
1710
+	}
1711
+
1712
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1713
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1714
+	$count = $importlimit;
1715
+	$requested_limit = $importlimit;
1716
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1717
+
1718
+	if ($count < $totRecords) {
1719
+		$count = $tmpCnt + $count;
1720
+		if ($count > $totRecords) {
1721
+			$count = $totRecords;
1722
+		}
1723
+	} else {
1724
+		$count = $totRecords;
1725
+	}
1726
+
1727
+	$total_records = 0;
1728
+	$rowcount = 0;
1729
+	$address_invalid = 0;
1730
+	$blank_address = 0;
1731
+	$upload_files = 0;
1732
+	$invalid_post_type = 0;
1733
+	$invalid_title = 0;
1734
+	$customKeyarray = array();
1735
+	$gd_post_info = array();
1736
+	$post_location = array();
1737
+	$countpost = 0;
1738
+
1739
+	if (!empty($file)) {
1740
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1741
+		$customKeyarray = $columns;
1742
+
1743
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1744
+			$return['error'] = CSV_INVAILD_FILE;
1745
+			echo json_encode($return);
1746
+			exit;
1747
+		}
1748
+
1749
+		for ($i = 1; $i <= $importlimit; $i++) {
1750
+			$current_index = $tmpCnt + $i;
1751
+			if (isset($file[$current_index])) {
1752
+				$total_records++;
1753
+
1754
+				$buffer = geodir_str_getcsv($file[$current_index]);
1755
+				$post_title = addslashes($buffer[0]);
1756
+				$current_post_author = $buffer[1];
1757
+				$post_desc = addslashes($buffer[2]);
1758
+				$post_cat = array();
1759
+				$catids_arr = array();
1760
+				$post_cat = trim($buffer[3]); // comma seperated category name
1761
+
1762
+				if ($post_cat) {
1763
+					$post_cat_arr = explode(',', $post_cat);
1764
+
1765
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
1766
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1767
+
1768
+						if (!empty($buffer[5])) {
1769
+							if (in_array($buffer[5], geodir_get_posttypes())) {
1770
+
1771
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1772
+
1773
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
1774
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1775
+									$catids_arr[] = $cat->slug;
1776
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1777
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1778
+									$catids_arr[] = $cat->slug;
1779
+								} else {
1780
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
1781
+									if ($ret && !is_wp_error($ret)) {
1782
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
1783
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1784
+											$catids_arr[] = $cat->slug;
1785
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1786
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1787
+											$catids_arr[] = $cat->slug;
1788
+										}
1789
+									}
1790
+								}
1791
+							}
1792
+						}
1793
+					}
1794
+				}
1795
+
1796
+				if (!$catids_arr) {
1797
+					$catids_arr[] = 1;
1798
+				}
1799
+
1800
+				$post_tags = trim($buffer[4]); // comma seperated tags
1801
+
1802
+				$tag_arr = '';
1803
+				if ($post_tags) {
1804
+					$tag_arr = explode(',', $post_tags);
1805
+				}
1806
+
1807
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1808
+
1809
+				$error = '';
1810
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1811
+					$invalid_post_type++;
1812
+					continue;
1813
+				}
1814
+
1815
+				if ($post_title != '') {
1816
+					$menu_order = 0;
1817
+					$image_folder_name = 'uplaod/';
1818
+
1819
+					$image_names = array();
1820
+
1821
+					for ($c = 5; $c < count($customKeyarray); $c++) {
1822
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1823
+
1824
+						if ($customKeyarray[$c] == 'IMAGE') {
1825
+							$buffer[$c] = trim($buffer[$c]);
1826
+
1827
+							if (!empty($buffer[$c])) {
1828
+								$image_names[] = $buffer[$c];
1829
+							}
1830
+						}
1831
+
1832
+						if ($customKeyarray[$c] == 'alive_days') {
1833
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
1834
+								$submitdata = date('Y-m-d');
1835
+
1836
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1837
+							} else {
1838
+								$gd_post_info['expire_date'] = 'Never';
1839
+							}
1840
+						}
1841
+
1842
+						if ($customKeyarray[$c] == 'post_city') {
1843
+							$post_city = addslashes($buffer[$c]);
1844
+						}
1845
+
1846
+						if ($customKeyarray[$c] == 'post_region') {
1847
+							$post_region = addslashes($buffer[$c]);
1848
+						}
1849
+
1850
+						if ($customKeyarray[$c] == 'post_country') {
1851
+							$post_country = addslashes($buffer[$c]);
1852
+						}
1853
+
1854
+						if ($customKeyarray[$c] == 'post_latitude') {
1855
+							$post_latitude = addslashes($buffer[$c]);
1856
+						}
1857
+
1858
+						if ($customKeyarray[$c] == 'post_longitude') {
1859
+							$post_longitude = addslashes($buffer[$c]);
1860
+						}
1861 1861
 						
1862 1862
 						// Post status
1863 1863
 						if ($customKeyarray[$c] == 'post_status') {
1864
-                            $post_status = sanitize_key( $buffer[$c] );
1865
-                        }
1866
-                    }
1867
-
1868
-                    /* ================ before array create ============== */
1869
-                    $location_result = geodir_get_default_location();
1870
-                    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'] == '')) {
1871
-                        $blank_address++;
1872
-                        continue;
1873
-                    } else if ($location_result->location_id == 0) {
1874
-                        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))) {
1875
-                            $address_invalid++;
1876
-                            continue;
1877
-                        }
1878
-                    }
1864
+							$post_status = sanitize_key( $buffer[$c] );
1865
+						}
1866
+					}
1867
+
1868
+					/* ================ before array create ============== */
1869
+					$location_result = geodir_get_default_location();
1870
+					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'] == '')) {
1871
+						$blank_address++;
1872
+						continue;
1873
+					} else if ($location_result->location_id == 0) {
1874
+						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))) {
1875
+							$address_invalid++;
1876
+							continue;
1877
+						}
1878
+					}
1879 1879
 					
1880 1880
 					// Default post status
1881 1881
 					$default_status = 'publish';
1882 1882
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
1883 1883
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
1884 1884
 
1885
-                    $my_post['post_title'] = $post_title;
1886
-                    $my_post['post_content'] = $post_desc;
1887
-                    $my_post['post_type'] = addslashes($buffer[5]);
1888
-                    $my_post['post_author'] = $current_post_author;
1889
-                    $my_post['post_status'] = $post_status;
1890
-                    $my_post['post_category'] = $catids_arr;
1891
-                    $my_post['post_tags'] = $tag_arr;
1892
-
1893
-                    $gd_post_info['post_tags'] = $tag_arr;
1894
-                    $gd_post_info['post_title'] = $post_title;
1895
-                    $gd_post_info['post_status'] = $post_status;
1896
-                    $gd_post_info['submit_time'] = time();
1897
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1898
-
1899
-                    $last_postid = wp_insert_post($my_post);
1900
-                    $countpost++;
1901
-
1902
-                    // Check if we need to save post location as new location
1903
-                    if ($location_result->location_id > 0) {
1904
-                        if (isset($post_city) && isset($post_region)) {
1905
-                            $request_info['post_location'] = array(
1906
-                                'city' => $post_city,
1907
-                                'region' => $post_region,
1908
-                                'country' => $post_country,
1909
-                                'geo_lat' => $post_latitude,
1910
-                                'geo_lng' => $post_longitude
1911
-                            );
1912
-
1913
-                            $post_location_info = $request_info['post_location'];
1914
-                            if ($location_id = geodir_add_new_location($post_location_info))
1915
-                                $post_location_id = $location_id;
1916
-                        } else {
1917
-                            $post_location_id = 0;
1918
-                        }
1919
-                    } else {
1920
-                        $post_location_id = 0;
1921
-                    }
1922
-
1923
-                    /* ------- get default package info ----- */
1924
-                    $payment_info = array();
1925
-                    $package_info = array();
1926
-
1927
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1928
-                    $package_id = '';
1929
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1930
-                        $package_id = $gd_post_info['package_id'];
1931
-                    }
1932
-
1933
-                    if (!empty($package_info)) {
1934
-                        $payment_info['package_id'] = $package_info['pid'];
1935
-
1936
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1937
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1938
-                        } else {
1939
-                            $payment_info['expire_date'] = 'Never';
1940
-                        }
1941
-
1942
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
1943
-                    }
1944
-
1945
-                    $gd_post_info['post_location_id'] = $post_location_id;
1946
-
1947
-                    $post_type = get_post_type($last_postid);
1948
-
1949
-                    $table = $plugin_prefix . $post_type . '_detail';
1950
-
1951
-                    geodir_save_post_info($last_postid, $gd_post_info);
1952
-
1953
-                    if (!empty($image_names)) {
1954
-                        $upload_files++;
1955
-                        $menu_order = 1;
1956
-
1957
-                        foreach ($image_names as $image_name) {
1958
-                            $img_name_arr = explode('.', $image_name);
1959
-
1960
-                            $uploads = wp_upload_dir();
1961
-                            $sub_dir = $uploads['subdir'];
1962
-
1963
-                            $arr_file_type = wp_check_filetype($image_name);
1964
-                            $uploaded_file_type = $arr_file_type['type'];
1965
-
1966
-                            $attachment = array();
1967
-                            $attachment['post_id'] = $last_postid;
1968
-                            $attachment['title'] = $img_name_arr[0];
1969
-                            $attachment['content'] = '';
1970
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
1971
-                            $attachment['mime_type'] = $uploaded_file_type;
1972
-                            $attachment['menu_order'] = $menu_order;
1973
-                            $attachment['is_featured'] = 0;
1974
-
1975
-                            $attachment_set = '';
1976
-
1977
-                            foreach ($attachment as $key => $val) {
1978
-                                if ($val != '')
1979
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1980
-                            }
1981
-                            $attachment_set = trim($attachment_set, ", ");
1982
-
1983
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1984
-
1985
-                            if ($menu_order == 1) {
1986
-                                $post_type = get_post_type($last_postid);
1987
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1988
-                            }
1989
-                            $menu_order++;
1990
-                        }
1991
-                    }
1992
-
1993
-                    $gd_post_info['package_id'] = $package_id;
1994
-
1995
-                    /** This action is documented in geodirectory-functions/post-functions.php */
1996
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1997
-
1998
-                    if (!empty($buffer[5])) {
1999
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
2000
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2001
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2002
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2003
-
2004
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2005
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2006
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2007
-                        }
2008
-                    }
2009
-                } else {
2010
-                    $invalid_title++;
2011
-                }
2012
-            }
2013
-        }
2014
-    }
2015
-    $return['rowcount'] = $countpost;
2016
-    $return['invalidcount'] = $address_invalid;
2017
-    $return['blank_address'] = $blank_address;
2018
-    $return['upload_files'] = $upload_files;
2019
-    $return['invalid_post_type'] = $invalid_post_type;
2020
-    $return['invalid_title'] = $invalid_title;
2021
-    $return['total_records'] = $total_records;
2022
-
2023
-    echo json_encode($return);
2024
-    exit;
1885
+					$my_post['post_title'] = $post_title;
1886
+					$my_post['post_content'] = $post_desc;
1887
+					$my_post['post_type'] = addslashes($buffer[5]);
1888
+					$my_post['post_author'] = $current_post_author;
1889
+					$my_post['post_status'] = $post_status;
1890
+					$my_post['post_category'] = $catids_arr;
1891
+					$my_post['post_tags'] = $tag_arr;
1892
+
1893
+					$gd_post_info['post_tags'] = $tag_arr;
1894
+					$gd_post_info['post_title'] = $post_title;
1895
+					$gd_post_info['post_status'] = $post_status;
1896
+					$gd_post_info['submit_time'] = time();
1897
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1898
+
1899
+					$last_postid = wp_insert_post($my_post);
1900
+					$countpost++;
1901
+
1902
+					// Check if we need to save post location as new location
1903
+					if ($location_result->location_id > 0) {
1904
+						if (isset($post_city) && isset($post_region)) {
1905
+							$request_info['post_location'] = array(
1906
+								'city' => $post_city,
1907
+								'region' => $post_region,
1908
+								'country' => $post_country,
1909
+								'geo_lat' => $post_latitude,
1910
+								'geo_lng' => $post_longitude
1911
+							);
1912
+
1913
+							$post_location_info = $request_info['post_location'];
1914
+							if ($location_id = geodir_add_new_location($post_location_info))
1915
+								$post_location_id = $location_id;
1916
+						} else {
1917
+							$post_location_id = 0;
1918
+						}
1919
+					} else {
1920
+						$post_location_id = 0;
1921
+					}
1922
+
1923
+					/* ------- get default package info ----- */
1924
+					$payment_info = array();
1925
+					$package_info = array();
1926
+
1927
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1928
+					$package_id = '';
1929
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1930
+						$package_id = $gd_post_info['package_id'];
1931
+					}
1932
+
1933
+					if (!empty($package_info)) {
1934
+						$payment_info['package_id'] = $package_info['pid'];
1935
+
1936
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1937
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1938
+						} else {
1939
+							$payment_info['expire_date'] = 'Never';
1940
+						}
1941
+
1942
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
1943
+					}
1944
+
1945
+					$gd_post_info['post_location_id'] = $post_location_id;
1946
+
1947
+					$post_type = get_post_type($last_postid);
1948
+
1949
+					$table = $plugin_prefix . $post_type . '_detail';
1950
+
1951
+					geodir_save_post_info($last_postid, $gd_post_info);
1952
+
1953
+					if (!empty($image_names)) {
1954
+						$upload_files++;
1955
+						$menu_order = 1;
1956
+
1957
+						foreach ($image_names as $image_name) {
1958
+							$img_name_arr = explode('.', $image_name);
1959
+
1960
+							$uploads = wp_upload_dir();
1961
+							$sub_dir = $uploads['subdir'];
1962
+
1963
+							$arr_file_type = wp_check_filetype($image_name);
1964
+							$uploaded_file_type = $arr_file_type['type'];
1965
+
1966
+							$attachment = array();
1967
+							$attachment['post_id'] = $last_postid;
1968
+							$attachment['title'] = $img_name_arr[0];
1969
+							$attachment['content'] = '';
1970
+							$attachment['file'] = $sub_dir . '/' . $image_name;
1971
+							$attachment['mime_type'] = $uploaded_file_type;
1972
+							$attachment['menu_order'] = $menu_order;
1973
+							$attachment['is_featured'] = 0;
1974
+
1975
+							$attachment_set = '';
1976
+
1977
+							foreach ($attachment as $key => $val) {
1978
+								if ($val != '')
1979
+									$attachment_set .= $key . " = '" . $val . "', ";
1980
+							}
1981
+							$attachment_set = trim($attachment_set, ", ");
1982
+
1983
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1984
+
1985
+							if ($menu_order == 1) {
1986
+								$post_type = get_post_type($last_postid);
1987
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1988
+							}
1989
+							$menu_order++;
1990
+						}
1991
+					}
1992
+
1993
+					$gd_post_info['package_id'] = $package_id;
1994
+
1995
+					/** This action is documented in geodirectory-functions/post-functions.php */
1996
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1997
+
1998
+					if (!empty($buffer[5])) {
1999
+						if (in_array($buffer[5], geodir_get_posttypes())) {
2000
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2001
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2002
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2003
+
2004
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2005
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2006
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2007
+						}
2008
+					}
2009
+				} else {
2010
+					$invalid_title++;
2011
+				}
2012
+			}
2013
+		}
2014
+	}
2015
+	$return['rowcount'] = $countpost;
2016
+	$return['invalidcount'] = $address_invalid;
2017
+	$return['blank_address'] = $blank_address;
2018
+	$return['upload_files'] = $upload_files;
2019
+	$return['invalid_post_type'] = $invalid_post_type;
2020
+	$return['invalid_title'] = $invalid_title;
2021
+	$return['total_records'] = $total_records;
2022
+
2023
+	echo json_encode($return);
2024
+	exit;
2025 2025
 }
2026 2026
 
2027 2027
 // Add the tab in left sidebar menu fro import & export page.
@@ -2041,9 +2041,9 @@  discard block
 block discarded – undo
2041 2041
  * @param $post object $post The post object of the post being saved.
2042 2042
  */
2043 2043
 function geodir_update_location_prefix($post_id,$post){
2044
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2045
-        update_option('geodir_location_prefix',$post->post_name);
2046
-    }
2044
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2045
+		update_option('geodir_location_prefix',$post->post_name);
2046
+	}
2047 2047
 
2048 2048
 }
2049 2049
 
@@ -2054,50 +2054,50 @@  discard block
 block discarded – undo
2054 2054
 function geodir_ga_callback(){
2055 2055
 
2056 2056
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2057
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2058
-    $code = "code=".$_REQUEST['code'];
2059
-    $grant_type = "&grant_type=authorization_code";
2060
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2061
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2062
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2057
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2058
+	$code = "code=".$_REQUEST['code'];
2059
+	$grant_type = "&grant_type=authorization_code";
2060
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2061
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2062
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2063 2063
 
2064
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2064
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2065 2065
 
2066
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2066
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2067 2067
 
2068
-    //print_r($response);
2068
+	//print_r($response);
2069 2069
 
2070
-    $error_msg =  __('Something went wrong','geodirectory');
2071
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2070
+	$error_msg =  __('Something went wrong','geodirectory');
2071
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2072 2072
 
2073
-        $parts = json_decode($response['body']);
2074
-        //print_r($parts);
2075
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2076
-        else{
2073
+		$parts = json_decode($response['body']);
2074
+		//print_r($parts);
2075
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2076
+		else{
2077 2077
 
2078
-            update_option('gd_ga_access_token', $parts->access_token);
2079
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2080
-            ?><script>window.close();</script><?php
2081
-        }
2078
+			update_option('gd_ga_access_token', $parts->access_token);
2079
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2080
+			?><script>window.close();</script><?php
2081
+		}
2082 2082
 
2083 2083
 
2084
-    }
2085
-    elseif(!empty($response['response']['code'])) {
2086
-        $parts = json_decode($response['body']);
2084
+	}
2085
+	elseif(!empty($response['response']['code'])) {
2086
+		$parts = json_decode($response['body']);
2087 2087
 
2088
-        if(isset($parts->error)){
2089
-            echo $parts->error.": ".$parts->error_description;exit;
2090
-        }else{
2091
-            echo $error_msg." - #2";exit;
2092
-        }
2088
+		if(isset($parts->error)){
2089
+			echo $parts->error.": ".$parts->error_description;exit;
2090
+		}else{
2091
+			echo $error_msg." - #2";exit;
2092
+		}
2093 2093
 
2094
-    }else{
2094
+	}else{
2095 2095
 
2096
-        echo $error_msg." - #3";exit;
2096
+		echo $error_msg." - #3";exit;
2097 2097
 
2098
-    }
2098
+	}
2099 2099
 }
2100
-    exit;
2100
+	exit;
2101 2101
 }
2102 2102
 
2103 2103
 add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
Please login to merge, or discard this patch.
geodirectory-functions/cat-meta-functions/Tax-meta-class.php 4 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -2054,6 +2054,11 @@  discard block
 block discarded – undo
2054 2054
         }
2055 2055
 
2056 2056
         //update meta
2057
+
2058
+        /**
2059
+         * @param string $term_id
2060
+         * @param string $key
2061
+         */
2057 2062
         public function update_tax_meta($term_id, $key, $value, $post_type = '')
2058 2063
         {
2059 2064
 
@@ -2095,6 +2100,12 @@  discard block
 block discarded – undo
2095 2100
 
2096 2101
 //get term meta field
2097 2102
 if (!function_exists('get_tax_meta')) {
2103
+
2104
+    /**
2105
+     * @param string $key
2106
+     *
2107
+     * @return string
2108
+     */
2098 2109
     function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2099 2110
     {
2100 2111
 
@@ -2139,6 +2150,10 @@  discard block
 block discarded – undo
2139 2150
 
2140 2151
 //update meta
2141 2152
 if (!function_exists('update_tax_meta')) {
2153
+
2154
+    /**
2155
+     * @param string $key
2156
+     */
2142 2157
     function update_tax_meta($term_id, $key, $value, $post_type = '')
2143 2158
     {
2144 2159
 
Please login to merge, or discard this patch.
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.
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', 'https://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', 'https://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' || $pagenow == 'term.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' || $pagenow == 'term.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.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
             $this->add_missed_values();
114 114
             if (isset($meta_box['use_with_theme']))
115 115
                 if ($meta_box['use_with_theme'] === true) {
116
-                    $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
116
+                    $this->SelfPath = get_stylesheet_directory_uri().'/library/cat-meta';
117 117
                 } elseif ($meta_box['use_with_theme'] === false) {
118 118
                     $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119 119
                 } else {
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                 $li = "<li id='item_{$attachment_id}'>";
263 263
                 $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
264 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>";
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 266
                 $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
267 267
                 $li .= "</li>";
268 268
                 $html .= $li;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
             $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0;
336 336
             $ok = false;
337 337
             if (strpos($field_id, '[') === false) {
338
-                check_admin_referer("at-delete-mupload_" . urldecode($field_id));
338
+                check_admin_referer("at-delete-mupload_".urldecode($field_id));
339 339
                 if ($term_id > 0)
340 340
                     $this->delete_tax_meta($term_id, $field_id);
341 341
                 //$ok = wp_delete_attachment( $attachment_id );
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 
424 424
             if ($this->has_field('date') && $this->is_edit_page()) {
425 425
                 // Enqueu JQuery UI, use proper version.
426
-                wp_enqueue_style('tmc-jquery-ui-css', 'https://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'));
426
+                wp_enqueue_style('tmc-jquery-ui-css', 'https://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 428
             }
429 429
 
430 430
         }
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
             if ($this->has_field('time') && $this->is_edit_page()) {
442 442
 
443 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);
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 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 447
 
448 448
             }
@@ -462,13 +462,13 @@  discard block
 block discarded – undo
462 462
             if (!empty($this->_meta_box['pages'])) {
463 463
                 foreach ($this->_meta_box['pages'] as $page) {
464 464
                     //add fields to edit form
465
-                    add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form'));
465
+                    add_action($page.'_edit_form_fields', array(&$this, 'show_edit_form'));
466 466
                     //add fields to add new form
467
-                    add_action($page . '_add_form_fields', array(&$this, 'show_new_form'));
467
+                    add_action($page.'_add_form_fields', array(&$this, 'show_new_form'));
468 468
                     // this saves the edit fields
469
-                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2);
469
+                    add_action('edited_'.$page, array(&$this, 'save'), 10, 2);
470 470
                     // this saves the add fields
471
-                    add_action('created_' . $page, array(&$this, 'save'), 10, 2);
471
+                    add_action('created_'.$page, array(&$this, 'save'), 10, 2);
472 472
                 }
473 473
             }
474 474
 
@@ -517,13 +517,13 @@  discard block
 block discarded – undo
517 517
                     $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
518 518
 
519 519
                 if ($field['validate_func']) {
520
-                    echo '<tr class="form-field form-required ' . $field['style'] . '">';
520
+                    echo '<tr class="form-field form-required '.$field['style'].'">';
521 521
                 } else {
522
-                    echo '<tr class="form-field ' . $field['style'] . '">';
522
+                    echo '<tr class="form-field '.$field['style'].'">';
523 523
                 }
524 524
 
525 525
                 // Call Separated methods for displaying each type of field.
526
-                call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta);
526
+                call_user_func(array(&$this, 'show_field_'.$field['type']), $field, $meta);
527 527
                 echo '</tr>';
528 528
             }
529 529
             echo '</table>';
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
                 foreach ($meta as $me) {
551 551
                     //for labling toggles
552 552
                     $mmm = $me[$field['fields'][0]['id']];
553
-                    echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">';
553
+                    echo '<div class="at-repater-block">'.$mmm.'<br/><table class="repeater-table" style="display: none;">';
554 554
                     if ($field['inline']) {
555 555
                         echo '<tr class="at-inline" VALIGN="top">';
556 556
                     }
557 557
                     foreach ($field['fields'] as $f) {
558 558
                         //reset var $id for repeater
559 559
                         $id = '';
560
-                        $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
560
+                        $id = $field['id'].'['.$c.']['.$f['id'].']';
561 561
                         $m = $me[$f['id']];
562 562
                         $m = ($m !== '') ? $m : $f['std'];
563 563
                         if ('image' != $f['type'] && $f['type'] != 'repeater')
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
                         if (!$field['inline']) {
568 568
                             echo '<tr>';
569 569
                         }
570
-                        call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m);
570
+                        call_user_func(array(&$this, 'show_field_'.$f['type']), $f, $m);
571 571
                         if (!$field['inline']) {
572 572
                             echo '</tr>';
573 573
                         }
@@ -578,18 +578,18 @@  discard block
 block discarded – undo
578 578
                     echo '</table>
579 579
 				<span class="at-re-toggle"><img src="';
580 580
                     if ($this->_Local_images) {
581
-                        echo $plugin_path . '/images/edit.png';
581
+                        echo $plugin_path.'/images/edit.png';
582 582
                     } else {
583 583
                         echo 'http://i.imgur.com/ka0E2.png';
584 584
                     }
585 585
                     echo '" alt="Edit" title="Edit"/></span> 
586 586
 				<img src="';
587 587
                     if ($this->_Local_images) {
588
-                        echo $plugin_path . '/images/remove.png';
588
+                        echo $plugin_path.'/images/remove.png';
589 589
                     } else {
590 590
                         echo 'http://i.imgur.com/g8Duj.png';
591 591
                     }
592
-                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
592
+                    echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>';
593 593
                     $c = $c + 1;
594 594
 
595 595
                 }
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
 
599 599
             echo '<img src="';
600 600
             if ($this->_Local_images) {
601
-                echo $plugin_path . '/images/add.png';
601
+                echo $plugin_path.'/images/add.png';
602 602
             } else {
603 603
                 echo 'http://i.imgur.com/w5Tuc.png';
604 604
             }
605
-            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>';
605
+            echo '" alt="'.__('Add', 'geodirectory').'" title="'.__('Add', 'geodirectory').'" id="add-'.$field['id'].'"><br/></div>';
606 606
 
607 607
             //create all fields once more for js function and catch with object buffer
608 608
             ob_start();
@@ -613,12 +613,12 @@  discard block
 block discarded – undo
613 613
             foreach ($field['fields'] as $f) {
614 614
                 //reset var $id for repeater
615 615
                 $id = '';
616
-                $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']';
616
+                $id = $field['id'].'[CurrentCounter]['.$f['id'].']';
617 617
                 $f['id'] = $id;
618 618
                 if (!$field['inline']) {
619 619
                     echo '<tr>';
620 620
                 }
621
-                call_user_func(array(&$this, 'show_field_' . $f['type']), $f, '');
621
+                call_user_func(array(&$this, 'show_field_'.$f['type']), $f, '');
622 622
                 if (!$field['inline']) {
623 623
                     echo '</tr>';
624 624
                 }
@@ -628,24 +628,24 @@  discard block
 block discarded – undo
628 628
             }
629 629
             echo '</table><img src="';
630 630
             if ($this->_Local_images) {
631
-                echo $plugin_path . '/images/remove.png';
631
+                echo $plugin_path.'/images/remove.png';
632 632
             } else {
633 633
                 echo 'http://i.imgur.com/g8Duj.png';
634 634
             }
635
-            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
636
-            $counter = 'countadd_' . $field['id'];
635
+            echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>';
636
+            $counter = 'countadd_'.$field['id'];
637 637
             $js_code = ob_get_clean();
638 638
             $js_code = str_replace("'", "\"", $js_code);
639
-            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code);
639
+            $js_code = str_replace("CurrentCounter", "' + ".$counter." + '", $js_code);
640 640
             echo '<script>
641 641
 				jQuery(document).ready(function() {
642
-					var ' . $counter . ' = ' . $c . ';
643
-					jQuery("#add-' . $field['id'] . '").live(\'click\', function() {
644
-						' . $counter . ' = ' . $counter . ' + 1;
645
-						jQuery(this).before(\'' . $js_code . '\');						
642
+					var ' . $counter.' = '.$c.';
643
+					jQuery("#add-' . $field['id'].'").live(\'click\', function() {
644
+						' . $counter.' = '.$counter.' + 1;
645
+						jQuery(this).before(\'' . $js_code.'\');						
646 646
 						update_repeater_fields();
647 647
 					});
648
-        			jQuery("#remove-' . $field['id'] . '").live(\'click\', function() {
648
+        			jQuery("#remove-' . $field['id'].'").live(\'click\', function() {
649 649
             			jQuery(this).parent().remove();
650 650
         			});
651 651
     			});
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
         public function show_field_paragraph($field)
773 773
         {
774 774
             //$this->show_field_begin( $field, $meta );
775
-            echo '<p>' . $field['value'] . '</p>';
775
+            echo '<p>'.$field['value'].'</p>';
776 776
             //$this->show_field_end( $field, $meta );
777 777
         }
778 778
 
@@ -803,12 +803,12 @@  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
-            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
809
+            echo "<select class='at-select' name='{$field['id']}".($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'").">";
810 810
             foreach ($field['options'] as $key => $value) {
811
-                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>";
811
+                echo "<option value='{$key}'".selected(in_array($key, $meta), true, false).">{$value}</option>";
812 812
             }
813 813
             echo "</select>";
814 814
             $this->show_field_end($field, $meta);
@@ -827,11 +827,11 @@  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) {
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>";
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 835
             }
836 836
             $this->show_field_end($field, $meta);
837 837
         }
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
         {
849 849
 
850 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']}";
851
+            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'".checked(!empty($meta), true, false)." /> {$field['desc']}";
852 852
             $this->show_field_end($field, $meta);
853 853
         }
854 854
 
@@ -890,18 +890,18 @@  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 />";
897 897
 
898 898
             if (!empty($meta)) {
899 899
                 $nonce = wp_create_nonce('at_ajax_delete');
900
-                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>';
900
+                echo '<div style="margin-bottom: 10px"><strong>'.__('Uploaded files', 'geodirectory').'</strong></div>';
901 901
                 echo '<ol class="at-upload">';
902 902
                 foreach ($meta as $att) {
903 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>";
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 905
                 }
906 906
                 echo '</ol>';
907 907
             }
@@ -909,13 +909,13 @@  discard block
 block discarded – undo
909 909
             // show form upload
910 910
 
911 911
             echo "<div class='at-file-upload-label'>";
912
-            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>";
912
+            echo "<strong>".__('Upload new files', 'geodirectory')."</strong>";
913 913
             echo "</div>";
914 914
             echo "<div class='new-files'>";
915 915
             echo "<div class='file-input'>";
916 916
             echo "<input type='file' name='{$field['id']}[]' />";
917 917
             echo "</div><!-- End .file-input -->";
918
-            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>";
918
+            echo "<a class='at-add-file button' href='#'>".__('Add more files', 'geodirectory')."</a>";
919 919
             echo "</div><!-- End .new-files -->";
920 920
             echo "</td>";
921 921
             $this->show_field_end($field, $meta);
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
         public function show_field_image($field, $meta)
933 933
         {
934 934
             $this->show_field_begin($field, $meta);
935
-            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
935
+            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_".$field['id'], false, false);
936 936
             if (is_array($meta)) {
937 937
                 if (isset($meta[0]) && is_array($meta[0]))
938 938
                     $meta = $meta[0];
@@ -958,20 +958,20 @@  discard block
 block discarded – undo
958 958
 
959 959
                 $sub_dir = str_replace($uploads_baseurl, '', $sub_dir);
960 960
 
961
-                $uploads_url = $uploads_baseurl . $sub_dir;
961
+                $uploads_url = $uploads_baseurl.$sub_dir;
962 962
 
963
-                $meta['src'] = $uploads_url . '/' . $file_name;
963
+                $meta['src'] = $uploads_url.'/'.$file_name;
964 964
 
965 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') . "' />";
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 970
             } else {
971 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') . "' />";
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 975
             }
976 976
             echo $html;
977 977
             $this->show_field_end($field, $meta);
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 
996 996
             echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />";
997 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') . "'/>";
998
+            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='".__('Select a color', 'geodirectory')."'/>";
999 999
             echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>";
1000 1000
             $this->show_field_end($field, $meta);
1001 1001
 
@@ -1013,14 +1013,14 @@  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
 
1020 1020
             $html = array();
1021 1021
 
1022 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}";
1023
+                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'".checked(in_array($key, $meta), true, false)." /> {$value}";
1024 1024
             }
1025 1025
 
1026 1026
             echo implode('<br />', $html);
@@ -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']);
@@ -1081,13 +1081,13 @@  discard block
 block discarded – undo
1081 1081
             // checkbox_list
1082 1082
             if ('checkbox_list' == $options['type']) {
1083 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/>";
1084
+                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'".checked(in_array($p->ID, $meta), true, false)." /> $p->post_title<br/>";
1085 1085
                 }
1086 1086
             } // select
1087 1087
             else {
1088
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1088
+                echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">";
1089 1089
                 foreach ($posts as $p) {
1090
-                    echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>";
1090
+                    echo "<option value='$p->ID'".selected(in_array($p->ID, $meta), true, false).">$p->post_title</option>";
1091 1091
                 }
1092 1092
                 echo "</select>";
1093 1093
             }
@@ -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']);
@@ -1119,13 +1119,13 @@  discard block
 block discarded – undo
1119 1119
             // checkbox_list
1120 1120
             if ('checkbox_list' == $options['type']) {
1121 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/>";
1122
+                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'".checked(in_array($term->slug, $meta), true, false)." /> $term->name<br/>";
1123 1123
                 }
1124 1124
             } // select
1125 1125
             else {
1126
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1126
+                echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">";
1127 1127
                 foreach ($terms as $term) {
1128
-                    echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>";
1128
+                    echo "<option value='$term->slug'".selected(in_array($term->slug, $meta), true, false).">$term->name</option>";
1129 1129
                 }
1130 1130
                 echo "</select>";
1131 1131
             }
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 
1182 1182
                     //$old_filename = $upload_dir['path'].'/'.$old_filename;
1183 1183
 
1184
-                    $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png';
1184
+                    $new_filename = $upload_dir['path'].'/'.'cat_icon_'.$term_id.'.png';
1185 1185
 
1186 1186
                     /*rename($old_filename, $new_filename);
1187 1187
 				
@@ -1223,9 +1223,9 @@  discard block
 block discarded – undo
1223 1223
                 if ($type != "paragraph") {
1224 1224
 
1225 1225
                     // Call defined method to save meta value, if there's no methods, call common one.
1226
-                    $save_func = 'save_field_' . $type;
1226
+                    $save_func = 'save_field_'.$type;
1227 1227
                     if (method_exists($this, $save_func)) {
1228
-                        call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new);
1228
+                        call_user_func(array(&$this, 'save_field_'.$type), $term_id, $field, $old, $new);
1229 1229
                     } else {
1230 1230
                         $this->save_field($term_id, $field, $old, $new);
1231 1231
                     }
@@ -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
-        $m = get_option('tax_meta_' . $post_type . $term_id);
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,13 +2147,13 @@  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
-        update_option('tax_meta_' . $post_type . $term_id, $m);
2156
+        update_option('tax_meta_'.$post_type.$term_id, $m);
2157 2157
 
2158 2158
         /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */
2159 2159
         do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
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.
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.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -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
 /**
@@ -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
 /**
@@ -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,57 +315,57 @@  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();
328
-                    $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>';
328
+                    $shop_link = '<a href="'.$shop_url.'">'.$shop_title.'</a>';
329 329
                 }
330 330
 
331 331
                 if (is_front_page()) {
332
-                    echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>';
332
+                    echo '<div class="x-breadcrumbs">'.$current_before.$home_text.$current_after.'</div>';
333 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>';
334
+                    echo '<div class="x-breadcrumbs"><a href="'.$home_link.'">'.$home_text.'</a>'.$delimiter.$current_before.$blog_title.$current_after.'</div>';
335 335
                 } else {
336
-                    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
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 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;
340
+                        echo $current_before.single_cat_title('', false).$current_after;
341 341
                     } elseif (x_is_product_category()) {
342
-                        echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
342
+                        echo $shop_link.$delimiter.$current_before.single_cat_title('', false).$current_after;
343 343
                     } elseif (x_is_product_tag()) {
344
-                        echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after;
344
+                        echo $shop_link.$delimiter.$current_before.single_tag_title('', false).$current_after;
345 345
                     } elseif (is_search()) {
346
-                        echo $current_before . __('Search Results for ', '__x__') . '&#8220;' . get_search_query() . '&#8221;' . $current_after;
346
+                        echo $current_before.__('Search Results for ', '__x__').'&#8220;'.get_search_query().'&#8221;'.$current_after;
347 347
                     } elseif (is_singular('post')) {
348 348
                         if (get_option('page_for_posts') == is_front_page()) {
349
-                            echo $current_before . $page_title . $current_after;
349
+                            echo $current_before.$page_title.$current_after;
350 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;
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 352
                         }
353 353
                     } elseif (x_is_portfolio()) {
354
-                        echo $current_before . get_the_title() . $current_after;
354
+                        echo $current_before.get_the_title().$current_after;
355 355
                     } elseif (x_is_portfolio_item()) {
356 356
                         $link = x_get_parent_portfolio_link();
357 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;
358
+                        echo '<a href="'.$link.'" title="'.esc_attr(__('See All Posts', '__x__')).'">'.$title.'</a>'.$delimiter.$current_before.$page_title.$current_after;
359 359
                     } elseif (x_is_product()) {
360
-                        echo $shop_link . $delimiter . $current_before . $page_title . $current_after;
360
+                        echo $shop_link.$delimiter.$current_before.$page_title.$current_after;
361 361
                     } elseif (is_page() && !$post->post_parent) {
362
-                        echo $current_before . $page_title . $current_after;
362
+                        echo $current_before.$page_title.$current_after;
363 363
                     } elseif (is_page() && $post->post_parent) {
364 364
                         $parent_id = $post->post_parent;
365 365
                         $breadcrumbs = array();
366 366
                         while ($parent_id) {
367 367
                             $page = get_page($parent_id);
368
-                            $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
368
+                            $breadcrumbs[] = '<a href="'.get_permalink($page->ID).'">'.get_the_title($page->ID).'</a>';
369 369
                             $parent_id = $page->post_parent;
370 370
                         }
371 371
                         $breadcrumbs = array_reverse($breadcrumbs);
@@ -373,24 +373,24 @@  discard block
 block discarded – undo
373 373
                             echo $breadcrumbs[$i];
374 374
                             if ($i != count($breadcrumbs) - 1) echo $delimiter;
375 375
                         }
376
-                        echo $delimiter . $current_before . $page_title . $current_after;
376
+                        echo $delimiter.$current_before.$page_title.$current_after;
377 377
                     } elseif (is_tag()) {
378
-                        echo $current_before . single_tag_title('', false) . $current_after;
378
+                        echo $current_before.single_tag_title('', false).$current_after;
379 379
                     } elseif (is_author()) {
380 380
                         GLOBAL $author;
381 381
                         $userdata = get_userdata($author);
382
-                        echo $current_before . __('Posts by ', '__x__') . '&#8220;' . $userdata->display_name . $current_after . '&#8221;';
382
+                        echo $current_before.__('Posts by ', '__x__').'&#8220;'.$userdata->display_name.$current_after.'&#8221;';
383 383
                     } elseif (is_404()) {
384
-                        echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after;
384
+                        echo $current_before.__('404 (Page Not Found)', '__x__').$current_after;
385 385
                     } elseif (is_archive()) {
386 386
                         if (x_is_shop()) {
387
-                            echo $current_before . $shop_title . $current_after;
387
+                            echo $current_before.$shop_title.$current_after;
388 388
                         } else {
389
-                            echo $current_before . __('Archives ', '__x__') . $current_after;
389
+                            echo $current_before.__('Archives ', '__x__').$current_after;
390 390
                         }
391 391
                     }
392 392
                     if (get_query_var('paged')) {
393
-                        echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>';
393
+                        echo ' <span class="current" style="white-space: nowrap;">('.__('Page', '__x__').' '.get_query_var('paged').')</span>';
394 394
                     }
395 395
                     echo '</div>';
396 396
                 }
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
     }
@@ -1331,8 +1338,9 @@  discard block
 block discarded – undo
1331 1338
     $tabs_array = geodir_detail_page_tabs_array();
1332 1339
     if (!empty($tabs_excluded)) {
1333 1340
         foreach ($tabs_excluded as $tab) {
1334
-            if (array_key_exists($tab, $tabs_array))
1335
-                unset($tabs_array[$tab]);
1341
+            if (array_key_exists($tab, $tabs_array)) {
1342
+                            unset($tabs_array[$tab]);
1343
+            }
1336 1344
         }
1337 1345
     }
1338 1346
     return $tabs_array;
@@ -1370,8 +1378,9 @@  discard block
 block discarded – undo
1370 1378
         $video = geodir_get_video($post->ID);
1371 1379
         $special_offers = geodir_get_special_offers($post->ID);
1372 1380
         $related_listing_array = array();
1373
-        if (get_option('geodir_add_related_listing_posttypes'))
1374
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1381
+        if (get_option('geodir_add_related_listing_posttypes')) {
1382
+                    $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1383
+        }
1375 1384
 
1376 1385
         $related_listing = '';
1377 1386
         if (in_array($post->post_type, $related_listing_array)) {
@@ -1417,11 +1426,13 @@  discard block
 block discarded – undo
1417 1426
         $video = isset($post->geodir_video) ? $post->geodir_video : '';
1418 1427
         $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1419 1428
 
1420
-        if (isset($post->post_images))
1421
-            $post->post_images = trim($post->post_images, ",");
1429
+        if (isset($post->post_images)) {
1430
+                    $post->post_images = trim($post->post_images, ",");
1431
+        }
1422 1432
 
1423
-        if (isset($post->post_images) && !empty($post->post_images))
1424
-            $post_images = explode(",", $post->post_images);
1433
+        if (isset($post->post_images) && !empty($post->post_images)) {
1434
+                    $post_images = explode(",", $post->post_images);
1435
+        }
1425 1436
 
1426 1437
         $thumb_image = '';
1427 1438
         if (!empty($post_images)) {
Please login to merge, or discard this patch.
Indentation   +1398 added lines, -1398 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * @global object $gd_session GeoDirectory Session object.
18 18
  */
19 19
 function geodir_list_view_select() {
20
-    global $gd_session;
20
+	global $gd_session;
21 21
 	?>
22 22
     <script type="text/javascript">
23 23
 	function geodir_list_view_select(list) {
@@ -86,63 +86,63 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function geodir_max_excerpt($charlength)
88 88
 {
89
-    global $post;
90
-    if ($charlength == '0') {
91
-        return;
92
-    }
93
-    $out = '';
89
+	global $post;
90
+	if ($charlength == '0') {
91
+		return;
92
+	}
93
+	$out = '';
94 94
 	
95 95
 	$temp_post = $post;
96 96
 	$excerpt = get_the_excerpt();
97 97
 
98
-    $charlength++;
99
-    $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
100
-    if (mb_strlen($excerpt) > $charlength) {
101
-        if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
102
-            $excut = -(mb_strlen($excerpt_more));
103
-            $subex = mb_substr($excerpt, 0, $excut);
104
-            if ($charlength > 0 && mb_strlen($subex) > $charlength) {
105
-                $subex = mb_substr($subex, 0, $charlength);
106
-            }
107
-            $out .= $subex;
108
-        } else {
109
-            $subex = mb_substr($excerpt, 0, $charlength - 5);
110
-            $exwords = explode(' ', $subex);
111
-            $excut = -(mb_strlen($exwords[count($exwords) - 1]));
112
-            if ($excut < 0) {
113
-                $out .= mb_substr($subex, 0, $excut);
114
-            } else {
115
-                $out .= $subex;
116
-            }
117
-        }
118
-        $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
119
-        /**
120
-         * Filter excerpt read more text.
121
-         *
122
-         * @since 1.0.0
123
-         */
124
-        $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
125
-        $out .= '</a>';
126
-
127
-    } else {
128
-        if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129
-            $excut = -(mb_strlen($excerpt_more));
130
-            $out .= mb_substr($excerpt, 0, $excut);
131
-            $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
132
-            /**
133
-             * Filter excerpt read more text.
134
-             *
135
-             * @since 1.0.0
136
-             */
137
-            $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
138
-            $out .= '</a>';
139
-        } else {
140
-            $out .= $excerpt;
141
-        }
142
-    }
98
+	$charlength++;
99
+	$excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
100
+	if (mb_strlen($excerpt) > $charlength) {
101
+		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
102
+			$excut = -(mb_strlen($excerpt_more));
103
+			$subex = mb_substr($excerpt, 0, $excut);
104
+			if ($charlength > 0 && mb_strlen($subex) > $charlength) {
105
+				$subex = mb_substr($subex, 0, $charlength);
106
+			}
107
+			$out .= $subex;
108
+		} else {
109
+			$subex = mb_substr($excerpt, 0, $charlength - 5);
110
+			$exwords = explode(' ', $subex);
111
+			$excut = -(mb_strlen($exwords[count($exwords) - 1]));
112
+			if ($excut < 0) {
113
+				$out .= mb_substr($subex, 0, $excut);
114
+			} else {
115
+				$out .= $subex;
116
+			}
117
+		}
118
+		$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
119
+		/**
120
+		 * Filter excerpt read more text.
121
+		 *
122
+		 * @since 1.0.0
123
+		 */
124
+		$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
125
+		$out .= '</a>';
126
+
127
+	} else {
128
+		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129
+			$excut = -(mb_strlen($excerpt_more));
130
+			$out .= mb_substr($excerpt, 0, $excut);
131
+			$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
132
+			/**
133
+			 * Filter excerpt read more text.
134
+			 *
135
+			 * @since 1.0.0
136
+			 */
137
+			$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
138
+			$out .= '</a>';
139
+		} else {
140
+			$out .= $excerpt;
141
+		}
142
+	}
143 143
 	$post = $temp_post;
144 144
 
145
-    return $out;
145
+	return $out;
146 146
 }
147 147
 
148 148
 /**
@@ -157,34 +157,34 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function geodir_post_package_info($package_info, $post = '', $post_type = '')
159 159
 {
160
-    $package_info['pid'] = 0;
161
-    $package_info['days'] = 0;
162
-    $package_info['amount'] = 0;
163
-    $package_info['is_featured'] = 0;
164
-    $package_info['image_limit'] = '';
165
-    $package_info['google_analytics'] = 1;
166
-    $package_info['sendtofriend'] = 1;
167
-
168
-    /**
169
-     * Filter listing package info.
170
-     *
171
-     * @since 1.0.0
172
-     * @param array $package_info {
173
-     *    Attributes of the package_info.
174
-     *
175
-     *    @type int $pid Package ID. Default 0.
176
-     *    @type int $days Package validity in Days. Default 0.
177
-     *    @type int $amount Package amount. Default 0.
178
-     *    @type int $is_featured Is this featured package? Default 0.
179
-     *    @type string $image_limit Image limit for this package. Default "".
180
-     *    @type int $google_analytics Add analytics to this package. Default 1.
181
-     *    @type int $sendtofriend Send to friend. Default 1.
182
-     *
183
-     * }
184
-     * @param object|string $post The post object.
185
-     * @param string $post_type The post type.
186
-     */
187
-    return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
160
+	$package_info['pid'] = 0;
161
+	$package_info['days'] = 0;
162
+	$package_info['amount'] = 0;
163
+	$package_info['is_featured'] = 0;
164
+	$package_info['image_limit'] = '';
165
+	$package_info['google_analytics'] = 1;
166
+	$package_info['sendtofriend'] = 1;
167
+
168
+	/**
169
+	 * Filter listing package info.
170
+	 *
171
+	 * @since 1.0.0
172
+	 * @param array $package_info {
173
+	 *    Attributes of the package_info.
174
+	 *
175
+	 *    @type int $pid Package ID. Default 0.
176
+	 *    @type int $days Package validity in Days. Default 0.
177
+	 *    @type int $amount Package amount. Default 0.
178
+	 *    @type int $is_featured Is this featured package? Default 0.
179
+	 *    @type string $image_limit Image limit for this package. Default "".
180
+	 *    @type int $google_analytics Add analytics to this package. Default 1.
181
+	 *    @type int $sendtofriend Send to friend. Default 1.
182
+	 *
183
+	 * }
184
+	 * @param object|string $post The post object.
185
+	 * @param string $post_type The post type.
186
+	 */
187
+	return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
188 188
 
189 189
 }
190 190
 
@@ -212,127 +212,127 @@  discard block
 block discarded – undo
212 212
  */
213 213
 function geodir_send_inquiry($request)
214 214
 {
215
-    global $wpdb;
215
+	global $wpdb;
216 216
 
217
-    // strip slashes from text
218
-    $request = !empty($request) ? stripslashes_deep($request) : $request;
217
+	// strip slashes from text
218
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
219 219
 
220
-    $yourname = $request['inq_name'];
221
-    $youremail = $request['inq_email'];
222
-    $inq_phone = $request['inq_phone'];
223
-    $frnd_comments = $request['inq_msg'];
224
-    $pid = $request['pid'];
220
+	$yourname = $request['inq_name'];
221
+	$youremail = $request['inq_email'];
222
+	$inq_phone = $request['inq_phone'];
223
+	$frnd_comments = $request['inq_msg'];
224
+	$pid = $request['pid'];
225 225
 
226
-    $author_id = '';
227
-    $post_title = '';
226
+	$author_id = '';
227
+	$post_title = '';
228 228
 
229
-    if ($request['pid']) {
229
+	if ($request['pid']) {
230 230
 
231
-        $productinfosql = $wpdb->prepare(
232
-            "select ID,post_author,post_title from $wpdb->posts where ID =%d",
233
-            array($request['pid'])
234
-        );
235
-        $productinfo = $wpdb->get_row($productinfosql);
231
+		$productinfosql = $wpdb->prepare(
232
+			"select ID,post_author,post_title from $wpdb->posts where ID =%d",
233
+			array($request['pid'])
234
+		);
235
+		$productinfo = $wpdb->get_row($productinfosql);
236 236
 
237
-        $author_id = $productinfo->post_author;
238
-        $post_title = $productinfo->post_title;
239
-    }
237
+		$author_id = $productinfo->post_author;
238
+		$post_title = $productinfo->post_title;
239
+	}
240 240
 
241
-    $post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>';
241
+	$post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>';
242 242
 
243
-    $user_info = get_userdata($author_id);
244
-    $to_email = geodir_get_post_meta($pid, 'geodir_email', true);
245
-    $to_name = geodir_get_client_name($author_id);
243
+	$user_info = get_userdata($author_id);
244
+	$to_email = geodir_get_post_meta($pid, 'geodir_email', true);
245
+	$to_name = geodir_get_client_name($author_id);
246 246
 
247
-    if ($to_email == '') {
248
-        $to_email = get_option('admin_email');
249
-    }
247
+	if ($to_email == '') {
248
+		$to_email = get_option('admin_email');
249
+	}
250 250
 
251
-    /**
252
-     * Called after the send enquiry var have been set but before the email has been sent.
253
-     *
254
-     * @since 1.0.0
255
-     * @param array $request {
256
-     *    The submitted form fields as an array.
257
-     *
258
-     *    @type string $sendact Enquiry type. Default "send_inqury".
259
-     *    @type string $pid Post ID.
260
-     *    @type string $inq_name Sender name.
261
-     *    @type string $inq_email Sender mail.
262
-     *    @type string $inq_phone Sender phone.
263
-     *    @type string $inq_msg Email message.
264
-     *
265
-     * }
266
-     * @param string $type The form type, default: `Enquiry`.
267
-     */
268
-    do_action('geodir_after_send_enquiry', $request, 'Enquiry');
269
-
270
-    $client_message = $frnd_comments;
271
-    $client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
272
-    /**
273
-     * Filter client message text.
274
-     *
275
-     * @since 1.0.0
276
-     * @param string $client_message Client message text.
277
-     */
278
-    $client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
279
-
280
-    /**
281
-     * Called before the send enquiry email is sent.
282
-     *
283
-     * @since 1.0.0
284
-     * @param array $request {
285
-     *    The submitted form fields as an array.
286
-     *
287
-     *    @type string $sendact Enquiry type. Default "send_inqury".
288
-     *    @type string $pid Post ID.
289
-     *    @type string $inq_name Sender name.
290
-     *    @type string $inq_email Sender mail.
291
-     *    @type string $inq_phone Sender phone.
292
-     *    @type string $inq_msg Email message.
293
-     *
294
-     * }
295
-     */
296
-    do_action('geodir_before_send_enquiry_email', $request);
297
-    if ($to_email) {
298
-        // strip slashes message
299
-        $client_message = stripslashes_deep($client_message);
300
-
301
-        geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
302
-    }
251
+	/**
252
+	 * Called after the send enquiry var have been set but before the email has been sent.
253
+	 *
254
+	 * @since 1.0.0
255
+	 * @param array $request {
256
+	 *    The submitted form fields as an array.
257
+	 *
258
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
259
+	 *    @type string $pid Post ID.
260
+	 *    @type string $inq_name Sender name.
261
+	 *    @type string $inq_email Sender mail.
262
+	 *    @type string $inq_phone Sender phone.
263
+	 *    @type string $inq_msg Email message.
264
+	 *
265
+	 * }
266
+	 * @param string $type The form type, default: `Enquiry`.
267
+	 */
268
+	do_action('geodir_after_send_enquiry', $request, 'Enquiry');
303 269
 
304
-    /**
305
-     * Called after the send enquiry email is sent.
306
-     *
307
-     * @since 1.0.0
308
-     * @param array $request {
309
-     *    The submitted form fields as an array.
310
-     *
311
-     *    @type string $sendact Enquiry type. Default "send_inqury".
312
-     *    @type string $pid Post ID.
313
-     *    @type string $inq_name Sender name.
314
-     *    @type string $inq_email Sender mail.
315
-     *    @type string $inq_phone Sender phone.
316
-     *    @type string $inq_msg Email message.
317
-     *
318
-     * }
319
-     */
320
-    do_action('geodir_after_send_enquiry_email', $request);
321
-    $url = get_permalink($pid);
322
-    if (strstr($url, '?')) {
323
-        $url = $url . "&send_inquiry=success";
324
-    } else {
325
-        $url = $url . "?send_inquiry=success";
326
-    }
327
-    /**
328
-     * Filter redirect url after the send enquiry email is sent.
329
-     *
330
-     * @since 1.0.0
331
-     * @param string $url Redirect url.
332
-     */
333
-    $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
334
-    wp_redirect($url);
335
-    gd_die();
270
+	$client_message = $frnd_comments;
271
+	$client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
272
+	/**
273
+	 * Filter client message text.
274
+	 *
275
+	 * @since 1.0.0
276
+	 * @param string $client_message Client message text.
277
+	 */
278
+	$client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
279
+
280
+	/**
281
+	 * Called before the send enquiry email is sent.
282
+	 *
283
+	 * @since 1.0.0
284
+	 * @param array $request {
285
+	 *    The submitted form fields as an array.
286
+	 *
287
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
288
+	 *    @type string $pid Post ID.
289
+	 *    @type string $inq_name Sender name.
290
+	 *    @type string $inq_email Sender mail.
291
+	 *    @type string $inq_phone Sender phone.
292
+	 *    @type string $inq_msg Email message.
293
+	 *
294
+	 * }
295
+	 */
296
+	do_action('geodir_before_send_enquiry_email', $request);
297
+	if ($to_email) {
298
+		// strip slashes message
299
+		$client_message = stripslashes_deep($client_message);
300
+
301
+		geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
302
+	}
303
+
304
+	/**
305
+	 * Called after the send enquiry email is sent.
306
+	 *
307
+	 * @since 1.0.0
308
+	 * @param array $request {
309
+	 *    The submitted form fields as an array.
310
+	 *
311
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
312
+	 *    @type string $pid Post ID.
313
+	 *    @type string $inq_name Sender name.
314
+	 *    @type string $inq_email Sender mail.
315
+	 *    @type string $inq_phone Sender phone.
316
+	 *    @type string $inq_msg Email message.
317
+	 *
318
+	 * }
319
+	 */
320
+	do_action('geodir_after_send_enquiry_email', $request);
321
+	$url = get_permalink($pid);
322
+	if (strstr($url, '?')) {
323
+		$url = $url . "&send_inquiry=success";
324
+	} else {
325
+		$url = $url . "?send_inquiry=success";
326
+	}
327
+	/**
328
+	 * Filter redirect url after the send enquiry email is sent.
329
+	 *
330
+	 * @since 1.0.0
331
+	 * @param string $url Redirect url.
332
+	 */
333
+	$url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
334
+	wp_redirect($url);
335
+	gd_die();
336 336
 
337 337
 }
338 338
 
@@ -361,85 +361,85 @@  discard block
 block discarded – undo
361 361
  */
362 362
 function geodir_send_friend($request)
363 363
 {
364
-    global $wpdb;
365
-
366
-    // strip slashes from text
367
-    $request = !empty($request) ? stripslashes_deep($request) : $request;
368
-
369
-    $yourname = $request['yourname'];
370
-    $youremail = $request['youremail'];
371
-    $frnd_subject = $request['frnd_subject'];
372
-    $frnd_comments = $request['frnd_comments'];
373
-    $pid = $request['pid'];
374
-    $to_email = $request['to_email'];
375
-    $to_name = $request['to_name'];
376
-    if ($request['pid']) {
377
-        $productinfosql = $wpdb->prepare(
378
-            "select ID,post_title from $wpdb->posts where ID =%d",
379
-            array($request['pid'])
380
-        );
381
-        $productinfo = $wpdb->get_results($productinfosql);
382
-        foreach ($productinfo as $productinfoObj) {
383
-            $post_title = $productinfoObj->post_title;
384
-        }
385
-    }
364
+	global $wpdb;
365
+
366
+	// strip slashes from text
367
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
368
+
369
+	$yourname = $request['yourname'];
370
+	$youremail = $request['youremail'];
371
+	$frnd_subject = $request['frnd_subject'];
372
+	$frnd_comments = $request['frnd_comments'];
373
+	$pid = $request['pid'];
374
+	$to_email = $request['to_email'];
375
+	$to_name = $request['to_name'];
376
+	if ($request['pid']) {
377
+		$productinfosql = $wpdb->prepare(
378
+			"select ID,post_title from $wpdb->posts where ID =%d",
379
+			array($request['pid'])
380
+		);
381
+		$productinfo = $wpdb->get_results($productinfosql);
382
+		foreach ($productinfo as $productinfoObj) {
383
+			$post_title = $productinfoObj->post_title;
384
+		}
385
+	}
386 386
 
387
-    /**
388
-     * Called before the send to friend email is sent.
389
-     *
390
-     * @since 1.0.0
391
-     * @param array $request {
392
-     *    The submitted form fields as an array.
393
-     *
394
-     *    @type string $sendact Enquiry type. Default "email_frnd".
395
-     *    @type string $pid Post ID.
396
-     *    @type string $to_name Friend name.
397
-     *    @type string $to_email Friend email.
398
-     *    @type string $yourname Sender name.
399
-     *    @type string $youremail Sender email.
400
-     *    @type string $frnd_subject Email subject.
401
-     *    @type string $frnd_comments Email Message.
402
-     *
403
-     * }
404
-     */
405
-    do_action('geodir_before_send_to_friend_email', $request);
406
-    geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
407
-
408
-    /**
409
-     * Called after the send to friend email is sent.
410
-     *
411
-     * @since 1.0.0
412
-     * @param array $request {
413
-     *    The submitted form fields as an array.
414
-     *
415
-     *    @type string $sendact Enquiry type. Default "email_frnd".
416
-     *    @type string $pid Post ID.
417
-     *    @type string $to_name Friend name.
418
-     *    @type string $to_email Friend email.
419
-     *    @type string $yourname Sender name.
420
-     *    @type string $youremail Sender email.
421
-     *    @type string $frnd_subject Email subject.
422
-     *    @type string $frnd_comments Email Message.
423
-     *
424
-     * }
425
-     */
426
-    do_action('geodir_after_send_to_friend_email', $request);
427
-
428
-    $url = get_permalink($pid);
429
-    if (strstr($url, '?')) {
430
-        $url = $url . "&sendtofrnd=success";
431
-    } else {
432
-        $url = $url . "?sendtofrnd=success";
433
-    }
434
-    /**
435
-     * Filter redirect url after the send to friend email is sent.
436
-     *
437
-     * @since 1.0.0
438
-     * @param string $url Redirect url.
439
-     */
440
-    $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
441
-    wp_redirect($url);
442
-    gd_die();
387
+	/**
388
+	 * Called before the send to friend email is sent.
389
+	 *
390
+	 * @since 1.0.0
391
+	 * @param array $request {
392
+	 *    The submitted form fields as an array.
393
+	 *
394
+	 *    @type string $sendact Enquiry type. Default "email_frnd".
395
+	 *    @type string $pid Post ID.
396
+	 *    @type string $to_name Friend name.
397
+	 *    @type string $to_email Friend email.
398
+	 *    @type string $yourname Sender name.
399
+	 *    @type string $youremail Sender email.
400
+	 *    @type string $frnd_subject Email subject.
401
+	 *    @type string $frnd_comments Email Message.
402
+	 *
403
+	 * }
404
+	 */
405
+	do_action('geodir_before_send_to_friend_email', $request);
406
+	geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
407
+
408
+	/**
409
+	 * Called after the send to friend email is sent.
410
+	 *
411
+	 * @since 1.0.0
412
+	 * @param array $request {
413
+	 *    The submitted form fields as an array.
414
+	 *
415
+	 *    @type string $sendact Enquiry type. Default "email_frnd".
416
+	 *    @type string $pid Post ID.
417
+	 *    @type string $to_name Friend name.
418
+	 *    @type string $to_email Friend email.
419
+	 *    @type string $yourname Sender name.
420
+	 *    @type string $youremail Sender email.
421
+	 *    @type string $frnd_subject Email subject.
422
+	 *    @type string $frnd_comments Email Message.
423
+	 *
424
+	 * }
425
+	 */
426
+	do_action('geodir_after_send_to_friend_email', $request);
427
+
428
+	$url = get_permalink($pid);
429
+	if (strstr($url, '?')) {
430
+		$url = $url . "&sendtofrnd=success";
431
+	} else {
432
+		$url = $url . "?sendtofrnd=success";
433
+	}
434
+	/**
435
+	 * Filter redirect url after the send to friend email is sent.
436
+	 *
437
+	 * @since 1.0.0
438
+	 * @param string $url Redirect url.
439
+	 */
440
+	$url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
441
+	wp_redirect($url);
442
+	gd_die();
443 443
 }
444 444
 
445 445
 /**
@@ -453,28 +453,28 @@  discard block
 block discarded – undo
453 453
  */
454 454
 function geodir_before_tab_content($hash_key)
455 455
 {
456
-    switch ($hash_key) {
457
-        case 'post_info' :
458
-            echo '<div class="geodir-company_info field-group">';
459
-            break;
460
-        case 'post_images' :
461
-            /**
462
-             * Filter post gallery HTML id.
463
-             *
464
-             * @since 1.0.0
465
-             */
466
-            echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
467
-            break;
468
-        case 'reviews' :
469
-            echo '<div id="reviews-wrap" class="clearfix"> ';
470
-            break;
471
-        case 'post_video':
472
-            echo ' <div id="post_video-wrap" class="clearfix">';
473
-            break;
474
-        case 'special_offers':
475
-            echo '<div id="special_offers-wrap" class="clearfix">';
476
-            break;
477
-    }
456
+	switch ($hash_key) {
457
+		case 'post_info' :
458
+			echo '<div class="geodir-company_info field-group">';
459
+			break;
460
+		case 'post_images' :
461
+			/**
462
+			 * Filter post gallery HTML id.
463
+			 *
464
+			 * @since 1.0.0
465
+			 */
466
+			echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
467
+			break;
468
+		case 'reviews' :
469
+			echo '<div id="reviews-wrap" class="clearfix"> ';
470
+			break;
471
+		case 'post_video':
472
+			echo ' <div id="post_video-wrap" class="clearfix">';
473
+			break;
474
+		case 'special_offers':
475
+			echo '<div id="special_offers-wrap" class="clearfix">';
476
+			break;
477
+	}
478 478
 }
479 479
 
480 480
 /**
@@ -488,23 +488,23 @@  discard block
 block discarded – undo
488 488
  */
489 489
 function geodir_after_tab_content($hash_key)
490 490
 {
491
-    switch ($hash_key) {
492
-        case 'post_info' :
493
-            echo '</div>';
494
-            break;
495
-        case 'post_images' :
496
-            echo '</div>';
497
-            break;
498
-        case 'reviews' :
499
-            echo '</div>';
500
-            break;
501
-        case 'post_video':
502
-            echo '</div>';
503
-            break;
504
-        case 'special_offers':
505
-            echo '</div>';
506
-            break;
507
-    }
491
+	switch ($hash_key) {
492
+		case 'post_info' :
493
+			echo '</div>';
494
+			break;
495
+		case 'post_images' :
496
+			echo '</div>';
497
+			break;
498
+		case 'reviews' :
499
+			echo '</div>';
500
+			break;
501
+		case 'post_video':
502
+			echo '</div>';
503
+			break;
504
+		case 'special_offers':
505
+			echo '</div>';
506
+			break;
507
+	}
508 508
 }
509 509
 
510 510
 
@@ -520,21 +520,21 @@  discard block
 block discarded – undo
520 520
 function geodir_get_posts_default_sort($post_type)
521 521
 {
522 522
 
523
-    global $wpdb;
523
+	global $wpdb;
524 524
 
525
-    if ($post_type != '') {
525
+	if ($post_type != '') {
526 526
 
527
-        $all_postypes = geodir_get_posttypes();
527
+		$all_postypes = geodir_get_posttypes();
528 528
 
529
-        if (!in_array($post_type, $all_postypes))
530
-            return false;
529
+		if (!in_array($post_type, $all_postypes))
530
+			return false;
531 531
 
532
-        $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
532
+		$sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
533 533
 
534
-        if (!empty($sort_field_info))
535
-            return $sort_field_info;
534
+		if (!empty($sort_field_info))
535
+			return $sort_field_info;
536 536
 
537
-    }
537
+	}
538 538
 
539 539
 }
540 540
 
@@ -549,24 +549,24 @@  discard block
 block discarded – undo
549 549
  * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false.
550 550
  */
551 551
 function geodir_get_sort_options($post_type) {
552
-    global $wpdb;
553
-
554
-    if ($post_type != '') {
555
-        $all_postypes = geodir_get_posttypes();
556
-
557
-        if (!in_array($post_type, $all_postypes))
558
-            return false;
559
-
560
-        $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561
-        /**
562
-         * Filter post sort options.
563
-         *
564
-         * @since 1.0.0
565
-         * @param array $sort_field_info Unfiltered sort field array.
566
-         * @param string $post_type Post type.
567
-         */
568
-        return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
569
-    }
552
+	global $wpdb;
553
+
554
+	if ($post_type != '') {
555
+		$all_postypes = geodir_get_posttypes();
556
+
557
+		if (!in_array($post_type, $all_postypes))
558
+			return false;
559
+
560
+		$sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561
+		/**
562
+		 * Filter post sort options.
563
+		 *
564
+		 * @since 1.0.0
565
+		 * @param array $sort_field_info Unfiltered sort field array.
566
+		 * @param string $post_type Post type.
567
+		 */
568
+		return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
569
+	}
570 570
 
571 571
 }
572 572
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
  */
581 581
 function geodir_display_sort_options()
582 582
 {
583
-    global $wp_query;
583
+	global $wp_query;
584 584
 	
585 585
 	/**
586 586
 	 * On search pages there should be no sort options, sorting is done by search criteria.
@@ -591,57 +591,57 @@  discard block
 block discarded – undo
591 591
 		return;
592 592
 	}
593 593
 
594
-    $sort_by = '';
594
+	$sort_by = '';
595 595
 
596
-    if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
596
+	if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
597 597
 
598
-    $gd_post_type = geodir_get_current_posttype();
598
+	$gd_post_type = geodir_get_current_posttype();
599 599
 
600
-    $sort_options = geodir_get_sort_options($gd_post_type);
600
+	$sort_options = geodir_get_sort_options($gd_post_type);
601 601
 
602 602
 
603
-    $sort_field_options = '';
603
+	$sort_field_options = '';
604 604
 
605
-    if (!empty($sort_options)) {
606
-        foreach ($sort_options as $sort) {
605
+	if (!empty($sort_options)) {
606
+		foreach ($sort_options as $sort) {
607 607
 			$sort = stripslashes_deep($sort); // strip slashes
608 608
 
609
-            $label = __($sort->site_title, 'geodirectory');
609
+			$label = __($sort->site_title, 'geodirectory');
610 610
 
611
-            if ($sort->field_type == 'random') {
612
-                $key = $sort->field_type;
613
-                ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
615
-            }
611
+			if ($sort->field_type == 'random') {
612
+				$key = $sort->field_type;
613
+				($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
615
+			}
616 616
 
617
-            if ($sort->htmlvar_name == 'comment_count') {
618
-                $sort->htmlvar_name = 'rating_count';
619
-            }
617
+			if ($sort->htmlvar_name == 'comment_count') {
618
+				$sort->htmlvar_name = 'rating_count';
619
+			}
620 620
 
621
-            if ($sort->sort_asc) {
622
-                $key = $sort->htmlvar_name . '_asc';
623
-                $label = $sort->site_title;
624
-                if ($sort->asc_title)
625
-                    $label = $sort->asc_title;
626
-                ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628
-            }
621
+			if ($sort->sort_asc) {
622
+				$key = $sort->htmlvar_name . '_asc';
623
+				$label = $sort->site_title;
624
+				if ($sort->asc_title)
625
+					$label = $sort->asc_title;
626
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628
+			}
629 629
 
630
-            if ($sort->sort_desc) {
631
-                $key = $sort->htmlvar_name . '_desc';
632
-                $label = $sort->site_title;
633
-                if ($sort->desc_title)
634
-                    $label = $sort->desc_title;
635
-                ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637
-            }
630
+			if ($sort->sort_desc) {
631
+				$key = $sort->htmlvar_name . '_desc';
632
+				$label = $sort->site_title;
633
+				if ($sort->desc_title)
634
+					$label = $sort->desc_title;
635
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637
+			}
638 638
 
639
-        }
640
-    }
639
+		}
640
+	}
641 641
 
642
-    if ($sort_field_options != '') {
642
+	if ($sort_field_options != '') {
643 643
 
644
-        ?>
644
+		?>
645 645
 
646 646
         <div class="geodir-tax-sort">
647 647
 
@@ -650,14 +650,14 @@  discard block
 block discarded – undo
650 650
                 <option
651 651
                     value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
652 652
 
653
-                echo $sort_field_options;?>
653
+				echo $sort_field_options;?>
654 654
 
655 655
             </select>
656 656
 
657 657
         </div>
658 658
     <?php
659 659
 
660
-    }
660
+	}
661 661
 
662 662
 }
663 663
 
@@ -677,10 +677,10 @@  discard block
 block discarded – undo
677 677
 function geodir_advance_customfields_heading($title, $field_type)
678 678
 {
679 679
 
680
-    if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
681
-        $title = '';
682
-    }
683
-    return $title;
680
+	if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
681
+		$title = '';
682
+	}
683
+	return $title;
684 684
 }
685 685
 
686 686
 
@@ -697,71 +697,71 @@  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, $related_nearest, $related_parent_lat, $related_parent_lon;
714
-        $related_parent_lat = $post->post_latitude;
715
-        $related_parent_lon = $post->post_longitude;
716
-        $origi_post = $post;
717
-        $post_type = '';
718
-        $post_id = '';
719
-        $category_taxonomy = '';
720
-        $tax_field = 'id';
721
-        $category = array();
722
-
723
-        if (isset($_REQUEST['backandedit'])) {
724
-            $post = (object)$gd_session->get('listing');
725
-            $post_type = $post->listing_type;
726
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
727
-                $post_id = $_REQUEST['pid'];
728
-        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
729
-            $post = geodir_get_post_info($_REQUEST['pid']);
730
-            $post_type = $post->post_type;
731
-            $post_id = $_REQUEST['pid'];
732
-        } elseif (isset($post->post_type) && $post->post_type != '') {
733
-            $post_type = $post->post_type;
734
-            $post_id = $post->ID;
735
-        }
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, $related_nearest, $related_parent_lat, $related_parent_lon;
714
+		$related_parent_lat = $post->post_latitude;
715
+		$related_parent_lon = $post->post_longitude;
716
+		$origi_post = $post;
717
+		$post_type = '';
718
+		$post_id = '';
719
+		$category_taxonomy = '';
720
+		$tax_field = 'id';
721
+		$category = array();
722
+
723
+		if (isset($_REQUEST['backandedit'])) {
724
+			$post = (object)$gd_session->get('listing');
725
+			$post_type = $post->listing_type;
726
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
727
+				$post_id = $_REQUEST['pid'];
728
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
729
+			$post = geodir_get_post_info($_REQUEST['pid']);
730
+			$post_type = $post->post_type;
731
+			$post_id = $_REQUEST['pid'];
732
+		} elseif (isset($post->post_type) && $post->post_type != '') {
733
+			$post_type = $post->post_type;
734
+			$post_id = $post->ID;
735
+		}
736 736
 
737
-        if ($relate_to == 'category') {
737
+		if ($relate_to == 'category') {
738 738
 
739
-            $category_taxonomy = $post_type . $relate_to;
740
-            if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
741
-                $category = explode(',', trim($post->{$category_taxonomy}, ','));
739
+			$category_taxonomy = $post_type . $relate_to;
740
+			if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
741
+				$category = explode(',', trim($post->{$category_taxonomy}, ','));
742 742
 
743
-        } elseif ($relate_to == 'tags') {
743
+		} elseif ($relate_to == 'tags') {
744 744
 
745
-            $category_taxonomy = $post_type . '_' . $relate_to;
746
-            if ($post->post_tags != '')
747
-                $category = explode(',', trim($post->post_tags, ','));
748
-            $tax_field = 'name';
749
-        }
745
+			$category_taxonomy = $post_type . '_' . $relate_to;
746
+			if ($post->post_tags != '')
747
+				$category = explode(',', trim($post->post_tags, ','));
748
+			$tax_field = 'name';
749
+		}
750 750
 
751
-        /* --- return false in invalid request --- */
752
-        if (empty($category))
753
-            return false;
751
+		/* --- return false in invalid request --- */
752
+		if (empty($category))
753
+			return false;
754 754
 
755
-        $all_postypes = geodir_get_posttypes();
755
+		$all_postypes = geodir_get_posttypes();
756 756
 
757
-        if (!in_array($post_type, $all_postypes))
758
-            return false;
757
+		if (!in_array($post_type, $all_postypes))
758
+			return false;
759 759
 
760
-        /* --- return false in invalid request --- */
760
+		/* --- return false in invalid request --- */
761 761
 
762
-       $location_url = '';
763
-        if ($add_location_filter != '0') {
764
-            $location_url = array();
762
+	   $location_url = '';
763
+		if ($add_location_filter != '0') {
764
+			$location_url = array();
765 765
 			$geodir_show_location_url = get_option('geodir_show_location_url');
766 766
 			
767 767
 			$gd_city = get_query_var('gd_city');
@@ -769,13 +769,13 @@  discard block
 block discarded – undo
769 769
 			if ($gd_city) {
770 770
 				$gd_country = get_query_var('gd_country');
771 771
 				$gd_region = get_query_var('gd_region');
772
-            } else {
773
-                $location = geodir_get_default_location();
772
+			} else {
773
+				$location = geodir_get_default_location();
774 774
 				
775 775
 				$gd_country = isset($location->country_slug) ? $location->country_slug : '';
776 776
 				$gd_region = isset($location->region_slug) ? $location->region_slug : '';
777 777
 				$gd_city = isset($location->city_slug) ? $location->city_slug : '';
778
-            }
778
+			}
779 779
 			
780 780
 			if ($geodir_show_location_url == 'all') {
781 781
 				$location_url[] = $gd_country;
@@ -788,100 +788,100 @@  discard block
 block discarded – undo
788 788
 			
789 789
 			$location_url[] = $gd_city;
790 790
 
791
-            $location_url = implode('/', $location_url);
792
-        }
791
+			$location_url = implode('/', $location_url);
792
+		}
793 793
 
794 794
 
795
-        if (!empty($category)) {
796
-            global $geodir_add_location_url;
797
-            $geodir_add_location_url = '0';
798
-            if ($add_location_filter != '0') {
799
-                $geodir_add_location_url = '1';
800
-            }
801
-            $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
802
-            $geodir_add_location_url = NULL;
803
-        }
804
-        ob_start();
805
-        ?>
795
+		if (!empty($category)) {
796
+			global $geodir_add_location_url;
797
+			$geodir_add_location_url = '0';
798
+			if ($add_location_filter != '0') {
799
+				$geodir_add_location_url = '1';
800
+			}
801
+			$viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
802
+			$geodir_add_location_url = NULL;
803
+		}
804
+		ob_start();
805
+		?>
806 806
 
807 807
 
808 808
         <div class="geodir_locations geodir_location_listing">
809 809
 
810 810
             <?php
811
-            if (isset($request['is_widget']) && $request['is_widget'] == '1') {
812
-                /** geodir_before_title filter Documented in geodirectory_widgets.php */
813
-                $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
814
-                /** geodir_after_title filter Documented in geodirectory_widgets.php */
815
-                $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
816
-                ?>
811
+			if (isset($request['is_widget']) && $request['is_widget'] == '1') {
812
+				/** geodir_before_title filter Documented in geodirectory_widgets.php */
813
+				$before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
814
+				/** geodir_after_title filter Documented in geodirectory_widgets.php */
815
+				$after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
816
+				?>
817 817
                 <div class="location_list_heading clearfix">
818 818
                     <?php echo $before_title . $title . $after_title; ?>
819 819
                 </div>
820 820
             <?php
821
-            }
822
-            $query_args = array(
823
-                'posts_per_page' => $post_number,
824
-                'is_geodir_loop' => true,
825
-                'gd_location' => ($add_location_filter) ? true : false,
826
-                'post_type' => $post_type,
827
-                'order_by' => $list_sort,
828
-                'post__not_in' => array($post_id),
829
-                'excerpt_length' => $character_count,
830
-                'related_listings' => true
831
-            );
821
+			}
822
+			$query_args = array(
823
+				'posts_per_page' => $post_number,
824
+				'is_geodir_loop' => true,
825
+				'gd_location' => ($add_location_filter) ? true : false,
826
+				'post_type' => $post_type,
827
+				'order_by' => $list_sort,
828
+				'post__not_in' => array($post_id),
829
+				'excerpt_length' => $character_count,
830
+				'related_listings' => true
831
+			);
832 832
 
833
-            $tax_query = array('taxonomy' => $category_taxonomy,
834
-                'field' => $tax_field,
835
-                'terms' => $category
836
-            );
833
+			$tax_query = array('taxonomy' => $category_taxonomy,
834
+				'field' => $tax_field,
835
+				'terms' => $category
836
+			);
837 837
 
838
-            $query_args['tax_query'] = array($tax_query);
838
+			$query_args['tax_query'] = array($tax_query);
839 839
 
840 840
 
841
-            global $gridview_columns, $post;
841
+			global $gridview_columns, $post;
842 842
 
843 843
 
844
-            query_posts($query_args);
844
+			query_posts($query_args);
845 845
 
846
-            if (strstr($layout, 'gridview')) {
847
-                $listing_view_exp = explode('_', $layout);
848
-                $gridview_columns = $layout;
849
-                $layout = $listing_view_exp[0];
850
-            } else if ($layout == 'list') {
851
-                $gridview_columns = '';
852
-            }
853
-            $related_posts = true;
846
+			if (strstr($layout, 'gridview')) {
847
+				$listing_view_exp = explode('_', $layout);
848
+				$gridview_columns = $layout;
849
+				$layout = $listing_view_exp[0];
850
+			} else if ($layout == 'list') {
851
+				$gridview_columns = '';
852
+			}
853
+			$related_posts = true;
854 854
 
855
-            $related_nearest = false;
856
-            if ($list_sort == 'nearest') {
857
-                $related_nearest = true;
858
-            }
855
+			$related_nearest = false;
856
+			if ($list_sort == 'nearest') {
857
+				$related_nearest = true;
858
+			}
859 859
 
860 860
 
861
-            /**
862
-             * Filters related listing listview template.
863
-             *
864
-             * @since 1.0.0
865
-             */
866
-            $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
861
+			/**
862
+			 * Filters related listing listview template.
863
+			 *
864
+			 * @since 1.0.0
865
+			 */
866
+			$template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
867 867
 
868
-            /**
869
-             * Includes related listing listview template.
870
-             *
871
-             * @since 1.0.0
872
-             */
873
-            include($template);
868
+			/**
869
+			 * Includes related listing listview template.
870
+			 *
871
+			 * @since 1.0.0
872
+			 */
873
+			include($template);
874 874
 
875
-            wp_reset_query();
876
-            $post = $origi_post;
877
-            $related_nearest = false;
878
-            ?>
875
+			wp_reset_query();
876
+			$post = $origi_post;
877
+			$related_nearest = false;
878
+			?>
879 879
 
880 880
         </div>
881 881
         <?php
882
-        return $html = ob_get_clean();
882
+		return $html = ob_get_clean();
883 883
 
884
-    }
884
+	}
885 885
 
886 886
 }
887 887
 
@@ -897,17 +897,17 @@  discard block
 block discarded – undo
897 897
  */
898 898
 function geodir_category_count_script()
899 899
 {
900
-    global $geodir_post_category_str;
900
+	global $geodir_post_category_str;
901 901
 
902
-    if (!empty($geodir_post_category_str)) {
903
-        $geodir_post_category_str = serialize($geodir_post_category_str);
904
-    }
902
+	if (!empty($geodir_post_category_str)) {
903
+		$geodir_post_category_str = serialize($geodir_post_category_str);
904
+	}
905 905
 
906
-    $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
907
-    $script = "var post_category_array = " . json_encode($all_var) . ';';
908
-    echo '<script>';
909
-    echo $script;
910
-    echo '</script>';
906
+	$all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
907
+	$script = "var post_category_array = " . json_encode($all_var) . ';';
908
+	echo '<script>';
909
+	echo $script;
910
+	echo '</script>';
911 911
 
912 912
 }
913 913
 
@@ -920,16 +920,16 @@  discard block
 block discarded – undo
920 920
  */
921 921
 function geodir_get_map_default_language()
922 922
 {
923
-    $geodir_default_map_language = get_option('geodir_default_map_language');
924
-    if (empty($geodir_default_map_language))
925
-        $geodir_default_map_language = 'en';
926
-    /**
927
-     * Filter default map language.
928
-     *
929
-     * @since 1.0.0
930
-     * @param string $geodir_default_map_language Default map language.
931
-     */
932
-    return apply_filters('geodir_default_map_language', $geodir_default_map_language);
923
+	$geodir_default_map_language = get_option('geodir_default_map_language');
924
+	if (empty($geodir_default_map_language))
925
+		$geodir_default_map_language = 'en';
926
+	/**
927
+	 * Filter default map language.
928
+	 *
929
+	 * @since 1.0.0
930
+	 * @param string $geodir_default_map_language Default map language.
931
+	 */
932
+	return apply_filters('geodir_default_map_language', $geodir_default_map_language);
933 933
 }
934 934
 
935 935
 /**
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
  */
942 942
 function geodir_get_map_api_key()
943 943
 {
944
-    $key = get_option('geodir_google_api_key');
945
-    /**
946
-     * Filter Google maps api key.
947
-     *
948
-     * @since 1.6.4
949
-     * @param string $key Google maps api key.
950
-     */
951
-    return apply_filters('geodir_google_api_key', $key);
944
+	$key = get_option('geodir_google_api_key');
945
+	/**
946
+	 * Filter Google maps api key.
947
+	 *
948
+	 * @since 1.6.4
949
+	 * @param string $key Google maps api key.
950
+	 */
951
+	return apply_filters('geodir_google_api_key', $key);
952 952
 }
953 953
 
954 954
 
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
  */
966 966
 function geodir_add_meta_keywords()
967 967
 {
968
-    global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
968
+	global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
969 969
 
970
-    $is_geodir_page = geodir_is_geodir_page();
971
-    if (!$is_geodir_page) {
972
-        return;
973
-    }// if non GD page, bail
970
+	$is_geodir_page = geodir_is_geodir_page();
971
+	if (!$is_geodir_page) {
972
+		return;
973
+	}// if non GD page, bail
974 974
 
975 975
 	$use_gd_meta = true;
976 976
 	if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
@@ -985,182 +985,182 @@  discard block
 block discarded – undo
985 985
 		return;
986 986
 	}// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active.
987 987
 
988
-    $current_term = $wp_query->get_queried_object();
988
+	$current_term = $wp_query->get_queried_object();
989 989
 
990
-    $all_postypes = geodir_get_posttypes();
990
+	$all_postypes = geodir_get_posttypes();
991 991
 
992
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
992
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
993 993
 
994
-    $meta_desc = '';
995
-    $meta_key = '';
996
-    if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
997
-        /**
998
-         * Filter SEO meta location description.
999
-         *
1000
-         * @since 1.0.0
1001
-         */
1002
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
1003
-        $meta_desc .= '';
1004
-    }
1005
-    if (have_posts() && is_single() OR is_page()) {
1006
-        while (have_posts()) {
1007
-            the_post();
1008
-
1009
-            if (has_excerpt()) {
1010
-                $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
1011
-                if (empty($out_excerpt)) {
1012
-                    $out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
1013
-                }
1014
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
1015
-            } else {
1016
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
1017
-                $out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
1018
-                if (empty($out_excerpt)) {
1019
-                    $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
1020
-                }
1021
-                $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
1022
-            }
994
+	$meta_desc = '';
995
+	$meta_key = '';
996
+	if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
997
+		/**
998
+		 * Filter SEO meta location description.
999
+		 *
1000
+		 * @since 1.0.0
1001
+		 */
1002
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', '');
1003
+		$meta_desc .= '';
1004
+	}
1005
+	if (have_posts() && is_single() OR is_page()) {
1006
+		while (have_posts()) {
1007
+			the_post();
1008
+
1009
+			if (has_excerpt()) {
1010
+				$out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
1011
+				if (empty($out_excerpt)) {
1012
+					$out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
1013
+				}
1014
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
1015
+			} else {
1016
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
1017
+				$out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
1018
+				if (empty($out_excerpt)) {
1019
+					$out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
1020
+				}
1021
+				$out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
1022
+			}
1023 1023
 
1024
-            $meta_desc .= $out_excerpt;
1025
-        }
1026
-    } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1027
-        if (is_category()) {
1028
-            $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1029
-        } elseif (is_tag()) {
1030
-            $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1031
-        }
1032
-    } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1033
-        $meta_desc .= isset($current_term->description) ? $current_term->description : '';
1034
-    }
1024
+			$meta_desc .= $out_excerpt;
1025
+		}
1026
+	} elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1027
+		if (is_category()) {
1028
+			$meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1029
+		} elseif (is_tag()) {
1030
+			$meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1031
+		}
1032
+	} elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1033
+		$meta_desc .= isset($current_term->description) ? $current_term->description : '';
1034
+	}
1035 1035
 
1036 1036
 
1037
-    $geodir_post_type = geodir_get_current_posttype();
1038
-    $geodir_post_type_info = get_post_type_object($geodir_post_type);
1039
-    $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1040
-
1041
-    $category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1042
-    $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1043
-
1044
-    $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1045
-    $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1046
-
1047
-    $geodir_is_search = geodir_is_page('search') ? true : false;
1048
-    $geodir_is_location = geodir_is_page('location') ? true : false;
1049
-    $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1050
-    $godir_location_terms = geodir_get_current_location_terms('query_vars');
1051
-    $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1052
-    $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1053
-    $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1054
-    $replace_location = __('Everywhere', 'geodirectory');
1055
-    $location_id = NULL;
1056
-    if ($geodir_location_manager) {
1057
-        $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1058
-        $location_id = (int)$wpdb->get_var($sql);
1059
-        $location_type = geodir_what_is_current_location();
1060
-        if ($location_type == 'city') {
1061
-            $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1062
-        } elseif ($location_type == 'region') {
1063
-            $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1064
-        } elseif ($location_type == 'country') {
1065
-            $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1066
-            $replace_location = __($replace_location, 'geodirectory');
1067
-        }
1068
-        $country = get_query_var('gd_country');
1069
-        $region = get_query_var('gd_region');
1070
-        $city = get_query_var('gd_city');
1071
-        $current_location = '';
1072
-        if ($country != '') {
1073
-            $current_location = get_actual_location_name('country', $country, true);
1074
-        }
1075
-        if ($region != '') {
1076
-            $current_location = get_actual_location_name('region', $region);
1077
-        }
1078
-        if ($city != '') {
1079
-            $current_location = get_actual_location_name('city', $city);
1080
-        }
1081
-        $replace_location = $current_location != '' ? $current_location : $replace_location;
1082
-    }
1037
+	$geodir_post_type = geodir_get_current_posttype();
1038
+	$geodir_post_type_info = get_post_type_object($geodir_post_type);
1039
+	$geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1040
+
1041
+	$category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1042
+	$tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1043
+
1044
+	$geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1045
+	$geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1046
+
1047
+	$geodir_is_search = geodir_is_page('search') ? true : false;
1048
+	$geodir_is_location = geodir_is_page('location') ? true : false;
1049
+	$geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1050
+	$godir_location_terms = geodir_get_current_location_terms('query_vars');
1051
+	$gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1052
+	$gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1053
+	$gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1054
+	$replace_location = __('Everywhere', 'geodirectory');
1055
+	$location_id = NULL;
1056
+	if ($geodir_location_manager) {
1057
+		$sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1058
+		$location_id = (int)$wpdb->get_var($sql);
1059
+		$location_type = geodir_what_is_current_location();
1060
+		if ($location_type == 'city') {
1061
+			$replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1062
+		} elseif ($location_type == 'region') {
1063
+			$replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1064
+		} elseif ($location_type == 'country') {
1065
+			$replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1066
+			$replace_location = __($replace_location, 'geodirectory');
1067
+		}
1068
+		$country = get_query_var('gd_country');
1069
+		$region = get_query_var('gd_region');
1070
+		$city = get_query_var('gd_city');
1071
+		$current_location = '';
1072
+		if ($country != '') {
1073
+			$current_location = get_actual_location_name('country', $country, true);
1074
+		}
1075
+		if ($region != '') {
1076
+			$current_location = get_actual_location_name('region', $region);
1077
+		}
1078
+		if ($city != '') {
1079
+			$current_location = get_actual_location_name('city', $city);
1080
+		}
1081
+		$replace_location = $current_location != '' ? $current_location : $replace_location;
1082
+	}
1083 1083
 
1084
-    $geodir_meta_keys = '';
1085
-    $geodir_meta_desc = '';
1086
-    if ($is_geodir_page && !empty($geodir_post_type_info)) {
1087
-        if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1088
-            $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;
1089
-
1090
-            $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1091
-            $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;
1092
-
1093
-            if ($geodir_is_category) {
1094
-                $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1095
-                if (isset($category->term_id) && !empty($category->term_id)) {
1096
-                    $category_id = $category->term_id;
1097
-                    $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1098
-                    if ($location_id) {
1099
-                        $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1100
-                        $cat_loc_option = get_option($option_name);
1101
-
1102
-                        $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;
1103
-                        if (!$gd_cat_loc_default) {
1104
-                            $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1105
-                            $option = get_option($option_name);
1106
-                            $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1107
-                        }
1108
-                    }
1109
-                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1110
-                }
1111
-            } else if ($geodir_is_tag) {
1112
-                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1113
-            }
1114
-        }
1115
-    }
1084
+	$geodir_meta_keys = '';
1085
+	$geodir_meta_desc = '';
1086
+	if ($is_geodir_page && !empty($geodir_post_type_info)) {
1087
+		if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1088
+			$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;
1089
+
1090
+			$geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1091
+			$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;
1092
+
1093
+			if ($geodir_is_category) {
1094
+				$category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1095
+				if (isset($category->term_id) && !empty($category->term_id)) {
1096
+					$category_id = $category->term_id;
1097
+					$category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1098
+					if ($location_id) {
1099
+						$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1100
+						$cat_loc_option = get_option($option_name);
1101
+
1102
+						$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;
1103
+						if (!$gd_cat_loc_default) {
1104
+							$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1105
+							$option = get_option($option_name);
1106
+							$category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1107
+						}
1108
+					}
1109
+					$geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1110
+				}
1111
+			} else if ($geodir_is_tag) {
1112
+				$geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1113
+			}
1114
+		}
1115
+	}
1116 1116
 
1117 1117
 
1118
-    $gd_page = '';
1119
-    if(geodir_is_page('home')){
1120
-        $gd_page = 'home';
1121
-        $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1122
-    }
1123
-    elseif(geodir_is_page('detail')){
1124
-        $gd_page = 'detail';
1125
-        $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1126
-    }
1127
-    elseif(geodir_is_page('pt')){
1128
-        $gd_page = 'pt';
1129
-        $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1130
-    }
1131
-    elseif(geodir_is_page('listing')){
1132
-        $gd_page = 'listing';
1133
-        $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1134
-    }
1135
-    elseif(geodir_is_page('location')){
1136
-        $gd_page = 'location';
1137
-        $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1138
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1118
+	$gd_page = '';
1119
+	if(geodir_is_page('home')){
1120
+		$gd_page = 'home';
1121
+		$meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1122
+	}
1123
+	elseif(geodir_is_page('detail')){
1124
+		$gd_page = 'detail';
1125
+		$meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1126
+	}
1127
+	elseif(geodir_is_page('pt')){
1128
+		$gd_page = 'pt';
1129
+		$meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1130
+	}
1131
+	elseif(geodir_is_page('listing')){
1132
+		$gd_page = 'listing';
1133
+		$meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1134
+	}
1135
+	elseif(geodir_is_page('location')){
1136
+		$gd_page = 'location';
1137
+		$meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1138
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1139 1139
 
1140
-    }
1141
-    elseif(geodir_is_page('search')){
1142
-        $gd_page = 'search';
1143
-        $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1144
-    }
1145
-    elseif(geodir_is_page('add-listing')){
1146
-        $gd_page = 'add-listing';
1147
-        $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1148
-    }
1149
-    elseif(geodir_is_page('author')){
1150
-        $gd_page = 'author';
1151
-        $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1152
-    }
1153
-    elseif(geodir_is_page('login')){
1154
-        $gd_page = 'login';
1155
-        $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1156
-    }
1157
-    elseif(geodir_is_page('listing-success')){
1158
-        $gd_page = 'listing-success';
1159
-        $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1160
-    }
1140
+	}
1141
+	elseif(geodir_is_page('search')){
1142
+		$gd_page = 'search';
1143
+		$meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1144
+	}
1145
+	elseif(geodir_is_page('add-listing')){
1146
+		$gd_page = 'add-listing';
1147
+		$meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1148
+	}
1149
+	elseif(geodir_is_page('author')){
1150
+		$gd_page = 'author';
1151
+		$meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1152
+	}
1153
+	elseif(geodir_is_page('login')){
1154
+		$gd_page = 'login';
1155
+		$meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1156
+	}
1157
+	elseif(geodir_is_page('listing-success')){
1158
+		$gd_page = 'listing-success';
1159
+		$meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1160
+	}
1161 1161
 
1162 1162
 
1163
-    /*
1163
+	/*
1164 1164
     $geodir_meta_desc = $geodir_meta_desc != '' ? $geodir_meta_desc : $meta_desc;
1165 1165
     if ($geodir_meta_desc != '') {
1166 1166
         $geodir_meta_desc = strip_tags($geodir_meta_desc);
@@ -1173,74 +1173,74 @@  discard block
 block discarded – undo
1173 1173
     */
1174 1174
 
1175 1175
 
1176
-    if ($meta_desc) {
1177
-        $meta_desc = stripslashes_deep($meta_desc);
1178
-        /**
1179
-         * Filter page description to replace variables.
1180
-         *
1181
-         * @since 1.5.4
1182
-         * @param string $title The page description including variables.
1183
-         * @param string $gd_page The GeoDirectory page type if any.
1184
-         */
1185
-        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1186
-
1187
-        /**
1188
-         * Filter SEO meta description.
1189
-         *
1190
-         * @since 1.0.0
1191
-         * @param string $meta_desc Meta description content.
1192
-         */
1193
-        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1194
-    }
1176
+	if ($meta_desc) {
1177
+		$meta_desc = stripslashes_deep($meta_desc);
1178
+		/**
1179
+		 * Filter page description to replace variables.
1180
+		 *
1181
+		 * @since 1.5.4
1182
+		 * @param string $title The page description including variables.
1183
+		 * @param string $gd_page The GeoDirectory page type if any.
1184
+		 */
1185
+		$meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1186
+
1187
+		/**
1188
+		 * Filter SEO meta description.
1189
+		 *
1190
+		 * @since 1.0.0
1191
+		 * @param string $meta_desc Meta description content.
1192
+		 */
1193
+		echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1194
+	}
1195 1195
 
1196
-    // meta keywords
1197
-    if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1198
-        $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1199
-        $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1200
-
1201
-        $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1202
-    } else {
1203
-        $posttags = get_the_tags();
1204
-        if ($posttags) {
1205
-            foreach ($posttags as $tag) {
1206
-                $meta_key .= $tag->name . ' ';
1207
-            }
1208
-        } else {
1209
-            $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1210
-            $xt = 1;
1196
+	// meta keywords
1197
+	if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1198
+		$place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1199
+		$place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1200
+
1201
+		$meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1202
+	} else {
1203
+		$posttags = get_the_tags();
1204
+		if ($posttags) {
1205
+			foreach ($posttags as $tag) {
1206
+				$meta_key .= $tag->name . ' ';
1207
+			}
1208
+		} else {
1209
+			$tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1210
+			$xt = 1;
1211 1211
 
1212
-            foreach ($tags as $tag) {
1213
-                if ($xt <= 20) {
1214
-                    $meta_key .= $tag->name . ", ";
1215
-                }
1212
+			foreach ($tags as $tag) {
1213
+				if ($xt <= 20) {
1214
+					$meta_key .= $tag->name . ", ";
1215
+				}
1216 1216
 
1217
-                $xt++;
1218
-            }
1219
-        }
1220
-    }
1217
+				$xt++;
1218
+			}
1219
+		}
1220
+	}
1221 1221
 
1222
-    $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1223
-    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1224
-    if ($geodir_meta_keys != '') {
1225
-        $geodir_meta_keys = strip_tags($geodir_meta_keys);
1226
-        $geodir_meta_keys = esc_html($geodir_meta_keys);
1227
-        $geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1228
-        $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1229
-        $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1222
+	$meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1223
+	$geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1224
+	if ($geodir_meta_keys != '') {
1225
+		$geodir_meta_keys = strip_tags($geodir_meta_keys);
1226
+		$geodir_meta_keys = esc_html($geodir_meta_keys);
1227
+		$geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1228
+		$geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1229
+		$geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1230 1230
 
1231
-        $meta_key = rtrim(trim($geodir_meta_keys), ",");
1232
-    }
1231
+		$meta_key = rtrim(trim($geodir_meta_keys), ",");
1232
+	}
1233 1233
 
1234
-    if ($meta_key) {
1235
-        $meta_key = stripslashes_deep($meta_key);
1236
-        /**
1237
-         * Filter SEO meta keywords.
1238
-         *
1239
-         * @since 1.0.0
1240
-         * @param string $meta_desc Meta keywords.
1241
-         */
1242
-        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1243
-    }
1234
+	if ($meta_key) {
1235
+		$meta_key = stripslashes_deep($meta_key);
1236
+		/**
1237
+		 * Filter SEO meta keywords.
1238
+		 *
1239
+		 * @since 1.0.0
1240
+		 * @param string $meta_desc Meta keywords.
1241
+		 */
1242
+		echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1243
+	}
1244 1244
 
1245 1245
 }
1246 1246
 
@@ -1255,14 +1255,14 @@  discard block
 block discarded – undo
1255 1255
  */
1256 1256
 function geodir_detail_page_tabs_key_value_array()
1257 1257
 {
1258
-    $geodir_detail_page_tabs_key_value_array = array();
1258
+	$geodir_detail_page_tabs_key_value_array = array();
1259 1259
 
1260
-    $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1260
+	$geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1261 1261
 
1262
-    foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1263
-        $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1264
-    }
1265
-    return $geodir_detail_page_tabs_key_value_array;
1262
+	foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1263
+		$geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1264
+	}
1265
+	return $geodir_detail_page_tabs_key_value_array;
1266 1266
 }
1267 1267
 
1268 1268
 /**
@@ -1275,73 +1275,73 @@  discard block
 block discarded – undo
1275 1275
 function geodir_detail_page_tabs_array()
1276 1276
 {
1277 1277
 
1278
-    $arr_tabs = array();
1279
-    /**
1280
-     * Filter detail page tab display.
1281
-     *
1282
-     * @since 1.0.0
1283
-     */
1284
-    $arr_tabs['post_profile'] = array(
1285
-        'heading_text' => __('Profile', 'geodirectory'),
1286
-        'is_active_tab' => true,
1287
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1288
-        'tab_content' => ''
1289
-    );
1290
-    $arr_tabs['post_info'] = array(
1291
-        'heading_text' => __('More Info', 'geodirectory'),
1292
-        'is_active_tab' => false,
1293
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1294
-        'tab_content' => ''
1295
-    );
1296
-
1297
-    $arr_tabs['post_images'] = array(
1298
-        'heading_text' => __('Photo', 'geodirectory'),
1299
-        'is_active_tab' => false,
1300
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1301
-        'tab_content' => ''
1302
-    );
1303
-
1304
-    $arr_tabs['post_video'] = array(
1305
-        'heading_text' => __('Video', 'geodirectory'),
1306
-        'is_active_tab' => false,
1307
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1308
-        'tab_content' => ''
1309
-    );
1310
-
1311
-    $arr_tabs['special_offers'] = array(
1312
-        'heading_text' => __('Special Offers', 'geodirectory'),
1313
-        'is_active_tab' => false,
1314
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1315
-        'tab_content' => ''
1316
-    );
1317
-
1318
-    $arr_tabs['post_map'] = array(
1319
-        'heading_text' => __('Map', 'geodirectory'),
1320
-        'is_active_tab' => false,
1321
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1322
-        'tab_content' => ''
1323
-    );
1324
-
1325
-    $arr_tabs['reviews'] = array(
1326
-        'heading_text' => __('Reviews', 'geodirectory'),
1327
-        'is_active_tab' => false,
1328
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1329
-        'tab_content' => 'review display'
1330
-    );
1331
-
1332
-    $arr_tabs['related_listing'] = array(
1333
-        'heading_text' => __('Related Listing', 'geodirectory'),
1334
-        'is_active_tab' => false,
1335
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1336
-        'tab_content' => ''
1337
-    );
1338
-
1339
-    /**
1340
-     * Filter the tabs array.
1341
-     *
1342
-     * @since 1.0.0
1343
-     */
1344
-    return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1278
+	$arr_tabs = array();
1279
+	/**
1280
+	 * Filter detail page tab display.
1281
+	 *
1282
+	 * @since 1.0.0
1283
+	 */
1284
+	$arr_tabs['post_profile'] = array(
1285
+		'heading_text' => __('Profile', 'geodirectory'),
1286
+		'is_active_tab' => true,
1287
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1288
+		'tab_content' => ''
1289
+	);
1290
+	$arr_tabs['post_info'] = array(
1291
+		'heading_text' => __('More Info', 'geodirectory'),
1292
+		'is_active_tab' => false,
1293
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1294
+		'tab_content' => ''
1295
+	);
1296
+
1297
+	$arr_tabs['post_images'] = array(
1298
+		'heading_text' => __('Photo', 'geodirectory'),
1299
+		'is_active_tab' => false,
1300
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1301
+		'tab_content' => ''
1302
+	);
1303
+
1304
+	$arr_tabs['post_video'] = array(
1305
+		'heading_text' => __('Video', 'geodirectory'),
1306
+		'is_active_tab' => false,
1307
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1308
+		'tab_content' => ''
1309
+	);
1310
+
1311
+	$arr_tabs['special_offers'] = array(
1312
+		'heading_text' => __('Special Offers', 'geodirectory'),
1313
+		'is_active_tab' => false,
1314
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1315
+		'tab_content' => ''
1316
+	);
1317
+
1318
+	$arr_tabs['post_map'] = array(
1319
+		'heading_text' => __('Map', 'geodirectory'),
1320
+		'is_active_tab' => false,
1321
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1322
+		'tab_content' => ''
1323
+	);
1324
+
1325
+	$arr_tabs['reviews'] = array(
1326
+		'heading_text' => __('Reviews', 'geodirectory'),
1327
+		'is_active_tab' => false,
1328
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1329
+		'tab_content' => 'review display'
1330
+	);
1331
+
1332
+	$arr_tabs['related_listing'] = array(
1333
+		'heading_text' => __('Related Listing', 'geodirectory'),
1334
+		'is_active_tab' => false,
1335
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1336
+		'tab_content' => ''
1337
+	);
1338
+
1339
+	/**
1340
+	 * Filter the tabs array.
1341
+	 *
1342
+	 * @since 1.0.0
1343
+	 */
1344
+	return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1345 1345
 
1346 1346
 
1347 1347
 }
@@ -1356,15 +1356,15 @@  discard block
 block discarded – undo
1356 1356
  */
1357 1357
 function geodir_detail_page_tabs_list()
1358 1358
 {
1359
-    $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1360
-    $tabs_array = geodir_detail_page_tabs_array();
1361
-    if (!empty($tabs_excluded)) {
1362
-        foreach ($tabs_excluded as $tab) {
1363
-            if (array_key_exists($tab, $tabs_array))
1364
-                unset($tabs_array[$tab]);
1365
-        }
1366
-    }
1367
-    return $tabs_array;
1359
+	$tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1360
+	$tabs_array = geodir_detail_page_tabs_array();
1361
+	if (!empty($tabs_excluded)) {
1362
+		foreach ($tabs_excluded as $tab) {
1363
+			if (array_key_exists($tab, $tabs_array))
1364
+				unset($tabs_array[$tab]);
1365
+		}
1366
+	}
1367
+	return $tabs_array;
1368 1368
 }
1369 1369
 
1370 1370
 
@@ -1382,156 +1382,156 @@  discard block
 block discarded – undo
1382 1382
  */
1383 1383
 function geodir_show_detail_page_tabs()
1384 1384
 {
1385
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1385
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1386 1386
 
1387
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1388
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1389
-    $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
1387
+	$post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1388
+	$request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1389
+	$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
1390 1390
 
1391
-    if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1392
-        $post = geodir_get_post_info($request_post_id);
1393
-        setup_postdata($post);
1394
-    }
1391
+	if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1392
+		$post = geodir_get_post_info($request_post_id);
1393
+		setup_postdata($post);
1394
+	}
1395 1395
 
1396
-    $geodir_post_detail_fields = geodir_show_listing_info('detail');
1397
-
1398
-    $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1399
-
1400
-    if (geodir_is_page('detail')) {
1401
-        $video = geodir_get_video($post->ID);
1402
-        $special_offers = geodir_get_special_offers($post->ID);
1403
-        $related_listing_array = array();
1404
-        if (get_option('geodir_add_related_listing_posttypes'))
1405
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1406
-
1407
-        $related_listing = '';
1408
-        if (in_array($post->post_type, $related_listing_array) && $arr_detail_page_tabs['related_listing']['is_display']) {
1409
-            $request = array('post_number' => get_option('geodir_related_post_count'),
1410
-                'relate_to' => get_option('geodir_related_post_relate_to'),
1411
-                'layout' => get_option('geodir_related_post_listing_view'),
1412
-                'add_location_filter' => get_option('geodir_related_post_location_filter'),
1413
-                'list_sort' => get_option('geodir_related_post_sortby'),
1414
-                'character_count' => get_option('geodir_related_post_excerpt'));
1415
-
1416
-            if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
1417
-                $related_listing = geodir_get_detail_page_related_events($request);
1418
-            } else {
1419
-                $related_listing = geodir_related_posts_display($request);
1420
-            }
1396
+	$geodir_post_detail_fields = geodir_show_listing_info('detail');
1397
+
1398
+	$arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1399
+
1400
+	if (geodir_is_page('detail')) {
1401
+		$video = geodir_get_video($post->ID);
1402
+		$special_offers = geodir_get_special_offers($post->ID);
1403
+		$related_listing_array = array();
1404
+		if (get_option('geodir_add_related_listing_posttypes'))
1405
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
1406
+
1407
+		$related_listing = '';
1408
+		if (in_array($post->post_type, $related_listing_array) && $arr_detail_page_tabs['related_listing']['is_display']) {
1409
+			$request = array('post_number' => get_option('geodir_related_post_count'),
1410
+				'relate_to' => get_option('geodir_related_post_relate_to'),
1411
+				'layout' => get_option('geodir_related_post_listing_view'),
1412
+				'add_location_filter' => get_option('geodir_related_post_location_filter'),
1413
+				'list_sort' => get_option('geodir_related_post_sortby'),
1414
+				'character_count' => get_option('geodir_related_post_excerpt'));
1415
+
1416
+			if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
1417
+				$related_listing = geodir_get_detail_page_related_events($request);
1418
+			} else {
1419
+				$related_listing = geodir_related_posts_display($request);
1420
+			}
1421 1421
 
1422
-        }
1422
+		}
1423 1423
 
1424
-        $post_images = geodir_get_images($post->ID, 'thumbnail');
1425
-        $thumb_image = '';
1426
-        if (!empty($post_images)) {
1427
-            foreach ($post_images as $image) {
1428
-                $caption = (!empty($image->caption)) ? $image->caption : '';
1429
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1430
-                $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1431
-                $thumb_image .= '</a>';
1432
-            }
1433
-        }
1424
+		$post_images = geodir_get_images($post->ID, 'thumbnail');
1425
+		$thumb_image = '';
1426
+		if (!empty($post_images)) {
1427
+			foreach ($post_images as $image) {
1428
+				$caption = (!empty($image->caption)) ? $image->caption : '';
1429
+				$thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1430
+				$thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1431
+				$thumb_image .= '</a>';
1432
+			}
1433
+		}
1434 1434
 
1435
-        $map_args = array();
1436
-        $map_args['map_canvas_name'] = 'detail_page_map_canvas';
1437
-        $map_args['width'] = '600';
1438
-        $map_args['height'] = '300';
1439
-        if ($post->post_mapzoom) {
1440
-            $map_args['zoom'] = '' . $post->post_mapzoom . '';
1441
-        }
1442
-        $map_args['autozoom'] = false;
1443
-        $map_args['child_collapse'] = '0';
1444
-        $map_args['enable_cat_filters'] = false;
1445
-        $map_args['enable_text_search'] = false;
1446
-        $map_args['enable_post_type_filters'] = false;
1447
-        $map_args['enable_location_filters'] = false;
1448
-        $map_args['enable_jason_on_load'] = true;
1449
-        $map_args['enable_map_direction'] = true;
1450
-        $map_args['map_class_name'] = 'geodir-map-detail-page';
1451
-        $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1452
-    } else if (geodir_is_page('preview')) {
1453
-        $video = isset($post->geodir_video) ? $post->geodir_video : '';
1454
-        $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1455
-
1456
-        if (isset($post->post_images))
1457
-            $post->post_images = trim($post->post_images, ",");
1458
-
1459
-        if (isset($post->post_images) && !empty($post->post_images))
1460
-            $post_images = explode(",", $post->post_images);
1461
-
1462
-        $thumb_image = '';
1463
-        if (!empty($post_images)) {
1464
-            foreach ($post_images as $image) {
1465
-                if ($image != '') {
1466
-                    $thumb_image .= '<a href="' . $image . '">';
1467
-                    $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1468
-                    $thumb_image .= '</a>';
1469
-                }
1470
-            }
1471
-        }
1435
+		$map_args = array();
1436
+		$map_args['map_canvas_name'] = 'detail_page_map_canvas';
1437
+		$map_args['width'] = '600';
1438
+		$map_args['height'] = '300';
1439
+		if ($post->post_mapzoom) {
1440
+			$map_args['zoom'] = '' . $post->post_mapzoom . '';
1441
+		}
1442
+		$map_args['autozoom'] = false;
1443
+		$map_args['child_collapse'] = '0';
1444
+		$map_args['enable_cat_filters'] = false;
1445
+		$map_args['enable_text_search'] = false;
1446
+		$map_args['enable_post_type_filters'] = false;
1447
+		$map_args['enable_location_filters'] = false;
1448
+		$map_args['enable_jason_on_load'] = true;
1449
+		$map_args['enable_map_direction'] = true;
1450
+		$map_args['map_class_name'] = 'geodir-map-detail-page';
1451
+		$map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1452
+	} else if (geodir_is_page('preview')) {
1453
+		$video = isset($post->geodir_video) ? $post->geodir_video : '';
1454
+		$special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1455
+
1456
+		if (isset($post->post_images))
1457
+			$post->post_images = trim($post->post_images, ",");
1458
+
1459
+		if (isset($post->post_images) && !empty($post->post_images))
1460
+			$post_images = explode(",", $post->post_images);
1461
+
1462
+		$thumb_image = '';
1463
+		if (!empty($post_images)) {
1464
+			foreach ($post_images as $image) {
1465
+				if ($image != '') {
1466
+					$thumb_image .= '<a href="' . $image . '">';
1467
+					$thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1468
+					$thumb_image .= '</a>';
1469
+				}
1470
+			}
1471
+		}
1472 1472
 
1473
-        global $map_jason;
1474
-        $marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1475
-        $marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : '';
1476
-        $icon_size = geodir_get_marker_size($marker_icon);
1477
-        $marker_json['w'] = $icon_size['w'];
1478
-        $marker_json['h'] = $icon_size['h'];
1479
-        $map_jason[] = json_encode($marker_json);
1480
-
1481
-        $address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1482
-        $address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1483
-        $mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1484
-        $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1485
-        if (!$mapzoom) {
1486
-            $mapzoom = 12;
1487
-        }
1473
+		global $map_jason;
1474
+		$marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1475
+		$marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : '';
1476
+		$icon_size = geodir_get_marker_size($marker_icon);
1477
+		$marker_json['w'] = $icon_size['w'];
1478
+		$marker_json['h'] = $icon_size['h'];
1479
+		$map_jason[] = json_encode($marker_json);
1480
+
1481
+		$address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1482
+		$address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1483
+		$mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1484
+		$mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1485
+		if (!$mapzoom) {
1486
+			$mapzoom = 12;
1487
+		}
1488 1488
 
1489
-        $map_args = array();
1490
-        $map_args['map_canvas_name'] = 'preview_map_canvas';
1491
-        $map_args['width'] = '950';
1492
-        $map_args['height'] = '300';
1493
-        $map_args['child_collapse'] = '0';
1494
-        $map_args['maptype'] = $mapview;
1495
-        $map_args['autozoom'] = false;
1496
-        $map_args['zoom'] = "$mapzoom";
1497
-        $map_args['latitude'] = $address_latitude;
1498
-        $map_args['longitude'] = $address_longitude;
1499
-        $map_args['enable_cat_filters'] = false;
1500
-        $map_args['enable_text_search'] = false;
1501
-        $map_args['enable_post_type_filters'] = false;
1502
-        $map_args['enable_location_filters'] = false;
1503
-        $map_args['enable_jason_on_load'] = true;
1504
-        $map_args['enable_map_direction'] = true;
1505
-        $map_args['map_class_name'] = 'geodir-map-preview-page';
1506
-    }
1489
+		$map_args = array();
1490
+		$map_args['map_canvas_name'] = 'preview_map_canvas';
1491
+		$map_args['width'] = '950';
1492
+		$map_args['height'] = '300';
1493
+		$map_args['child_collapse'] = '0';
1494
+		$map_args['maptype'] = $mapview;
1495
+		$map_args['autozoom'] = false;
1496
+		$map_args['zoom'] = "$mapzoom";
1497
+		$map_args['latitude'] = $address_latitude;
1498
+		$map_args['longitude'] = $address_longitude;
1499
+		$map_args['enable_cat_filters'] = false;
1500
+		$map_args['enable_text_search'] = false;
1501
+		$map_args['enable_post_type_filters'] = false;
1502
+		$map_args['enable_location_filters'] = false;
1503
+		$map_args['enable_jason_on_load'] = true;
1504
+		$map_args['enable_map_direction'] = true;
1505
+		$map_args['map_class_name'] = 'geodir-map-preview-page';
1506
+	}
1507 1507
 
1508
-    $active_tab = '';
1509
-    $active_tab_name = '';
1510
-    $default_tab = '';
1511
-    $default_tab_name = '';
1512
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1513
-        if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1514
-            $active_tab = $tab_index;
1515
-            $active_tab_name = __($tabs['heading_text'], 'geodirectory');
1516
-        }
1508
+	$active_tab = '';
1509
+	$active_tab_name = '';
1510
+	$default_tab = '';
1511
+	$default_tab_name = '';
1512
+	foreach($arr_detail_page_tabs as $tab_index => $tabs){
1513
+		if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1514
+			$active_tab = $tab_index;
1515
+			$active_tab_name = __($tabs['heading_text'], 'geodirectory');
1516
+		}
1517 1517
         
1518
-        if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1519
-            $default_tab = $tab_index;
1520
-            $default_tab_name = __($tabs['heading_text'], 'geodirectory');
1521
-        }
1522
-    }
1518
+		if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1519
+			$default_tab = $tab_index;
1520
+			$default_tab_name = __($tabs['heading_text'], 'geodirectory');
1521
+		}
1522
+	}
1523 1523
     
1524
-    if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1525
-        if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1526
-            $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1527
-        }
1524
+	if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1525
+		if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1526
+			$arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1527
+		}
1528 1528
         
1529
-        $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1530
-        $active_tab = $default_tab;
1531
-        $active_tab_name = $default_tab_name;
1532
-    }
1533
-    $tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1534
-    ?>
1529
+		$arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1530
+		$active_tab = $default_tab;
1531
+		$active_tab_name = $default_tab_name;
1532
+	}
1533
+	$tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1534
+	?>
1535 1535
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1536 1536
         <?php if(!$tab_list){ ?>
1537 1537
         <div id="geodir-tab-mobile-menu">
@@ -1541,166 +1541,166 @@  discard block
 block discarded – undo
1541 1541
         </div>
1542 1542
         <dl class="geodir-tab-head">
1543 1543
             <?php
1544
-            }
1545
-            /**
1546
-             * Called before the details page tab list headings, inside the `dl` tag.
1547
-             *
1548
-             * @since 1.0.0
1549
-             * @see 'geodir_after_tab_list'
1550
-             */
1551
-            do_action('geodir_before_tab_list'); ?>
1544
+			}
1545
+			/**
1546
+			 * Called before the details page tab list headings, inside the `dl` tag.
1547
+			 *
1548
+			 * @since 1.0.0
1549
+			 * @see 'geodir_after_tab_list'
1550
+			 */
1551
+			do_action('geodir_before_tab_list'); ?>
1552 1552
             <?php
1553 1553
 
1554
-            foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1555
-                if ($detail_page_tab['is_display']) {
1554
+			foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1555
+				if ($detail_page_tab['is_display']) {
1556 1556
 
1557
-                    if(!$tab_list) {
1558
-                        ?>
1557
+					if(!$tab_list) {
1558
+						?>
1559 1559
                         <dt></dt> <!-- added to comply with validation -->
1560 1560
                         <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php } ?> ><a
1561 1561
                                 data-tab="#<?php echo $tab_index; ?>"
1562 1562
                                 data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a>
1563 1563
                         </dd>
1564 1564
                         <?php
1565
-                    }
1566
-                    ob_start() // start tab content buffering
1567
-                    ?>
1565
+					}
1566
+					ob_start() // start tab content buffering
1567
+					?>
1568 1568
                     <li id="<?php echo $tab_index;?>Tab">
1569 1569
                         <?php if($tab_list){
1570
-                            $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1571
-                            /**
1572
-                             * Filter the tab list title html.
1573
-                             *
1574
-                             * @since 1.6.1
1575
-                             * @param string $tab_title The html for the tab title.
1576
-                             * @param string $tab_index The tab index type.
1577
-                             * @param array $detail_page_tab The array of values including title text.
1578
-                             */
1579
-                            echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1580
-                        }?>
1570
+							$tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1571
+							/**
1572
+							 * Filter the tab list title html.
1573
+							 *
1574
+							 * @since 1.6.1
1575
+							 * @param string $tab_title The html for the tab title.
1576
+							 * @param string $tab_index The tab index type.
1577
+							 * @param array $detail_page_tab The array of values including title text.
1578
+							 */
1579
+							echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1580
+						}?>
1581 1581
                         <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1582 1582
                         <?php
1583
-                        /**
1584
-                         * Called before the details tab content is output per tab.
1585
-                         *
1586
-                         * @since 1.0.0
1587
-                         * @param string $tab_index The tab name ID.
1588
-                         */
1589
-                        do_action('geodir_before_tab_content', $tab_index);
1590
-
1591
-                        /**
1592
-                         * Called before the details tab content is output per tab.
1593
-                         *
1594
-                         * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1595
-                         *
1596
-                         * @since 1.0.0
1597
-                         * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1598
-                         */
1599
-                        do_action('geodir_before_' . $tab_index . '_tab_content');
1600
-                        /// write a code to generate content of each tab
1601
-                        switch ($tab_index) {
1602
-                            case 'post_profile':
1603
-                                /**
1604
-                                 * Called before the listing description content on the details page tab.
1605
-                                 *
1606
-                                 * @since 1.0.0
1607
-                                 */
1608
-                                do_action('geodir_before_description_on_listing_detail');
1609
-                                if (geodir_is_page('detail')) {
1610
-                                    the_content();
1611
-                                } else {
1612
-                                    /** This action is documented in geodirectory_template_actions.php */
1613
-                                    echo apply_filters('the_content', stripslashes($post->post_desc));
1614
-                                }
1615
-
1616
-                                /**
1617
-                                 * Called after the listing description content on the details page tab.
1618
-                                 *
1619
-                                 * @since 1.0.0
1620
-                                 */
1621
-                                do_action('geodir_after_description_on_listing_detail');
1622
-                                break;
1623
-                            case 'post_info':
1624
-                                echo $geodir_post_detail_fields;
1625
-                                break;
1626
-                            case 'post_images':
1627
-                                echo $thumb_image;
1628
-                                break;
1629
-                            case 'post_video':
1630
-                                /** This action is documented in geodirectory_template_actions.php */
1631
-                                echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1632
-                                break;
1633
-                            case 'special_offers':
1634
-                                echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
1635
-
1636
-                                break;
1637
-                            case 'post_map':
1638
-                                geodir_draw_map($map_args);
1639
-                                break;
1640
-                            case 'reviews':
1641
-                                comments_template();
1642
-                                break;
1643
-                            case 'related_listing':
1644
-                                echo $related_listing;
1645
-                                break;
1646
-                            default: {
1647
-                                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'])) {
1648
-                                    echo $detail_page_tab['tab_content'];
1649
-                                }
1650
-                            }
1651
-                                break;
1652
-                        }
1653
-
1654
-                        /**
1655
-                         * Called after the details tab content is output per tab.
1656
-                         *
1657
-                         * @since 1.0.0
1658
-                         */
1659
-                        do_action('geodir_after_tab_content', $tab_index);
1660
-
1661
-                        /**
1662
-                         * Called after the details tab content is output per tab.
1663
-                         *
1664
-                         * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1665
-                         *
1666
-                         * @since 1.0.0
1667
-                         * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1668
-                         */
1669
-                        do_action('geodir_after_' . $tab_index . '_tab_content');
1670
-                        ?> </li>
1583
+						/**
1584
+						 * Called before the details tab content is output per tab.
1585
+						 *
1586
+						 * @since 1.0.0
1587
+						 * @param string $tab_index The tab name ID.
1588
+						 */
1589
+						do_action('geodir_before_tab_content', $tab_index);
1590
+
1591
+						/**
1592
+						 * Called before the details tab content is output per tab.
1593
+						 *
1594
+						 * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1595
+						 *
1596
+						 * @since 1.0.0
1597
+						 * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1598
+						 */
1599
+						do_action('geodir_before_' . $tab_index . '_tab_content');
1600
+						/// write a code to generate content of each tab
1601
+						switch ($tab_index) {
1602
+							case 'post_profile':
1603
+								/**
1604
+								 * Called before the listing description content on the details page tab.
1605
+								 *
1606
+								 * @since 1.0.0
1607
+								 */
1608
+								do_action('geodir_before_description_on_listing_detail');
1609
+								if (geodir_is_page('detail')) {
1610
+									the_content();
1611
+								} else {
1612
+									/** This action is documented in geodirectory_template_actions.php */
1613
+									echo apply_filters('the_content', stripslashes($post->post_desc));
1614
+								}
1615
+
1616
+								/**
1617
+								 * Called after the listing description content on the details page tab.
1618
+								 *
1619
+								 * @since 1.0.0
1620
+								 */
1621
+								do_action('geodir_after_description_on_listing_detail');
1622
+								break;
1623
+							case 'post_info':
1624
+								echo $geodir_post_detail_fields;
1625
+								break;
1626
+							case 'post_images':
1627
+								echo $thumb_image;
1628
+								break;
1629
+							case 'post_video':
1630
+								/** This action is documented in geodirectory_template_actions.php */
1631
+								echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1632
+								break;
1633
+							case 'special_offers':
1634
+								echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
1635
+
1636
+								break;
1637
+							case 'post_map':
1638
+								geodir_draw_map($map_args);
1639
+								break;
1640
+							case 'reviews':
1641
+								comments_template();
1642
+								break;
1643
+							case 'related_listing':
1644
+								echo $related_listing;
1645
+								break;
1646
+							default: {
1647
+								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'])) {
1648
+									echo $detail_page_tab['tab_content'];
1649
+								}
1650
+							}
1651
+								break;
1652
+						}
1653
+
1654
+						/**
1655
+						 * Called after the details tab content is output per tab.
1656
+						 *
1657
+						 * @since 1.0.0
1658
+						 */
1659
+						do_action('geodir_after_tab_content', $tab_index);
1660
+
1661
+						/**
1662
+						 * Called after the details tab content is output per tab.
1663
+						 *
1664
+						 * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1665
+						 *
1666
+						 * @since 1.0.0
1667
+						 * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1668
+						 */
1669
+						do_action('geodir_after_' . $tab_index . '_tab_content');
1670
+						?> </li>
1671 1671
                     <?php
1672
-                    /**
1673
-                     * Filter the current tab content.
1674
-                     *
1675
-                     * @since 1.0.0
1676
-                     */
1677
-                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1678
-                } // end of if for is_display
1679
-            }// end of foreach
1680
-
1681
-            /**
1682
-             * Called after the details page tab list headings, inside the `dl` tag.
1683
-             *
1684
-             * @since 1.0.0
1685
-             * @see 'geodir_before_tab_list'
1686
-             */
1687
-            do_action('geodir_after_tab_list');
1688
-            ?>
1672
+					/**
1673
+					 * Filter the current tab content.
1674
+					 *
1675
+					 * @since 1.0.0
1676
+					 */
1677
+					$arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1678
+				} // end of if for is_display
1679
+			}// end of foreach
1680
+
1681
+			/**
1682
+			 * Called after the details page tab list headings, inside the `dl` tag.
1683
+			 *
1684
+			 * @since 1.0.0
1685
+			 * @see 'geodir_before_tab_list'
1686
+			 */
1687
+			do_action('geodir_after_tab_list');
1688
+			?>
1689 1689
             <?php if(!$tab_list){?></dl><?php }?>
1690 1690
         <ul class="geodir-tabs-content entry-content <?php if($tab_list){?>geodir-tabs-list<?php }?>" style="position:relative;">
1691 1691
             <?php
1692
-            foreach ($arr_detail_page_tabs as $detail_page_tab) {
1693
-                if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1694
-                    echo $detail_page_tab['tab_content'];
1695
-                }// end of if
1696
-            }// end of foreach
1697
-
1698
-            /**
1699
-             * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1700
-             *
1701
-             * @since 1.0.0
1702
-             */
1703
-            do_action('geodir_add_tab_content'); ?>
1692
+			foreach ($arr_detail_page_tabs as $detail_page_tab) {
1693
+				if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1694
+					echo $detail_page_tab['tab_content'];
1695
+				}// end of if
1696
+			}// end of foreach
1697
+
1698
+			/**
1699
+			 * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1700
+			 *
1701
+			 * @since 1.0.0
1702
+			 */
1703
+			do_action('geodir_add_tab_content'); ?>
1704 1704
         </ul>
1705 1705
         <!--gd-tabs-content ul end-->
1706 1706
     </div>
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
         });
1724 1724
     </script>
1725 1725
     <?php
1726
-    }
1726
+	}
1727 1727
 }
1728 1728
 
1729 1729
 /**
@@ -1736,127 +1736,127 @@  discard block
 block discarded – undo
1736 1736
  */
1737 1737
 function geodir_exif($file)
1738 1738
 {
1739
-    if (empty($file) || !is_array($file)) {
1740
-        return $file;
1741
-    }
1739
+	if (empty($file) || !is_array($file)) {
1740
+		return $file;
1741
+	}
1742 1742
     
1743
-    $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1744
-    if (!($file_path && file_exists($file_path))) {
1745
-        return $file;
1746
-    }
1747
-    $file['file'] = $file_path;
1743
+	$file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1744
+	if (!($file_path && file_exists($file_path))) {
1745
+		return $file;
1746
+	}
1747
+	$file['file'] = $file_path;
1748 1748
     
1749
-    if (!file_is_valid_image($file_path)) {
1750
-        return $file; // Bail if file is not an image.
1751
-    }
1749
+	if (!file_is_valid_image($file_path)) {
1750
+		return $file; // Bail if file is not an image.
1751
+	}
1752 1752
     
1753
-    if (!function_exists('wp_get_image_editor')) {
1754
-        return $file;
1755
-    }
1753
+	if (!function_exists('wp_get_image_editor')) {
1754
+		return $file;
1755
+	}
1756 1756
    
1757
-    $mime_type = $file['type'];
1758
-    $exif = array();
1759
-    if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1760
-        try {
1761
-            $exif = exif_read_data($file_path);
1762
-        } catch(Exception $e) {
1763
-            $exif = array();
1764
-        }
1765
-    }
1757
+	$mime_type = $file['type'];
1758
+	$exif = array();
1759
+	if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1760
+		try {
1761
+			$exif = exif_read_data($file_path);
1762
+		} catch(Exception $e) {
1763
+			$exif = array();
1764
+		}
1765
+	}
1766 1766
     
1767
-    $rotate = false;
1768
-    $flip = false;
1769
-    $modify = false;
1770
-    $orientation = 0;
1771
-    if (!empty($exif) && isset($exif['Orientation'])) {
1772
-        switch ((int)$exif['Orientation']) {
1773
-            case 1:
1774
-                // do nothing
1775
-                break;
1776
-            case 2:
1777
-                $flip = array(false, true);
1778
-                $modify = true;
1779
-                break;
1780
-            case 3:
1781
-                $orientation = -180;
1782
-                $rotate = true;
1783
-                $modify = true;
1784
-                break;
1785
-            case 4:
1786
-                $flip = array(true, false);
1787
-                $modify = true;
1788
-                break;
1789
-            case 5:
1790
-                $orientation = -90;
1791
-                $rotate = true;
1792
-                $flip = array(false, true);
1793
-                $modify = true;
1794
-                break;
1795
-            case 6:
1796
-                $orientation = -90;
1797
-                $rotate = true;
1798
-                $modify = true;
1799
-                break;
1800
-            case 7:
1801
-                $orientation = -270;
1802
-                $rotate = true;
1803
-                $flip = array(false, true);
1804
-                $modify = true;
1805
-                break;
1806
-            case 8:
1807
-            case 9:
1808
-                $orientation = -270;
1809
-                $rotate = true;
1810
-                $modify = true;
1811
-                break;
1812
-            default:
1813
-                $orientation = 0;
1814
-                $rotate = true;
1815
-                $modify = true;
1816
-                break;
1817
-        }
1818
-    }
1767
+	$rotate = false;
1768
+	$flip = false;
1769
+	$modify = false;
1770
+	$orientation = 0;
1771
+	if (!empty($exif) && isset($exif['Orientation'])) {
1772
+		switch ((int)$exif['Orientation']) {
1773
+			case 1:
1774
+				// do nothing
1775
+				break;
1776
+			case 2:
1777
+				$flip = array(false, true);
1778
+				$modify = true;
1779
+				break;
1780
+			case 3:
1781
+				$orientation = -180;
1782
+				$rotate = true;
1783
+				$modify = true;
1784
+				break;
1785
+			case 4:
1786
+				$flip = array(true, false);
1787
+				$modify = true;
1788
+				break;
1789
+			case 5:
1790
+				$orientation = -90;
1791
+				$rotate = true;
1792
+				$flip = array(false, true);
1793
+				$modify = true;
1794
+				break;
1795
+			case 6:
1796
+				$orientation = -90;
1797
+				$rotate = true;
1798
+				$modify = true;
1799
+				break;
1800
+			case 7:
1801
+				$orientation = -270;
1802
+				$rotate = true;
1803
+				$flip = array(false, true);
1804
+				$modify = true;
1805
+				break;
1806
+			case 8:
1807
+			case 9:
1808
+				$orientation = -270;
1809
+				$rotate = true;
1810
+				$modify = true;
1811
+				break;
1812
+			default:
1813
+				$orientation = 0;
1814
+				$rotate = true;
1815
+				$modify = true;
1816
+				break;
1817
+		}
1818
+	}
1819 1819
     
1820
-    $quality = null;
1821
-    /**
1822
-     * Filter the image quality.
1823
-     *
1824
-     * @since 1.5.7
1825
-     * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1826
-     * @param string $quality Image mime type.
1827
-     */
1828
-    $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1829
-    if ($quality !== null) {
1830
-        $modify = true;
1831
-    }
1820
+	$quality = null;
1821
+	/**
1822
+	 * Filter the image quality.
1823
+	 *
1824
+	 * @since 1.5.7
1825
+	 * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1826
+	 * @param string $quality Image mime type.
1827
+	 */
1828
+	$quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1829
+	if ($quality !== null) {
1830
+		$modify = true;
1831
+	}
1832 1832
 
1833
-    if (!$modify) {
1834
-        return $file; // no change
1835
-    }
1833
+	if (!$modify) {
1834
+		return $file; // no change
1835
+	}
1836 1836
 
1837
-    $image = wp_get_image_editor($file_path);
1838
-    if (!is_wp_error($image)) {
1839
-        if ($rotate) {
1840
-            $image->rotate($orientation);
1841
-        }
1837
+	$image = wp_get_image_editor($file_path);
1838
+	if (!is_wp_error($image)) {
1839
+		if ($rotate) {
1840
+			$image->rotate($orientation);
1841
+		}
1842 1842
         
1843
-        if (!empty($flip)) {
1844
-            $image->flip($flip[0], $flip[1]);
1845
-        }
1843
+		if (!empty($flip)) {
1844
+			$image->flip($flip[0], $flip[1]);
1845
+		}
1846 1846
         
1847
-        if ($quality !== null) {
1848
-            $image->set_quality((int)$quality);
1849
-        }
1847
+		if ($quality !== null) {
1848
+			$image->set_quality((int)$quality);
1849
+		}
1850 1850
         
1851
-       $result = $image->save($file_path);
1852
-       if (!is_wp_error($result)) {
1853
-           $file['file'] = $result['path'];
1854
-           $file['tmp_name'] = $result['path'];
1855
-       }
1856
-    }
1851
+	   $result = $image->save($file_path);
1852
+	   if (!is_wp_error($result)) {
1853
+		   $file['file'] = $result['path'];
1854
+		   $file['tmp_name'] = $result['path'];
1855
+	   }
1856
+	}
1857 1857
     
1858
-    // The image orientation is fixed, pass it back for further processing
1859
-    return $file;
1858
+	// The image orientation is fixed, pass it back for further processing
1859
+	return $file;
1860 1860
 }
1861 1861
 
1862 1862
 /**
@@ -1875,138 +1875,138 @@  discard block
 block discarded – undo
1875 1875
  * @return string Returns the recent reviews html.
1876 1876
  */
1877 1877
 function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
1878
-    global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1879
-    $tablecomments = $wpdb->comments;
1880
-    $tableposts = $wpdb->posts;
1881
-
1882
-    $comments_echo = '';
1883
-    $city_filter = '';
1884
-    $region_filter = '';
1885
-    $country_filter = '';
1886
-
1887
-    if ($gd_session->get('gd_multi_location')) {
1888
-        if ($gd_ses_country = $gd_session->get('gd_country')) {
1889
-            $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1890
-        }
1878
+	global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1879
+	$tablecomments = $wpdb->comments;
1880
+	$tableposts = $wpdb->posts;
1881
+
1882
+	$comments_echo = '';
1883
+	$city_filter = '';
1884
+	$region_filter = '';
1885
+	$country_filter = '';
1886
+
1887
+	if ($gd_session->get('gd_multi_location')) {
1888
+		if ($gd_ses_country = $gd_session->get('gd_country')) {
1889
+			$country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1890
+		}
1891 1891
 
1892
-        if ($gd_ses_region = $gd_session->get('gd_region')) {
1893
-            $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1894
-        }
1892
+		if ($gd_ses_region = $gd_session->get('gd_region')) {
1893
+			$region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1894
+		}
1895 1895
 
1896
-        if ($gd_ses_city = $gd_session->get('gd_city')) {
1897
-            $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1898
-        }
1899
-    }
1896
+		if ($gd_ses_city = $gd_session->get('gd_city')) {
1897
+			$city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1898
+		}
1899
+	}
1900 1900
 	
1901
-    $review_table = GEODIR_REVIEW_TABLE;
1902
-    $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";
1903
-
1904
-    $comments = $wpdb->get_results($request);
1905
-
1906
-    foreach ($comments as $comment) {
1907
-        // Set the extra comment info needed.
1908
-        $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1909
-        //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1910
-        $comment->comment_content = $comment_extra->comment_content;
1911
-        $comment->comment_author = $comment_extra->comment_author;
1912
-        $comment->comment_author_email = $comment_extra->comment_author_email;
1913
-
1914
-        $comment_id = '';
1915
-        $comment_id = $comment->comment_ID;
1916
-        $comment_content = strip_tags($comment->comment_content);
1917
-
1918
-        $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1919
-
1920
-        $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1921
-        $comment_author_email = $comment->comment_author_email;
1922
-        $comment_post_ID = $comment->post_id;
1923
-
1924
-        $na = true;
1925
-        if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1926
-            $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1927
-            if ($comment_post_ID == $comment_post_ID2) {
1928
-            } else {
1929
-                $na = false;
1930
-            }
1931
-        }
1901
+	$review_table = GEODIR_REVIEW_TABLE;
1902
+	$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";
1903
+
1904
+	$comments = $wpdb->get_results($request);
1905
+
1906
+	foreach ($comments as $comment) {
1907
+		// Set the extra comment info needed.
1908
+		$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1909
+		//echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1910
+		$comment->comment_content = $comment_extra->comment_content;
1911
+		$comment->comment_author = $comment_extra->comment_author;
1912
+		$comment->comment_author_email = $comment_extra->comment_author_email;
1913
+
1914
+		$comment_id = '';
1915
+		$comment_id = $comment->comment_ID;
1916
+		$comment_content = strip_tags($comment->comment_content);
1917
+
1918
+		$comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1919
+
1920
+		$permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1921
+		$comment_author_email = $comment->comment_author_email;
1922
+		$comment_post_ID = $comment->post_id;
1923
+
1924
+		$na = true;
1925
+		if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1926
+			$comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1927
+			if ($comment_post_ID == $comment_post_ID2) {
1928
+			} else {
1929
+				$na = false;
1930
+			}
1931
+		}
1932 1932
 
1933
-        $post_title = get_the_title($comment_post_ID);
1934
-        $permalink = get_permalink($comment_post_ID);
1935
-        $comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1936
-        $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1933
+		$post_title = get_the_title($comment_post_ID);
1934
+		$permalink = get_permalink($comment_post_ID);
1935
+		$comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1936
+		$read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1937 1937
 
1938
-        $comment_content_length = strlen($comment_content);
1939
-        if ($comment_content_length > $comment_lenth) {
1940
-            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1941
-        } else {
1942
-            $comment_excerpt = $comment_content;
1943
-        }
1938
+		$comment_content_length = strlen($comment_content);
1939
+		if ($comment_content_length > $comment_lenth) {
1940
+			$comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1941
+		} else {
1942
+			$comment_excerpt = $comment_content;
1943
+		}
1944 1944
 
1945
-        if ($comment->user_id) {
1946
-            $user_profile_url = get_author_posts_url($comment->user_id);
1947
-        } else {
1948
-            $user_profile_url = '';
1949
-        }
1945
+		if ($comment->user_id) {
1946
+			$user_profile_url = get_author_posts_url($comment->user_id);
1947
+		} else {
1948
+			$user_profile_url = '';
1949
+		}
1950 1950
 
1951
-        if ($comment_id && $na) {
1952
-            $comments_echo .= '<li class="clearfix">';
1953
-            $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1954
-            if (function_exists('get_avatar')) {
1955
-                if (!isset($comment->comment_type)) {
1956
-                    if ($user_profile_url) {
1957
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1958
-                    }
1959
-                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1960
-                    if ($user_profile_url) {
1961
-                        $comments_echo .= '</a>';
1962
-                    }
1963
-                } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1964
-                    if ($user_profile_url) {
1965
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1966
-                    }
1967
-                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1968
-                }
1969
-            } elseif (function_exists('gravatar')) {
1970
-                if ($user_profile_url) {
1971
-                    $comments_echo .= '<a href="' . $user_profile_url . '">';
1972
-                }
1973
-                $comments_echo .= "<img src=\"";
1974
-                if ('' == $comment->comment_type) {
1975
-                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1976
-                    if ($user_profile_url) {
1977
-                        $comments_echo .= '</a>';
1978
-                    }
1979
-                } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1980
-                    if ($user_profile_url) {
1981
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1982
-                    }
1983
-                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1984
-                    if ($user_profile_url) {
1985
-                        $comments_echo .= '</a>';
1986
-                    }
1987
-                }
1988
-                $comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1989
-            }
1951
+		if ($comment_id && $na) {
1952
+			$comments_echo .= '<li class="clearfix">';
1953
+			$comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1954
+			if (function_exists('get_avatar')) {
1955
+				if (!isset($comment->comment_type)) {
1956
+					if ($user_profile_url) {
1957
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1958
+					}
1959
+					$comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1960
+					if ($user_profile_url) {
1961
+						$comments_echo .= '</a>';
1962
+					}
1963
+				} elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1964
+					if ($user_profile_url) {
1965
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1966
+					}
1967
+					$comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1968
+				}
1969
+			} elseif (function_exists('gravatar')) {
1970
+				if ($user_profile_url) {
1971
+					$comments_echo .= '<a href="' . $user_profile_url . '">';
1972
+				}
1973
+				$comments_echo .= "<img src=\"";
1974
+				if ('' == $comment->comment_type) {
1975
+					$comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1976
+					if ($user_profile_url) {
1977
+						$comments_echo .= '</a>';
1978
+					}
1979
+				} elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1980
+					if ($user_profile_url) {
1981
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1982
+					}
1983
+					$comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1984
+					if ($user_profile_url) {
1985
+						$comments_echo .= '</a>';
1986
+					}
1987
+				}
1988
+				$comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1989
+			}
1990 1990
 
1991
-            $comments_echo .= "</span>\n";
1992
-
1993
-            $comments_echo .= '<span class="geodir_reviewer_content">';
1994
-            if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1995
-            $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1996
-            if($comment->user_id){$comments_echo .= '</a>';}
1997
-            $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1998
-            $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1999
-            $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
2000
-            $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
2001
-            //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
2002
-            $comments_echo .= '</p>';
2003
-
2004
-            $comments_echo .= "</span>\n";
2005
-            $comments_echo .= '</li>';
2006
-        }
2007
-    }
1991
+			$comments_echo .= "</span>\n";
1992
+
1993
+			$comments_echo .= '<span class="geodir_reviewer_content">';
1994
+			if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1995
+			$comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1996
+			if($comment->user_id){$comments_echo .= '</a>';}
1997
+			$comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1998
+			$comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1999
+			$comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
2000
+			$comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
2001
+			//echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
2002
+			$comments_echo .= '</p>';
2003
+
2004
+			$comments_echo .= "</span>\n";
2005
+			$comments_echo .= '</li>';
2006
+		}
2007
+	}
2008 2008
 
2009
-    return $comments_echo;
2009
+	return $comments_echo;
2010 2010
 }
2011 2011
 
2012 2012
 /**
@@ -2018,29 +2018,29 @@  discard block
 block discarded – undo
2018 2018
  */
2019 2019
 function geodir_home_map_cats_key_value_array()
2020 2020
 {
2021
-    $post_types = geodir_get_posttypes('object');
2022
-
2023
-    $return = array();
2024
-    if (!empty($post_types)) {
2025
-        foreach ($post_types as $key => $post_type) {
2026
-            $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
2027
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
2028
-            $taxonomies = geodir_get_taxonomies($key);
2029
-            $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
2030
-            $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
2031
-
2032
-            if (!empty($cat_terms)) {
2033
-                $return['optgroup_start-' . $key] = $post_type_name;
2034
-
2035
-                foreach ($cat_terms as $cat_term) {
2036
-                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2037
-                }
2021
+	$post_types = geodir_get_posttypes('object');
2038 2022
 
2039
-                $return['optgroup_end-' . $key] = $post_type_name;
2040
-            }
2041
-        }
2042
-    }
2043
-    return $return;
2023
+	$return = array();
2024
+	if (!empty($post_types)) {
2025
+		foreach ($post_types as $key => $post_type) {
2026
+			$cpt_name = __($post_type->labels->singular_name, 'geodirectory');
2027
+			$post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
2028
+			$taxonomies = geodir_get_taxonomies($key);
2029
+			$cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
2030
+			$cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
2031
+
2032
+			if (!empty($cat_terms)) {
2033
+				$return['optgroup_start-' . $key] = $post_type_name;
2034
+
2035
+				foreach ($cat_terms as $cat_term) {
2036
+					$return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2037
+				}
2038
+
2039
+				$return['optgroup_end-' . $key] = $post_type_name;
2040
+			}
2041
+		}
2042
+	}
2043
+	return $return;
2044 2044
 }
2045 2045
 
2046 2046
 /**
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
  */
2053 2053
 function geodir_twitter_tweet_button()
2054 2054
 {
2055
-    ?>
2055
+	?>
2056 2056
     <a href="http://twitter.com/share"
2057 2057
        class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
2058 2058
     <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
@@ -2069,11 +2069,11 @@  discard block
 block discarded – undo
2069 2069
  * @global object $post The current post object.
2070 2070
  */
2071 2071
 function geodir_fb_like_button() {
2072
-    global $post;
2073
-    ?>
2072
+	global $post;
2073
+	?>
2074 2074
     <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
2075
-        echo 'allowtransparency="true"';
2076
-    } ?> class="facebook"
2075
+		echo 'allowtransparency="true"';
2076
+	} ?> class="facebook"
2077 2077
          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"
2078 2078
          style="border:none; overflow:hidden; width:100px; height:20px"></iframe>
2079 2079
     <?php
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
  * @package GeoDirectory
2089 2089
  */
2090 2090
 function geodir_google_plus_button() {
2091
-    ?>
2091
+	?>
2092 2092
     <div id="plusone-div" class="g-plusone" data-size="medium"></div>
2093 2093
     <script type="text/javascript">
2094 2094
         (function () {
@@ -2113,8 +2113,8 @@  discard block
 block discarded – undo
2113 2113
  * @global object $post The current post object.
2114 2114
  */
2115 2115
 function geodir_share_this_button_code() {
2116
-    global $post;
2117
-    ?>
2116
+	global $post;
2117
+	?>
2118 2118
     <div class="addthis_toolbox addthis_default_style">
2119 2119
         <span id='st_sharethis'></span>
2120 2120
         <script type="text/javascript">var switchTo5x = false;</script>
@@ -2139,8 +2139,8 @@  discard block
 block discarded – undo
2139 2139
 }
2140 2140
 
2141 2141
 function geodir_listing_bounce_map_pin_on_hover() {
2142
-    if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2143
-        ?>
2142
+	if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2143
+		?>
2144 2144
         <script>
2145 2145
             jQuery(function ($) {
2146 2146
                 if (typeof(animate_marker) == 'function') {
@@ -2157,27 +2157,27 @@  discard block
 block discarded – undo
2157 2157
             });
2158 2158
         </script>
2159 2159
         <?php
2160
-    }
2160
+	}
2161 2161
 }
2162 2162
 add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2163 2163
 
2164 2164
 add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2165 2165
 function geodir_output_favourite_html_listings( $post_id){
2166
-    geodir_favourite_html('', $post_id);
2166
+	geodir_favourite_html('', $post_id);
2167 2167
 }
2168 2168
 
2169 2169
 add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2170 2170
 function geodir_output_pinpoint_html_listings( $post_id, $post){
2171
-    global $wp_query;
2171
+	global $wp_query;
2172 2172
 
2173
-    $show_pin_point = $wp_query->is_main_query();
2173
+	$show_pin_point = $wp_query->is_main_query();
2174 2174
     
2175
-    if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2176
-        $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2177
-        $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2178
-        ?>
2175
+	if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2176
+		$term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2177
+		$marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2178
+		?>
2179 2179
         <span class="geodir-pinpoint" style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?></span>
2180 2180
         <a class="geodir-pinpoint-link" href="javascript:void(0)" onclick="openMarker('listing_map_canvas' ,'<?php echo $post->ID; ?>')" onmouseover="animate_marker('listing_map_canvas' ,'<?php echo $post->ID; ?>')" onmouseout="stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')"><?php _e('Pinpoint', 'geodirectory'); ?></a>
2181 2181
         <?php
2182
-    }
2182
+	}
2183 2183
 }
2184 2184
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 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
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 $out .= $subex;
116 116
             }
117 117
         }
118
-        $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
118
+        $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">';
119 119
         /**
120 120
          * Filter excerpt read more text.
121 121
          *
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129 129
             $excut = -(mb_strlen($excerpt_more));
130 130
             $out .= mb_substr($excerpt, 0, $excut);
131
-            $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
131
+            $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">';
132 132
             /**
133 133
              * Filter excerpt read more text.
134 134
              *
@@ -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
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         $post_title = $productinfo->post_title;
239 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 243
     $user_info = get_userdata($author_id);
244 244
     $to_email = geodir_get_post_meta($pid, 'geodir_email', true);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     do_action('geodir_after_send_enquiry', $request, 'Enquiry');
269 269
 
270 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>.';
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 272
     /**
273 273
      * Filter client message text.
274 274
      *
@@ -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
     /**
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
     do_action('geodir_after_send_enquiry_email', $request);
321 321
     $url = get_permalink($pid);
322 322
     if (strstr($url, '?')) {
323
-        $url = $url . "&send_inquiry=success";
323
+        $url = $url."&send_inquiry=success";
324 324
     } else {
325
-        $url = $url . "?send_inquiry=success";
325
+        $url = $url."?send_inquiry=success";
326 326
     }
327 327
     /**
328 328
      * Filter redirect url after the send enquiry email is sent.
@@ -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.
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 
428 428
     $url = get_permalink($pid);
429 429
     if (strstr($url, '?')) {
430
-        $url = $url . "&sendtofrnd=success";
430
+        $url = $url."&sendtofrnd=success";
431 431
     } else {
432
-        $url = $url . "?sendtofrnd=success";
432
+        $url = $url."?sendtofrnd=success";
433 433
     }
434 434
     /**
435 435
      * Filter redirect url after the send to friend email is sent.
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
              *
464 464
              * @since 1.0.0
465 465
              */
466
-            echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
466
+            echo ' <div id="'.apply_filters('geodir_post_gallery_id', 'geodir-post-gallery').'" class="clearfix" >';
467 467
             break;
468 468
         case 'reviews' :
469 469
             echo '<div id="reviews-wrap" class="clearfix"> ';
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         if (!in_array($post_type, $all_postypes))
530 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 534
         if (!empty($sort_field_info))
535 535
             return $sort_field_info;
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
         if (!in_array($post_type, $all_postypes))
558 558
             return false;
559 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)));
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 561
         /**
562 562
          * Filter post sort options.
563 563
          *
@@ -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') {
@@ -619,21 +619,21 @@  discard block
 block discarded – undo
619 619
             }
620 620
 
621 621
             if ($sort->sort_asc) {
622
-                $key = $sort->htmlvar_name . '_asc';
622
+                $key = $sort->htmlvar_name.'_asc';
623 623
                 $label = $sort->site_title;
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) {
631
-                $key = $sort->htmlvar_name . '_desc';
631
+                $key = $sort->htmlvar_name.'_desc';
632 632
                 $label = $sort->site_title;
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
 
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
         $category = array();
722 722
 
723 723
         if (isset($_REQUEST['backandedit'])) {
724
-            $post = (object)$gd_session->get('listing');
724
+            $post = (object) $gd_session->get('listing');
725 725
             $post_type = $post->listing_type;
726 726
             if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
727 727
                 $post_id = $_REQUEST['pid'];
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 
737 737
         if ($relate_to == 'category') {
738 738
 
739
-            $category_taxonomy = $post_type . $relate_to;
739
+            $category_taxonomy = $post_type.$relate_to;
740 740
             if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
741 741
                 $category = explode(',', trim($post->{$category_taxonomy}, ','));
742 742
 
743 743
         } elseif ($relate_to == 'tags') {
744 744
 
745
-            $category_taxonomy = $post_type . '_' . $relate_to;
745
+            $category_taxonomy = $post_type.'_'.$relate_to;
746 746
             if ($post->post_tags != '')
747 747
                 $category = explode(',', trim($post->post_tags, ','));
748 748
             $tax_field = 'name';
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
             if ($add_location_filter != '0') {
799 799
                 $geodir_add_location_url = '1';
800 800
             }
801
-            $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
801
+            $viewall_url = get_term_link((int) $category[0], $post_type.$category_taxonomy);
802 802
             $geodir_add_location_url = NULL;
803 803
         }
804 804
         ob_start();
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
                 $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
816 816
                 ?>
817 817
                 <div class="location_list_heading clearfix">
818
-                    <?php echo $before_title . $title . $after_title; ?>
818
+                    <?php echo $before_title.$title.$after_title; ?>
819 819
                 </div>
820 820
             <?php
821 821
             }
@@ -903,8 +903,8 @@  discard block
 block discarded – undo
903 903
         $geodir_post_category_str = serialize($geodir_post_category_str);
904 904
     }
905 905
 
906
-    $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
907
-    $script = "var post_category_array = " . json_encode($all_var) . ';';
906
+    $all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8');
907
+    $script = "var post_category_array = ".json_encode($all_var).';';
908 908
     echo '<script>';
909 909
     echo $script;
910 910
     echo '</script>';
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
         }
1026 1026
     } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1027 1027
         if (is_category()) {
1028
-            $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1028
+            $meta_desc .= __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", FALSE));
1029 1029
         } elseif (is_tag()) {
1030
-            $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1030
+            $meta_desc .= __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", FALSE));
1031 1031
         }
1032 1032
     } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1033 1033
         $meta_desc .= isset($current_term->description) ? $current_term->description : '';
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
     $replace_location = __('Everywhere', 'geodirectory');
1055 1055
     $location_id = NULL;
1056 1056
     if ($geodir_location_manager) {
1057
-        $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1058
-        $location_id = (int)$wpdb->get_var($sql);
1057
+        $sql = $wpdb->prepare("SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1058
+        $location_id = (int) $wpdb->get_var($sql);
1059 1059
         $location_type = geodir_what_is_current_location();
1060 1060
         if ($location_type == 'city') {
1061 1061
             $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
@@ -1096,65 +1096,65 @@  discard block
 block discarded – undo
1096 1096
                     $category_id = $category->term_id;
1097 1097
                     $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1098 1098
                     if ($location_id) {
1099
-                        $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1099
+                        $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id;
1100 1100
                         $cat_loc_option = get_option($option_name);
1101 1101
 
1102 1102
                         $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;
1103 1103
                         if (!$gd_cat_loc_default) {
1104
-                            $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1104
+                            $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id.'_'.$location_id;
1105 1105
                             $option = get_option($option_name);
1106 1106
                             $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1107 1107
                         }
1108 1108
                     }
1109
-                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1109
+                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", FALSE)).'. '.$category_desc;
1110 1110
                 }
1111 1111
             } else if ($geodir_is_tag) {
1112
-                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1112
+                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", FALSE)).'. '.$geodir_meta_desc;
1113 1113
             }
1114 1114
         }
1115 1115
     }
1116 1116
 
1117 1117
 
1118 1118
     $gd_page = '';
1119
-    if(geodir_is_page('home')){
1119
+    if (geodir_is_page('home')) {
1120 1120
         $gd_page = 'home';
1121 1121
         $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1122 1122
     }
1123
-    elseif(geodir_is_page('detail')){
1123
+    elseif (geodir_is_page('detail')) {
1124 1124
         $gd_page = 'detail';
1125 1125
         $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1126 1126
     }
1127
-    elseif(geodir_is_page('pt')){
1127
+    elseif (geodir_is_page('pt')) {
1128 1128
         $gd_page = 'pt';
1129 1129
         $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1130 1130
     }
1131
-    elseif(geodir_is_page('listing')){
1131
+    elseif (geodir_is_page('listing')) {
1132 1132
         $gd_page = 'listing';
1133 1133
         $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1134 1134
     }
1135
-    elseif(geodir_is_page('location')){
1135
+    elseif (geodir_is_page('location')) {
1136 1136
         $gd_page = 'location';
1137 1137
         $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1138 1138
         $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1139 1139
 
1140 1140
     }
1141
-    elseif(geodir_is_page('search')){
1141
+    elseif (geodir_is_page('search')) {
1142 1142
         $gd_page = 'search';
1143 1143
         $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1144 1144
     }
1145
-    elseif(geodir_is_page('add-listing')){
1145
+    elseif (geodir_is_page('add-listing')) {
1146 1146
         $gd_page = 'add-listing';
1147 1147
         $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1148 1148
     }
1149
-    elseif(geodir_is_page('author')){
1149
+    elseif (geodir_is_page('author')) {
1150 1150
         $gd_page = 'author';
1151 1151
         $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1152 1152
     }
1153
-    elseif(geodir_is_page('login')){
1153
+    elseif (geodir_is_page('login')) {
1154 1154
         $gd_page = 'login';
1155 1155
         $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1156 1156
     }
1157
-    elseif(geodir_is_page('listing-success')){
1157
+    elseif (geodir_is_page('listing-success')) {
1158 1158
         $gd_page = 'listing-success';
1159 1159
         $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1160 1160
     }
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
          * @param string $title The page description including variables.
1183 1183
          * @param string $gd_page The GeoDirectory page type if any.
1184 1184
          */
1185
-        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1185
+        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
1186 1186
 
1187 1187
         /**
1188 1188
          * Filter SEO meta description.
@@ -1190,20 +1190,20 @@  discard block
 block discarded – undo
1190 1190
          * @since 1.0.0
1191 1191
          * @param string $meta_desc Meta description content.
1192 1192
          */
1193
-        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1193
+        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="'.$meta_desc.'" />', $meta_desc);
1194 1194
     }
1195 1195
 
1196 1196
     // meta keywords
1197 1197
     if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1198
-        $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1199
-        $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1198
+        $place_tags = wp_get_post_terms($post->ID, $post->post_type.'_tags', array("fields" => "names"));
1199
+        $place_cats = wp_get_post_terms($post->ID, $post->post_type.'category', array("fields" => "names"));
1200 1200
 
1201
-        $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1201
+        $meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
1202 1202
     } else {
1203 1203
         $posttags = get_the_tags();
1204 1204
         if ($posttags) {
1205 1205
             foreach ($posttags as $tag) {
1206
-                $meta_key .= $tag->name . ' ';
1206
+                $meta_key .= $tag->name.' ';
1207 1207
             }
1208 1208
         } else {
1209 1209
             $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 
1212 1212
             foreach ($tags as $tag) {
1213 1213
                 if ($xt <= 20) {
1214
-                    $meta_key .= $tag->name . ", ";
1214
+                    $meta_key .= $tag->name.", ";
1215 1215
                 }
1216 1216
 
1217 1217
                 $xt++;
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
     }
1221 1221
 
1222 1222
     $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1223
-    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1223
+    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key.', '.$geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1224 1224
     if ($geodir_meta_keys != '') {
1225 1225
         $geodir_meta_keys = strip_tags($geodir_meta_keys);
1226 1226
         $geodir_meta_keys = esc_html($geodir_meta_keys);
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
          * @since 1.0.0
1240 1240
          * @param string $meta_desc Meta keywords.
1241 1241
          */
1242
-        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1242
+        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="'.$meta_key.'" />', $meta_key);
1243 1243
     }
1244 1244
 
1245 1245
 }
@@ -1384,8 +1384,8 @@  discard block
 block discarded – undo
1384 1384
 {
1385 1385
     global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1386 1386
 
1387
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1388
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1387
+    $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0;
1388
+    $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
1389 1389
     $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
1390 1390
 
1391 1391
     if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 
1396 1396
     $geodir_post_detail_fields = geodir_show_listing_info('detail');
1397 1397
 
1398
-    $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1398
+    $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user
1399 1399
 
1400 1400
     if (geodir_is_page('detail')) {
1401 1401
         $video = geodir_get_video($post->ID);
@@ -1426,7 +1426,7 @@  discard block
 block discarded – undo
1426 1426
         if (!empty($post_images)) {
1427 1427
             foreach ($post_images as $image) {
1428 1428
                 $caption = (!empty($image->caption)) ? $image->caption : '';
1429
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1429
+                $thumb_image .= '<a href="'.$image->src.'" title="'.$caption.'">';
1430 1430
                 $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1431 1431
                 $thumb_image .= '</a>';
1432 1432
             }
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
         $map_args['width'] = '600';
1438 1438
         $map_args['height'] = '300';
1439 1439
         if ($post->post_mapzoom) {
1440
-            $map_args['zoom'] = '' . $post->post_mapzoom . '';
1440
+            $map_args['zoom'] = ''.$post->post_mapzoom.'';
1441 1441
         }
1442 1442
         $map_args['autozoom'] = false;
1443 1443
         $map_args['child_collapse'] = '0';
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
         if (!empty($post_images)) {
1464 1464
             foreach ($post_images as $image) {
1465 1465
                 if ($image != '') {
1466
-                    $thumb_image .= '<a href="' . $image . '">';
1466
+                    $thumb_image .= '<a href="'.$image.'">';
1467 1467
                     $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1468 1468
                     $thumb_image .= '</a>';
1469 1469
                 }
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
     $active_tab_name = '';
1510 1510
     $default_tab = '';
1511 1511
     $default_tab_name = '';
1512
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1512
+    foreach ($arr_detail_page_tabs as $tab_index => $tabs) {
1513 1513
         if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1514 1514
             $active_tab = $tab_index;
1515 1515
             $active_tab_name = __($tabs['heading_text'], 'geodirectory');
@@ -1530,10 +1530,10 @@  discard block
 block discarded – undo
1530 1530
         $active_tab = $default_tab;
1531 1531
         $active_tab_name = $default_tab_name;
1532 1532
     }
1533
-    $tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1533
+    $tab_list = (get_option('geodir_disable_tabs', false)) ? true : false;
1534 1534
     ?>
1535 1535
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1536
-        <?php if(!$tab_list){ ?>
1536
+        <?php if (!$tab_list) { ?>
1537 1537
         <div id="geodir-tab-mobile-menu">
1538 1538
             <i class="fa fa-bars"></i>
1539 1539
             <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span>
@@ -1554,10 +1554,10 @@  discard block
 block discarded – undo
1554 1554
             foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1555 1555
                 if ($detail_page_tab['is_display']) {
1556 1556
 
1557
-                    if(!$tab_list) {
1557
+                    if (!$tab_list) {
1558 1558
                         ?>
1559 1559
                         <dt></dt> <!-- added to comply with validation -->
1560
-                        <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php } ?> ><a
1560
+                        <dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php } ?> ><a
1561 1561
                                 data-tab="#<?php echo $tab_index; ?>"
1562 1562
                                 data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a>
1563 1563
                         </dd>
@@ -1565,9 +1565,9 @@  discard block
 block discarded – undo
1565 1565
                     }
1566 1566
                     ob_start() // start tab content buffering
1567 1567
                     ?>
1568
-                    <li id="<?php echo $tab_index;?>Tab">
1569
-                        <?php if($tab_list){
1570
-                            $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1568
+                    <li id="<?php echo $tab_index; ?>Tab">
1569
+                        <?php if ($tab_list) {
1570
+                            $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'], 'geodirectory').'</a></span><hr />';
1571 1571
                             /**
1572 1572
                              * Filter the tab list title html.
1573 1573
                              *
@@ -1576,9 +1576,9 @@  discard block
 block discarded – undo
1576 1576
                              * @param string $tab_index The tab index type.
1577 1577
                              * @param array $detail_page_tab The array of values including title text.
1578 1578
                              */
1579
-                            echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1579
+                            echo apply_filters('geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab);
1580 1580
                         }?>
1581
-                        <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1581
+                        <div id="<?php echo $tab_index; ?>" class="hash-offset"></div>
1582 1582
                         <?php
1583 1583
                         /**
1584 1584
                          * Called before the details tab content is output per tab.
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
                          * @since 1.0.0
1597 1597
                          * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1598 1598
                          */
1599
-                        do_action('geodir_before_' . $tab_index . '_tab_content');
1599
+                        do_action('geodir_before_'.$tab_index.'_tab_content');
1600 1600
                         /// write a code to generate content of each tab
1601 1601
                         switch ($tab_index) {
1602 1602
                             case 'post_profile':
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
                                 break;
1629 1629
                             case 'post_video':
1630 1630
                                 /** This action is documented in geodirectory_template_actions.php */
1631
-                                echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1631
+                                echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
1632 1632
                                 break;
1633 1633
                             case 'special_offers':
1634 1634
                                 echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
                          * @since 1.0.0
1667 1667
                          * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1668 1668
                          */
1669
-                        do_action('geodir_after_' . $tab_index . '_tab_content');
1669
+                        do_action('geodir_after_'.$tab_index.'_tab_content');
1670 1670
                         ?> </li>
1671 1671
                     <?php
1672 1672
                     /**
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
                      *
1675 1675
                      * @since 1.0.0
1676 1676
                      */
1677
-                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1677
+                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_".$detail_page_tab['tab_content']."_tab_content", ob_get_clean());
1678 1678
                 } // end of if for is_display
1679 1679
             }// end of foreach
1680 1680
 
@@ -1686,8 +1686,8 @@  discard block
 block discarded – undo
1686 1686
              */
1687 1687
             do_action('geodir_after_tab_list');
1688 1688
             ?>
1689
-            <?php if(!$tab_list){?></dl><?php }?>
1690
-        <ul class="geodir-tabs-content entry-content <?php if($tab_list){?>geodir-tabs-list<?php }?>" style="position:relative;">
1689
+            <?php if (!$tab_list) {?></dl><?php }?>
1690
+        <ul class="geodir-tabs-content entry-content <?php if ($tab_list) {?>geodir-tabs-list<?php }?>" style="position:relative;">
1691 1691
             <?php
1692 1692
             foreach ($arr_detail_page_tabs as $detail_page_tab) {
1693 1693
                 if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
         </ul>
1705 1705
         <!--gd-tabs-content ul end-->
1706 1706
     </div>
1707
-    <?php if(!$tab_list){ ?>
1707
+    <?php if (!$tab_list) { ?>
1708 1708
     <script>
1709 1709
         if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) {
1710 1710
             hashVal = window.location.hash;
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
     if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1760 1760
         try {
1761 1761
             $exif = exif_read_data($file_path);
1762
-        } catch(Exception $e) {
1762
+        } catch (Exception $e) {
1763 1763
             $exif = array();
1764 1764
         }
1765 1765
     }
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
     $modify = false;
1770 1770
     $orientation = 0;
1771 1771
     if (!empty($exif) && isset($exif['Orientation'])) {
1772
-        switch ((int)$exif['Orientation']) {
1772
+        switch ((int) $exif['Orientation']) {
1773 1773
             case 1:
1774 1774
                 // do nothing
1775 1775
                 break;
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
         }
1846 1846
         
1847 1847
         if ($quality !== null) {
1848
-            $image->set_quality((int)$quality);
1848
+            $image->set_quality((int) $quality);
1849 1849
         }
1850 1850
         
1851 1851
        $result = $image->save($file_path);
@@ -1917,7 +1917,7 @@  discard block
 block discarded – undo
1917 1917
 
1918 1918
         $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1919 1919
 
1920
-        $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1920
+        $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
1921 1921
         $comment_author_email = $comment->comment_author_email;
1922 1922
         $comment_post_ID = $comment->post_id;
1923 1923
 
@@ -1932,12 +1932,12 @@  discard block
 block discarded – undo
1932 1932
 
1933 1933
         $post_title = get_the_title($comment_post_ID);
1934 1934
         $permalink = get_permalink($comment_post_ID);
1935
-        $comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1936
-        $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1935
+        $comment_permalink = $permalink."#comment-".$comment->comment_ID;
1936
+        $read_more = '<a class="comment_excerpt" href="'.$comment_permalink.'">'.__('Read more', 'geodirectory').'</a>';
1937 1937
 
1938 1938
         $comment_content_length = strlen($comment_content);
1939 1939
         if ($comment_content_length > $comment_lenth) {
1940
-            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1940
+            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth).'... '.$read_more;
1941 1941
         } else {
1942 1942
             $comment_excerpt = $comment_content;
1943 1943
         }
@@ -1950,37 +1950,37 @@  discard block
 block discarded – undo
1950 1950
 
1951 1951
         if ($comment_id && $na) {
1952 1952
             $comments_echo .= '<li class="clearfix">';
1953
-            $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1953
+            $comments_echo .= "<span class=\"li".$comment_id." geodir_reviewer_image\">";
1954 1954
             if (function_exists('get_avatar')) {
1955 1955
                 if (!isset($comment->comment_type)) {
1956 1956
                     if ($user_profile_url) {
1957
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1957
+                        $comments_echo .= '<a href="'.$user_profile_url.'">';
1958 1958
                     }
1959
-                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1959
+                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1960 1960
                     if ($user_profile_url) {
1961 1961
                         $comments_echo .= '</a>';
1962 1962
                     }
1963 1963
                 } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1964 1964
                     if ($user_profile_url) {
1965
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1965
+                        $comments_echo .= '<a href="'.$user_profile_url.'">';
1966 1966
                     }
1967
-                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1967
+                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1968 1968
                 }
1969 1969
             } elseif (function_exists('gravatar')) {
1970 1970
                 if ($user_profile_url) {
1971
-                    $comments_echo .= '<a href="' . $user_profile_url . '">';
1971
+                    $comments_echo .= '<a href="'.$user_profile_url.'">';
1972 1972
                 }
1973 1973
                 $comments_echo .= "<img src=\"";
1974 1974
                 if ('' == $comment->comment_type) {
1975
-                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1975
+                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1976 1976
                     if ($user_profile_url) {
1977 1977
                         $comments_echo .= '</a>';
1978 1978
                     }
1979 1979
                 } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1980 1980
                     if ($user_profile_url) {
1981
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1981
+                        $comments_echo .= '<a href="'.$user_profile_url.'">';
1982 1982
                     }
1983
-                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1983
+                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1984 1984
                     if ($user_profile_url) {
1985 1985
                         $comments_echo .= '</a>';
1986 1986
                     }
@@ -1991,13 +1991,13 @@  discard block
 block discarded – undo
1991 1991
             $comments_echo .= "</span>\n";
1992 1992
 
1993 1993
             $comments_echo .= '<span class="geodir_reviewer_content">';
1994
-            if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1995
-            $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1996
-            if($comment->user_id){$comments_echo .= '</a>';}
1997
-            $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1998
-            $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1994
+            if ($comment->user_id) {$comments_echo .= '<a href="'.get_author_posts_url($comment->user_id).'">'; }
1995
+            $comments_echo .= '<span class="geodir_reviewer_author">'.$comment->comment_author.'</span> ';
1996
+            if ($comment->user_id) {$comments_echo .= '</a>'; }
1997
+            $comments_echo .= '<span class="geodir_reviewer_reviewed">'.__('reviewed', 'geodirectory').'</span> ';
1998
+            $comments_echo .= '<a href="'.$permalink.'" class="geodir_reviewer_title">'.$post_title.'</a>';
1999 1999
             $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
2000
-            $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
2000
+            $comments_echo .= '<p class="geodir_reviewer_text">'.$comment_excerpt.'';
2001 2001
             //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
2002 2002
             $comments_echo .= '</p>';
2003 2003
 
@@ -2024,19 +2024,19 @@  discard block
 block discarded – undo
2024 2024
     if (!empty($post_types)) {
2025 2025
         foreach ($post_types as $key => $post_type) {
2026 2026
             $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
2027
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
2027
+            $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
2028 2028
             $taxonomies = geodir_get_taxonomies($key);
2029 2029
             $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
2030 2030
             $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
2031 2031
 
2032 2032
             if (!empty($cat_terms)) {
2033
-                $return['optgroup_start-' . $key] = $post_type_name;
2033
+                $return['optgroup_start-'.$key] = $post_type_name;
2034 2034
 
2035 2035
                 foreach ($cat_terms as $cat_term) {
2036
-                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2036
+                    $return[$key.'_'.$cat_term->term_id] = $cat_term->name;
2037 2037
                 }
2038 2038
 
2039
-                $return['optgroup_end-' . $key] = $post_type_name;
2039
+                $return['optgroup_end-'.$key] = $post_type_name;
2040 2040
             }
2041 2041
         }
2042 2042
     }
@@ -2128,10 +2128,10 @@  discard block
 block discarded – undo
2128 2128
             stWidget.addEntry({
2129 2129
                 "service": "sharethis",
2130 2130
                 "element": document.getElementById('st_sharethis'),
2131
-                "url": "<?php echo geodir_curPageURL();?>",
2132
-                "title": "<?php echo $post->post_title;?>",
2131
+                "url": "<?php echo geodir_curPageURL(); ?>",
2132
+                "title": "<?php echo $post->post_title; ?>",
2133 2133
                 "type": "chicklet",
2134
-                "text": "<?php _e( 'Share', 'geodirectory' );?>"
2134
+                "text": "<?php _e('Share', 'geodirectory'); ?>"
2135 2135
             });
2136 2136
         </script>
2137 2137
     </div>
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
 }
2140 2140
 
2141 2141
 function geodir_listing_bounce_map_pin_on_hover() {
2142
-    if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2142
+    if (get_option('geodir_listing_hover_bounce_map_pin', true)) {
2143 2143
         ?>
2144 2144
         <script>
2145 2145
             jQuery(function ($) {
@@ -2159,15 +2159,15 @@  discard block
 block discarded – undo
2159 2159
         <?php
2160 2160
     }
2161 2161
 }
2162
-add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2162
+add_action('geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10);
2163 2163
 
2164
-add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2165
-function geodir_output_favourite_html_listings( $post_id){
2164
+add_action('geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1);
2165
+function geodir_output_favourite_html_listings($post_id) {
2166 2166
     geodir_favourite_html('', $post_id);
2167 2167
 }
2168 2168
 
2169
-add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2170
-function geodir_output_pinpoint_html_listings( $post_id, $post){
2169
+add_action('geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2170
+function geodir_output_pinpoint_html_listings($post_id, $post) {
2171 2171
     global $wp_query;
2172 2172
 
2173 2173
     $show_pin_point = $wp_query->is_main_query();
Please login to merge, or discard this patch.
geodirectory-functions/custom_taxonomy_hooks_actions.php 4 patches
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
  * @global wpdb $wpdb WordPress database abstraction object.
326 326
  * @deprecated 1.5.0 No longer required.
327 327
  * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
328
- * @return array Rewrite rules.
328
+ * @return string Rewrite rules.
329 329
  */
330 330
 function geodir_htaccess_contents($rules)
331 331
 {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
  * @since 1.0.0
351 351
  *
352 352
  * @param array $public_query_vars The array of query variables.
353
- * @return array Query variables.
353
+ * @return string[] Query variables.
354 354
  */
355 355
 function geodir_add_location_var($public_query_vars)
356 356
 {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
  * @since 1.0.0
367 367
  *
368 368
  * @param array $public_query_vars The array of query variables.
369
- * @return array Query variables.
369
+ * @return string[] Query variables.
370 370
  */
371 371
 function geodir_add_geodir_page_var($public_query_vars)
372 372
 {
@@ -793,7 +793,6 @@  discard block
 block discarded – undo
793 793
  *
794 794
  * @since 1.0.0
795 795
  *
796
- * @param object $wp The WordPress object.
797 796
  */
798 797
 function geodir_custom_post_status()
799 798
 {
Please login to merge, or discard this patch.
Braces   +103 added lines, -70 removed lines patch added patch discarded remove patch
@@ -106,24 +106,30 @@  discard block
 block discarded – undo
106 106
         $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
107 107
 
108 108
         if ($post_type == 'gd_place') {
109
-            if (array_key_exists('has_archive', $args))
110
-                $args['has_archive'] = $listing_slug;
109
+            if (array_key_exists('has_archive', $args)) {
110
+                            $args['has_archive'] = $listing_slug;
111
+            }
111 112
 
112 113
             if (array_key_exists('rewrite', $args)) {
113
-                if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
114
+                if (array_key_exists('slug', $args['rewrite'])) {
115
+                                    $args['rewrite']['slug'] = $listing_slug;
116
+                }
117
+                // . '/%gd_taxonomy%';
115 118
             }
116 119
 
117 120
             $geodir_post_types = get_option('geodir_post_types');
118 121
 
119 122
             if (array_key_exists($post_type, $geodir_post_types)) {
120 123
 
121
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
124
+                if (array_key_exists('has_archive', $geodir_post_types[$post_type])) {
125
+                                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
126
+                }
123 127
 
124
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
128
+                if (array_key_exists('rewrite', $geodir_post_types[$post_type])) {
129
+                                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
130
+                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;
131
+                }
132
+                // . '/%gd_taxonomy%';
127 133
 
128 134
                 update_option('geodir_post_types', $geodir_post_types);
129 135
 
@@ -138,10 +144,11 @@  discard block
 block discarded – undo
138 144
             if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139 145
                 $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
140 146
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
147
+                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category'])) {
148
+                                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143 149
                         if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
150
+                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
151
+                }
145 152
 
146 153
                 update_option('geodir_taxonomies', $geodir_taxonomies);
147 154
 
@@ -152,10 +159,11 @@  discard block
 block discarded – undo
152 159
             if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153 160
                 $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
154 161
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
162
+                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags'])) {
163
+                                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157 164
                         if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
165
+                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
166
+                }
159 167
 
160 168
                 update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 169
 
@@ -221,8 +229,9 @@  discard block
 block discarded – undo
221 229
         global $wpdb;
222 230
         $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223 231
     }
224
-    if (!isset($location_prefix))
225
-        $location_prefix = 'location';
232
+    if (!isset($location_prefix)) {
233
+            $location_prefix = 'location';
234
+    }
226 235
 
227 236
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
228 237
 	if ($location_manager) {
@@ -441,14 +450,17 @@  discard block
 block discarded – undo
441 450
         $gd_country = '';
442 451
         $gd_region = '';
443 452
         $gd_city = '';
444
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
-            $gd_country = urldecode($wp->query_vars['gd_country']);
453
+        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') {
454
+                    $gd_country = urldecode($wp->query_vars['gd_country']);
455
+        }
446 456
 
447
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
-            $gd_region = urldecode($wp->query_vars['gd_region']);
457
+        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') {
458
+                    $gd_region = urldecode($wp->query_vars['gd_region']);
459
+        }
449 460
 
450
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
-            $gd_city = urldecode($wp->query_vars['gd_city']);
461
+        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') {
462
+                    $gd_city = urldecode($wp->query_vars['gd_city']);
463
+        }
452 464
 
453 465
         if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454 466
             $default_location = geodir_get_default_location();
@@ -456,17 +468,19 @@  discard block
 block discarded – undo
456 468
             if (get_option('geodir_add_location_url')) {
457 469
                 if ($geodir_show_location_url != 'all') {
458 470
                     if ($gd_region == '') {
459
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
460
-                            $gd_region = $gd_ses_region;
461
-                        else
462
-                            $gd_region = $default_location->region_slug;
471
+                        if ($gd_ses_region = $gd_session->get('gd_region')) {
472
+                                                    $gd_region = $gd_ses_region;
473
+                        } else {
474
+                                                    $gd_region = $default_location->region_slug;
475
+                        }
463 476
                     }
464 477
 
465 478
                     if ($gd_city == '') {
466
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
467
-                            $gd_city = $gd_ses_city;
468
-                        else
469
-                            $gd_city = $default_location->city_slug;
479
+                        if ($gd_ses_city = $gd_session->get('gd_city')) {
480
+                                                    $gd_city = $gd_ses_city;
481
+                        } else {
482
+                                                    $gd_city = $default_location->city_slug;
483
+                        }
470 484
 
471 485
                         $base_location_link = geodir_get_location_link('base');
472 486
                         wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
@@ -585,8 +599,9 @@  discard block
 block discarded – undo
585 599
 
586 600
 
587 601
 				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
588
-				if (!$post_title_replace_count)
589
-					$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
602
+				if (!$post_title_replace_count) {
603
+									$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
604
+				}
590 605
 				$geodir_terms = explode('/', $geodir_term);
591 606
 				$geodir_last_term = end($geodir_terms);
592 607
 
@@ -622,8 +637,9 @@  discard block
 block discarded – undo
622 637
                     if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
623 638
                         geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
624 639
                         geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
625
-                    )
626
-                        $is_geodir_location_found = true;
640
+                    ) {
641
+                                            $is_geodir_location_found = true;
642
+                    }
627 643
 
628 644
                     // if location has not been found for country , region and city then search for country and region only
629 645
 
@@ -631,8 +647,9 @@  discard block
 block discarded – undo
631 647
                         $gd_city = '';
632 648
                         if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
633 649
                             geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
634
-                        )
635
-                            $is_geodir_location_found = true;
650
+                        ) {
651
+                                                    $is_geodir_location_found = true;
652
+                        }
636 653
 
637 654
                     }
638 655
 
@@ -640,8 +657,9 @@  discard block
 block discarded – undo
640 657
                     if (!$is_geodir_location_found) {
641 658
                         $gd_city = '';
642 659
                         $gd_region = '';
643
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
644
-                            $is_geodir_location_found = true;
660
+                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) {
661
+                                                    $is_geodir_location_found = true;
662
+                        }
645 663
                     }
646 664
                 } else if ($geodir_show_location_url == 'country_city') {
647 665
                     if (count($geodir_terms) >= 2) {
@@ -651,17 +669,19 @@  discard block
 block discarded – undo
651 669
                         $gd_country = urldecode($geodir_terms[0]);
652 670
                     }
653 671
 
654
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
655
-                        $is_geodir_location_found = true;
672
+                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
673
+                                            $is_geodir_location_found = true;
674
+                    }
656 675
 
657 676
                     // if location has not been found for country and city  then search for country only
658 677
                     if (!$is_geodir_location_found) {
659 678
                         $gd_city = '';
660 679
                         
661
-						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
662
-                            $is_geodir_location_found = true;
680
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) {
681
+						                            $is_geodir_location_found = true;
682
+						}
663 683
                     }
664
-                }  else if ($geodir_show_location_url == 'region_city') {
684
+                } else if ($geodir_show_location_url == 'region_city') {
665 685
                     if (count($geodir_terms) >= 2) {
666 686
                         $gd_region = urldecode($geodir_terms[0]);
667 687
                         $gd_city = urldecode($geodir_terms[1]);
@@ -669,15 +689,17 @@  discard block
 block discarded – undo
669 689
                         $gd_region = urldecode($geodir_terms[0]);
670 690
                     }
671 691
 
672
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
673
-                        $is_geodir_location_found = true;
692
+                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
693
+                                            $is_geodir_location_found = true;
694
+                    }
674 695
 
675 696
                     // if location has not been found for region and city  then search for region only
676 697
                     if (!$is_geodir_location_found) {
677 698
                         $gd_city = '';
678 699
                         
679
-						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
680
-                            $is_geodir_location_found = true;
700
+						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) {
701
+						                            $is_geodir_location_found = true;
702
+						}
681 703
                     }
682 704
                 } else {
683 705
                     $gd_city = $geodir_terms[0];
@@ -719,14 +741,17 @@  discard block
 block discarded – undo
719 741
 
720 742
             $wp->query_vars[$geodir_taxonomy] = $geodir_term;
721 743
             // eliminate location related terms from taxonomy term
722
-            if ($gd_country != '')
723
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
744
+            if ($gd_country != '') {
745
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
746
+            }
724 747
 
725
-            if ($gd_region != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
748
+            if ($gd_region != '') {
749
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
750
+            }
727 751
 
728
-            if ($gd_city != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
752
+            if ($gd_city != '') {
753
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
754
+            }
730 755
 
731 756
 
732 757
             $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
@@ -762,27 +787,34 @@  discard block
 block discarded – undo
762 787
     if (get_option('geodir_add_location_url')) {        
763 788
 		if ($geodir_show_location_url == 'all') {
764 789
 		} else if ($geodir_show_location_url == 'country_city') {
765
-			 if (isset($wp->query_vars['gd_region']))
766
-                $wp->query_vars['gd_region'] = '';
790
+			 if (isset($wp->query_vars['gd_region'])) {
791
+			                 $wp->query_vars['gd_region'] = '';
792
+			 }
767 793
 		} else if ($geodir_show_location_url == 'region_city') {
768
-			if (isset($wp->query_vars['gd_country']))
769
-                $wp->query_vars['gd_country'] = '';
794
+			if (isset($wp->query_vars['gd_country'])) {
795
+			                $wp->query_vars['gd_country'] = '';
796
+			}
770 797
 		} else {
771
-			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
798
+			if (isset($wp->query_vars['gd_country'])) {
799
+			                $wp->query_vars['gd_country'] = '';
800
+			}
773 801
 
774
-            if (isset($wp->query_vars['gd_region']))
775
-                $wp->query_vars['gd_region'] = '';
802
+            if (isset($wp->query_vars['gd_region'])) {
803
+                            $wp->query_vars['gd_region'] = '';
804
+            }
776 805
 		}
777 806
     } else {
778
-        if (isset($wp->query_vars['gd_country']))
779
-            $wp->query_vars['gd_country'] = '';
807
+        if (isset($wp->query_vars['gd_country'])) {
808
+                    $wp->query_vars['gd_country'] = '';
809
+        }
780 810
 
781
-        if (isset($wp->query_vars['gd_region']))
782
-            $wp->query_vars['gd_region'] = '';
811
+        if (isset($wp->query_vars['gd_region'])) {
812
+                    $wp->query_vars['gd_region'] = '';
813
+        }
783 814
 
784
-        if (isset($wp->query_vars['gd_city']))
785
-            $wp->query_vars['gd_city'] = '';
815
+        if (isset($wp->query_vars['gd_city'])) {
816
+                    $wp->query_vars['gd_city'] = '';
817
+        }
786 818
     }
787 819
 }
788 820
 
@@ -894,8 +926,9 @@  discard block
 block discarded – undo
894 926
 function geodir_exclude_page_where($where)
895 927
 {
896 928
     global $wpdb;
897
-    if (is_admin())
898
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
929
+    if (is_admin()) {
930
+            $where .= " AND $wpdb->posts.post_status != 'virtual'";
931
+    }
899 932
 
900 933
     return $where;
901 934
 }
Please login to merge, or discard this patch.
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function geodir_register_taxonomies()
15 15
 {
16
-    $taxonomies = array();
17
-    $taxonomies = get_option('geodir_taxonomies');
18
-    // If custom taxonomies are present, register them
19
-    if (is_array($taxonomies)) {
20
-        // Sort taxonomies
21
-        ksort($taxonomies);
22
-
23
-        // Register taxonomies
24
-        foreach ($taxonomies as $taxonomy => $args) {
25
-            // Allow taxonomie names to be translated
26
-            if (!empty($args['args']['labels'])) {
27
-                foreach ($args['args']['labels'] as $key => $tax_label) {
28
-                    $args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
-                }
30
-            }
31
-
32
-            $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
-
34
-            if (taxonomy_exists($taxonomy)) {
35
-                $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
-            }
37
-        }
38
-    }
16
+	$taxonomies = array();
17
+	$taxonomies = get_option('geodir_taxonomies');
18
+	// If custom taxonomies are present, register them
19
+	if (is_array($taxonomies)) {
20
+		// Sort taxonomies
21
+		ksort($taxonomies);
22
+
23
+		// Register taxonomies
24
+		foreach ($taxonomies as $taxonomy => $args) {
25
+			// Allow taxonomie names to be translated
26
+			if (!empty($args['args']['labels'])) {
27
+				foreach ($args['args']['labels'] as $key => $tax_label) {
28
+					$args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
+				}
30
+			}
31
+
32
+			$tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
+
34
+			if (taxonomy_exists($taxonomy)) {
35
+				$tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
+			}
37
+		}
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function geodir_register_post_types() 
55 55
 {
56
-    global $wp_post_types;
56
+	global $wp_post_types;
57 57
 
58
-    $post_types = array();
59
-    $post_types = get_option('geodir_post_types');
58
+	$post_types = array();
59
+	$post_types = get_option('geodir_post_types');
60 60
 
61
-    // Register each post type if array of data is returned
62
-    if (is_array($post_types)):
61
+	// Register each post type if array of data is returned
62
+	if (is_array($post_types)):
63 63
 
64
-        foreach ($post_types as $post_type => $args):
64
+		foreach ($post_types as $post_type => $args):
65 65
 
66
-            if (!empty($args['rewrite']['slug'])) {
67
-                $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
-            }
69
-            $args = stripslashes_deep($args);
66
+			if (!empty($args['rewrite']['slug'])) {
67
+				$args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
+			}
69
+			$args = stripslashes_deep($args);
70 70
 
71
-            if (!empty($args['labels'])) {
72
-                foreach ($args['labels'] as $key => $val) {
73
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
-                }
75
-            }
71
+			if (!empty($args['labels'])) {
72
+				foreach ($args['labels'] as $key => $val) {
73
+					$args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
+				}
75
+			}
76 76
 
77
-            /**
78
-             * Filter post type args.
79
-             *
80
-             * @since 1.0.0
81
-             * @param string $args Post type args.
82
-             * @param string $post_type The post type.
83
-             */
84
-            $args = apply_filters('geodir_post_type_args', $args, $post_type);
77
+			/**
78
+			 * Filter post type args.
79
+			 *
80
+			 * @since 1.0.0
81
+			 * @param string $args Post type args.
82
+			 * @param string $post_type The post type.
83
+			 */
84
+			$args = apply_filters('geodir_post_type_args', $args, $post_type);
85 85
 
86
-            $post_type = register_post_type($post_type, $args);
86
+			$post_type = register_post_type($post_type, $args);
87 87
 
88
-        endforeach;
89
-    endif;
88
+		endforeach;
89
+	endif;
90 90
 }
91 91
 
92 92
 /**
@@ -100,72 +100,72 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_post_type_args_modify($args, $post_type)
102 102
 {
103
-    $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
103
+	$geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
104 104
 	if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
105 105
 
106
-        $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
106
+		$listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
107 107
 
108
-        if ($post_type == 'gd_place') {
109
-            if (array_key_exists('has_archive', $args))
110
-                $args['has_archive'] = $listing_slug;
108
+		if ($post_type == 'gd_place') {
109
+			if (array_key_exists('has_archive', $args))
110
+				$args['has_archive'] = $listing_slug;
111 111
 
112
-            if (array_key_exists('rewrite', $args)) {
113
-                if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
-            }
112
+			if (array_key_exists('rewrite', $args)) {
113
+				if (array_key_exists('slug', $args['rewrite']))
114
+					$args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
+			}
116 116
 
117
-            $geodir_post_types = get_option('geodir_post_types');
117
+			$geodir_post_types = get_option('geodir_post_types');
118 118
 
119
-            if (array_key_exists($post_type, $geodir_post_types)) {
119
+			if (array_key_exists($post_type, $geodir_post_types)) {
120 120
 
121
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
121
+				if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
+					$geodir_post_types[$post_type]['has_archive'] = $listing_slug;
123 123
 
124
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
124
+				if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
+					if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
+						$geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
127 127
 
128
-                update_option('geodir_post_types', $geodir_post_types);
128
+				update_option('geodir_post_types', $geodir_post_types);
129 129
 
130
-            }
130
+			}
131 131
 
132
-            $geodir_post_types = get_option('geodir_post_types');
132
+			$geodir_post_types = get_option('geodir_post_types');
133 133
 
134
-            /* --- update taxonomies (category) --- */
134
+			/* --- update taxonomies (category) --- */
135 135
 
136
-            $geodir_taxonomies = get_option('geodir_taxonomies');
136
+			$geodir_taxonomies = get_option('geodir_taxonomies');
137 137
 
138
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
138
+			if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
+				$geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
140 140
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
141
+				if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
+					if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
+						if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
+							$geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
145 145
 
146
-                update_option('geodir_taxonomies', $geodir_taxonomies);
146
+				update_option('geodir_taxonomies', $geodir_taxonomies);
147 147
 
148
-            }
148
+			}
149 149
 
150
-            /* --- update taxonomies (tags) --- */
151
-            $geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
150
+			/* --- update taxonomies (tags) --- */
151
+			$geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
+			if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
+				$geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
154 154
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
155
+				if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
+					if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
+						if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
+							$geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
159 159
 
160
-                update_option('geodir_taxonomies', $geodir_taxonomies_tag);
160
+				update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 161
 
162
-            }
162
+			}
163 163
 
164
-        }
164
+		}
165 165
 
166
-    }
166
+	}
167 167
 
168
-    return $args;
168
+	return $args;
169 169
 }
170 170
 
171 171
 /**
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function geodir_flush_rewrite_rules()
180 180
 {
181
-    global $wp_rewrite;
182
-    $wp_rewrite->flush_rules(false);
181
+	global $wp_rewrite;
182
+	$wp_rewrite->flush_rules(false);
183 183
 }
184 184
 
185 185
 /**
@@ -194,35 +194,35 @@  discard block
 block discarded – undo
194 194
  * @return array Rewrite rules.
195 195
  */
196 196
 function geodir_listing_rewrite_rules($rules) {
197
-    $newrules = array();
198
-    $taxonomies = get_option('geodir_taxonomies');
199
-    $detail_url_seprator = get_option('geodir_detailurl_separator');
197
+	$newrules = array();
198
+	$taxonomies = get_option('geodir_taxonomies');
199
+	$detail_url_seprator = get_option('geodir_detailurl_separator');
200 200
     
201 201
 	// create rules for post listing
202
-    if (is_array($taxonomies)):
203
-        foreach ($taxonomies as $taxonomy => $args):
204
-            $post_type = $args['object_type'];
205
-            $listing_slug = $args['listing_slug'];
206
-
207
-            if (strpos($taxonomy, 'tags')) {
208
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
-            } else {
211
-                // use this loop to add paging for details page comments paging
212
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
-            }
214
-        endforeach;
215
-    endif;
216
-
217
-    // create rules for location listing
218
-    $location_page = get_option('geodir_location_page');
202
+	if (is_array($taxonomies)):
203
+		foreach ($taxonomies as $taxonomy => $args):
204
+			$post_type = $args['object_type'];
205
+			$listing_slug = $args['listing_slug'];
206
+
207
+			if (strpos($taxonomy, 'tags')) {
208
+				$newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
+				$newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
+			} else {
211
+				// use this loop to add paging for details page comments paging
212
+				$newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
+			}
214
+		endforeach;
215
+	endif;
216
+
217
+	// create rules for location listing
218
+	$location_page = get_option('geodir_location_page');
219 219
 	
220
-    if($location_page) {
221
-        global $wpdb;
222
-        $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
-    }
224
-    if (!isset($location_prefix))
225
-        $location_prefix = 'location';
220
+	if($location_page) {
221
+		global $wpdb;
222
+		$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
+	}
224
+	if (!isset($location_prefix))
225
+		$location_prefix = 'location';
226 226
 
227 227
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
228 228
 	if ($location_manager) {
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
267 267
 	}
268 268
 
269
-    if ($location_page && function_exists('icl_object_id')) {
270
-        foreach(icl_get_languages('skip_missing=N') as $lang){
271
-            $alt_page_id = '';
272
-            $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
-            if($alt_page_id){
274
-                $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
269
+	if ($location_page && function_exists('icl_object_id')) {
270
+		foreach(icl_get_languages('skip_missing=N') as $lang){
271
+			$alt_page_id = '';
272
+			$alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
+			if($alt_page_id){
274
+				$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
275 275
 
276 276
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
277 277
 					$matches2 = '';
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
308 308
 					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
309 309
 				}
310
-            }
311
-        }
312
-    }
310
+			}
311
+		}
312
+	}
313 313
 
314
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
314
+	$newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
315 315
 
316
-    $rules = array_merge($newrules, $rules);
317
-    return $rules;
316
+	$rules = array_merge($newrules, $rules);
317
+	return $rules;
318 318
 }
319 319
 
320 320
 /**
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
  */
330 330
 function geodir_htaccess_contents($rules)
331 331
 {
332
-    global $wpdb;
333
-    $location_prefix = get_option('geodir_location_prefix');
334
-    // if location page slug changed then add redirect
335
-    if ($location_prefix == 'location') {
336
-        return $rules;
337
-    }
338
-    $my_content = <<<EOD
332
+	global $wpdb;
333
+	$location_prefix = get_option('geodir_location_prefix');
334
+	// if location page slug changed then add redirect
335
+	if ($location_prefix == 'location') {
336
+		return $rules;
337
+	}
338
+	$my_content = <<<EOD
339 339
 \n# BEGIN GeoDirectory Rules
340 340
 #Redirect 301 /location/ /$location_prefix/
341 341
 # END GeoDirectory Rules\n\n
342 342
 EOD;
343
-    return $my_content . $rules;
343
+	return $my_content . $rules;
344 344
 }
345 345
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
346 346
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function geodir_add_location_var($public_query_vars)
356 356
 {
357
-    $public_query_vars[] = 'gd_country';
358
-    $public_query_vars[] = 'gd_region';
359
-    $public_query_vars[] = 'gd_city';
360
-    return $public_query_vars;
357
+	$public_query_vars[] = 'gd_country';
358
+	$public_query_vars[] = 'gd_region';
359
+	$public_query_vars[] = 'gd_city';
360
+	return $public_query_vars;
361 361
 }
362 362
 
363 363
 /**
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
  */
371 371
 function geodir_add_geodir_page_var($public_query_vars)
372 372
 {
373
-    $public_query_vars[] = 'gd_is_geodir_page';
374
-    return $public_query_vars;
373
+	$public_query_vars[] = 'gd_is_geodir_page';
374
+	return $public_query_vars;
375 375
 }
376 376
 
377 377
 /**
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
  */
384 384
 function geodir_add_page_id_in_query_var()
385 385
 {
386
-    global $wp_query;
386
+	global $wp_query;
387 387
 
388
-    $page_id = $wp_query->get_queried_object_id();
388
+	$page_id = $wp_query->get_queried_object_id();
389 389
 
390
-    if (!get_query_var('page_id')) {
391
-        // fix for WP tags conflict with enfold theme
392
-        $theme_name = geodir_strtolower(wp_get_theme());
393
-        if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
-            return $wp_query;
395
-        }
396
-        $wp_query->set('page_id', $page_id);
397
-    }
390
+	if (!get_query_var('page_id')) {
391
+		// fix for WP tags conflict with enfold theme
392
+		$theme_name = geodir_strtolower(wp_get_theme());
393
+		if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
+			return $wp_query;
395
+		}
396
+		$wp_query->set('page_id', $page_id);
397
+	}
398 398
 
399
-    return $wp_query;
399
+	return $wp_query;
400 400
 }
401 401
 
402 402
 /**
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
 function geodir_set_location_var_in_session_in_core($wp) {
412 412
 	global $gd_session;
413 413
 	
414
-    // Fix for WPML removing page_id query var:
415
-    if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
-        global $wpdb;
417
-
418
-        $page_for_posts = get_option('page_for_posts');
419
-        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
-
421
-        if (function_exists('icl_object_id')) {
422
-            $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
-        }
424
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
425
-            $wp->query_vars['page_id'] = $real_page_id;
426
-        }
427
-    }
414
+	// Fix for WPML removing page_id query var:
415
+	if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
+		global $wpdb;
417
+
418
+		$page_for_posts = get_option('page_for_posts');
419
+		$real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
+
421
+		if (function_exists('icl_object_id')) {
422
+			$real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
+		}
424
+		if ($real_page_id && $real_page_id!=$page_for_posts) {
425
+			$wp->query_vars['page_id'] = $real_page_id;
426
+		}
427
+	}
428 428
 	
429 429
 	// Query Vars will have page_id parameter
430 430
 	// check if query var has page_id and that page id is location page
431
-    geodir_set_is_geodir_page($wp);
431
+	geodir_set_is_geodir_page($wp);
432 432
 	// if is GD homepage set the page ID
433 433
 	if (geodir_is_page('home')) {
434 434
 		$wp->query_vars['page_id'] = get_option('page_on_front');
@@ -437,118 +437,118 @@  discard block
 block discarded – undo
437 437
 	// The location url format (all or country_city or region_city or city).
438 438
 	$geodir_show_location_url = get_option('geodir_show_location_url');
439 439
 
440
-    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
-        $gd_country = '';
442
-        $gd_region = '';
443
-        $gd_city = '';
444
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
-            $gd_country = urldecode($wp->query_vars['gd_country']);
446
-
447
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
-            $gd_region = urldecode($wp->query_vars['gd_region']);
449
-
450
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
-            $gd_city = urldecode($wp->query_vars['gd_city']);
452
-
453
-        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
-            $default_location = geodir_get_default_location();
455
-
456
-            if (get_option('geodir_add_location_url')) {
457
-                if ($geodir_show_location_url != 'all') {
458
-                    if ($gd_region == '') {
459
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
460
-                            $gd_region = $gd_ses_region;
461
-                        else
462
-                            $gd_region = $default_location->region_slug;
463
-                    }
464
-
465
-                    if ($gd_city == '') {
466
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
467
-                            $gd_city = $gd_ses_city;
468
-                        else
469
-                            $gd_city = $default_location->city_slug;
470
-
471
-                        $base_location_link = geodir_get_location_link('base');
472
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
-                        exit();
474
-                    }
475
-                }
476
-            }
477
-
478
-            $args = array(
479
-                'what' => 'city',
480
-                'city_val' => $gd_city,
481
-                'region_val' => $gd_region,
482
-                'country_val' => $gd_country,
483
-                'country_column_name' => 'country_slug',
484
-                'region_column_name' => 'region_slug',
485
-                'city_column_name' => 'city_slug',
486
-                'location_link_part' => false,
487
-                'compare_operator' => ''
488
-            );
489
-
490
-            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
-            if (!empty($location_array)) {
492
-                $gd_session->set('gd_multi_location', 1);
493
-                $gd_session->set('gd_country', $gd_country);
494
-                $gd_session->set('gd_region', $gd_region);
495
-                $gd_session->set('gd_city', $gd_city);
440
+	if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
+		$gd_country = '';
442
+		$gd_region = '';
443
+		$gd_city = '';
444
+		if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
+			$gd_country = urldecode($wp->query_vars['gd_country']);
446
+
447
+		if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
+			$gd_region = urldecode($wp->query_vars['gd_region']);
449
+
450
+		if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
+			$gd_city = urldecode($wp->query_vars['gd_city']);
452
+
453
+		if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
+			$default_location = geodir_get_default_location();
455
+
456
+			if (get_option('geodir_add_location_url')) {
457
+				if ($geodir_show_location_url != 'all') {
458
+					if ($gd_region == '') {
459
+						if ($gd_ses_region = $gd_session->get('gd_region'))
460
+							$gd_region = $gd_ses_region;
461
+						else
462
+							$gd_region = $default_location->region_slug;
463
+					}
464
+
465
+					if ($gd_city == '') {
466
+						if ($gd_ses_city = $gd_session->get('gd_city'))
467
+							$gd_city = $gd_ses_city;
468
+						else
469
+							$gd_city = $default_location->city_slug;
470
+
471
+						$base_location_link = geodir_get_location_link('base');
472
+						wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
+						exit();
474
+					}
475
+				}
476
+			}
477
+
478
+			$args = array(
479
+				'what' => 'city',
480
+				'city_val' => $gd_city,
481
+				'region_val' => $gd_region,
482
+				'country_val' => $gd_country,
483
+				'country_column_name' => 'country_slug',
484
+				'region_column_name' => 'region_slug',
485
+				'city_column_name' => 'city_slug',
486
+				'location_link_part' => false,
487
+				'compare_operator' => ''
488
+			);
489
+
490
+			$location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
+			if (!empty($location_array)) {
492
+				$gd_session->set('gd_multi_location', 1);
493
+				$gd_session->set('gd_country', $gd_country);
494
+				$gd_session->set('gd_region', $gd_region);
495
+				$gd_session->set('gd_city', $gd_city);
496 496
                 
497 497
 				$wp->query_vars['gd_country'] = $gd_country;
498
-                $wp->query_vars['gd_region'] = $gd_region;
499
-                $wp->query_vars['gd_city'] = $gd_city;
500
-            } else {
501
-                $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
-            }
503
-        } else {
504
-            $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
-        }
506
-
507
-    } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
-        if (!is_admin()) {
509
-            $requested_post_type = $wp->query_vars['post_type'];
510
-            // check if this post type is geodirectory post types
511
-            $post_type_array = geodir_get_posttypes();
498
+				$wp->query_vars['gd_region'] = $gd_region;
499
+				$wp->query_vars['gd_city'] = $gd_city;
500
+			} else {
501
+				$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
+			}
503
+		} else {
504
+			$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
+		}
506
+
507
+	} else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
+		if (!is_admin()) {
509
+			$requested_post_type = $wp->query_vars['post_type'];
510
+			// check if this post type is geodirectory post types
511
+			$post_type_array = geodir_get_posttypes();
512 512
             
513 513
 			if (in_array($requested_post_type, $post_type_array)) {
514
-                // now u can apply geodirectory related manipulation.
515
-            }
516
-        }
517
-    } else {
518
-        // check if a geodirectory taxonomy is set
519
-        $gd_country = '';
520
-        $gd_region = '';
521
-        $gd_city = '';
514
+				// now u can apply geodirectory related manipulation.
515
+			}
516
+		}
517
+	} else {
518
+		// check if a geodirectory taxonomy is set
519
+		$gd_country = '';
520
+		$gd_region = '';
521
+		$gd_city = '';
522 522
         
523 523
 		$is_geodir_taxonomy = false;
524
-        $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
-        $is_geodir_location_found = false;
524
+		$is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
+		$is_geodir_location_found = false;
526 526
 		
527 527
 		$geodir_taxonomy = '';
528
-        $geodir_post_type = '';
529
-        $geodir_term = '';
530
-        $geodir_set_location_session = true;
531
-        $geodir_taxonomis = geodir_get_taxonomies('', true);
532
-
533
-        if(!empty($geodir_taxonomis)){
534
-            foreach ($geodir_taxonomis as $taxonomy) {
535
-                if (array_key_exists($taxonomy, $wp->query_vars)) {
536
-                    $is_geodir_taxonomy = true;
537
-                    $geodir_taxonomy = $taxonomy;
538
-                    $geodir_post_type = str_replace('category', '', $taxonomy);
539
-                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
-                    $geodir_term = $wp->query_vars[$geodir_taxonomy];
541
-                    break;
542
-                }
543
-            }
544
-        }
545
-
546
-        // now get an array of all terms seperated by '/'
547
-        $geodir_terms = explode('/', $geodir_term);
548
-        $geodir_last_term = end($geodir_terms);
549
-
550
-        if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
-            $wp->query_vars['post_type'] = $geodir_post_type;
528
+		$geodir_post_type = '';
529
+		$geodir_term = '';
530
+		$geodir_set_location_session = true;
531
+		$geodir_taxonomis = geodir_get_taxonomies('', true);
532
+
533
+		if(!empty($geodir_taxonomis)){
534
+			foreach ($geodir_taxonomis as $taxonomy) {
535
+				if (array_key_exists($taxonomy, $wp->query_vars)) {
536
+					$is_geodir_taxonomy = true;
537
+					$geodir_taxonomy = $taxonomy;
538
+					$geodir_post_type = str_replace('category', '', $taxonomy);
539
+					$geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
+					$geodir_term = $wp->query_vars[$geodir_taxonomy];
541
+					break;
542
+				}
543
+			}
544
+		}
545
+
546
+		// now get an array of all terms seperated by '/'
547
+		$geodir_terms = explode('/', $geodir_term);
548
+		$geodir_last_term = end($geodir_terms);
549
+
550
+		if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
+			$wp->query_vars['post_type'] = $geodir_post_type;
552 552
 
553 553
 			// now check if last term is a post of geodirectory post types
554 554
 			$geodir_post = get_posts(array(
@@ -597,196 +597,196 @@  discard block
 block discarded – undo
597 597
 				//return ;
598 598
 			}
599 599
 
600
-            $geodir_location_terms = '';
601
-            // if last term is not a post then check if last term is a term of the specific texonomy or not
602
-            if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
-                $is_geodir_taxonomy_term = true;
600
+			$geodir_location_terms = '';
601
+			// if last term is not a post then check if last term is a term of the specific texonomy or not
602
+			if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
+				$is_geodir_taxonomy_term = true;
604 604
 
605
-                $geodir_set_location_session = false;
606
-            }
605
+				$geodir_set_location_session = false;
606
+			}
607 607
 
608 608
 
609
-            // now check if there is location parts in the url or not
610
-            if (get_option('geodir_add_location_url')) {				
609
+			// now check if there is location parts in the url or not
610
+			if (get_option('geodir_add_location_url')) {				
611 611
 				$default_location = geodir_get_default_location();
612 612
                 
613 613
 				if ($geodir_show_location_url == 'all') {
614
-                    if (count($geodir_terms) >= 3) {
615
-                        $gd_country = urldecode($geodir_terms[0]);
616
-                        $gd_region = urldecode($geodir_terms[1]);
617
-                        $gd_city = urldecode($geodir_terms[2]);
618
-                    } else if (count($geodir_terms) >= 2) {
619
-                        $gd_country = urldecode($geodir_terms[0]);
620
-                        $gd_region = urldecode($geodir_terms[1]);
621
-                    } else if (count($geodir_terms) >= 1) {
622
-                        $gd_country = urldecode($geodir_terms[0]);
623
-                    }
624
-
625
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
-                        geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
-                        geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
-                    )
629
-                        $is_geodir_location_found = true;
630
-
631
-                    // if location has not been found for country , region and city then search for country and region only
632
-
633
-                    if (!$is_geodir_location_found) {
634
-                        $gd_city = '';
635
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
-                            geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
-                        )
638
-                            $is_geodir_location_found = true;
639
-
640
-                    }
641
-
642
-                    // if location has not been found for country , region  then search for country only
643
-                    if (!$is_geodir_location_found) {
644
-                        $gd_city = '';
645
-                        $gd_region = '';
646
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
-                            $is_geodir_location_found = true;
648
-                    }
649
-                } else if ($geodir_show_location_url == 'country_city') {
650
-                    if (count($geodir_terms) >= 2) {
651
-                        $gd_country = urldecode($geodir_terms[0]);
652
-                        $gd_city = urldecode($geodir_terms[1]);
653
-                    } else if (count($geodir_terms) >= 1) {
654
-                        $gd_country = urldecode($geodir_terms[0]);
655
-                    }
656
-
657
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
-                        $is_geodir_location_found = true;
659
-
660
-                    // if location has not been found for country and city  then search for country only
661
-                    if (!$is_geodir_location_found) {
662
-                        $gd_city = '';
614
+					if (count($geodir_terms) >= 3) {
615
+						$gd_country = urldecode($geodir_terms[0]);
616
+						$gd_region = urldecode($geodir_terms[1]);
617
+						$gd_city = urldecode($geodir_terms[2]);
618
+					} else if (count($geodir_terms) >= 2) {
619
+						$gd_country = urldecode($geodir_terms[0]);
620
+						$gd_region = urldecode($geodir_terms[1]);
621
+					} else if (count($geodir_terms) >= 1) {
622
+						$gd_country = urldecode($geodir_terms[0]);
623
+					}
624
+
625
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
+						geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
+						geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
+					)
629
+						$is_geodir_location_found = true;
630
+
631
+					// if location has not been found for country , region and city then search for country and region only
632
+
633
+					if (!$is_geodir_location_found) {
634
+						$gd_city = '';
635
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
+							geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
+						)
638
+							$is_geodir_location_found = true;
639
+
640
+					}
641
+
642
+					// if location has not been found for country , region  then search for country only
643
+					if (!$is_geodir_location_found) {
644
+						$gd_city = '';
645
+						$gd_region = '';
646
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
+							$is_geodir_location_found = true;
648
+					}
649
+				} else if ($geodir_show_location_url == 'country_city') {
650
+					if (count($geodir_terms) >= 2) {
651
+						$gd_country = urldecode($geodir_terms[0]);
652
+						$gd_city = urldecode($geodir_terms[1]);
653
+					} else if (count($geodir_terms) >= 1) {
654
+						$gd_country = urldecode($geodir_terms[0]);
655
+					}
656
+
657
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
+						$is_geodir_location_found = true;
659
+
660
+					// if location has not been found for country and city  then search for country only
661
+					if (!$is_geodir_location_found) {
662
+						$gd_city = '';
663 663
                         
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665
-                            $is_geodir_location_found = true;
666
-                    }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
668
-                    if (count($geodir_terms) >= 2) {
669
-                        $gd_region = urldecode($geodir_terms[0]);
670
-                        $gd_city = urldecode($geodir_terms[1]);
671
-                    } else if (count($geodir_terms) >= 1) {
672
-                        $gd_region = urldecode($geodir_terms[0]);
673
-                    }
674
-
675
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
-                        $is_geodir_location_found = true;
677
-
678
-                    // if location has not been found for region and city  then search for region only
679
-                    if (!$is_geodir_location_found) {
680
-                        $gd_city = '';
665
+							$is_geodir_location_found = true;
666
+					}
667
+				}  else if ($geodir_show_location_url == 'region_city') {
668
+					if (count($geodir_terms) >= 2) {
669
+						$gd_region = urldecode($geodir_terms[0]);
670
+						$gd_city = urldecode($geodir_terms[1]);
671
+					} else if (count($geodir_terms) >= 1) {
672
+						$gd_region = urldecode($geodir_terms[0]);
673
+					}
674
+
675
+					if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
+						$is_geodir_location_found = true;
677
+
678
+					// if location has not been found for region and city  then search for region only
679
+					if (!$is_geodir_location_found) {
680
+						$gd_city = '';
681 681
                         
682 682
 						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
683
-                            $is_geodir_location_found = true;
684
-                    }
685
-                } else {
686
-                    $gd_city = $geodir_terms[0];
687
-
688
-                    if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
-                        $is_geodir_location_found = true;
690
-                        $gd_region = $default_location->region_slug;
691
-                        $gd_country = $default_location->country_slug;
692
-                    }
693
-                }
694
-                // if locaton still not found then clear location related session variables
695
-                if ($is_geodir_location_found && $geodir_set_location_session) {
696
-                    $gd_session->set('gd_multi_location', 1);
697
-                    $gd_session->set('gd_country', $gd_country);
698
-                    $gd_session->set('gd_region', $gd_region);
699
-                    $gd_session->set('gd_city', $gd_city);
700
-                }
701
-
702
-                if ($geodir_show_location_url == 'all') {
683
+							$is_geodir_location_found = true;
684
+					}
685
+				} else {
686
+					$gd_city = $geodir_terms[0];
687
+
688
+					if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
+						$is_geodir_location_found = true;
690
+						$gd_region = $default_location->region_slug;
691
+						$gd_country = $default_location->country_slug;
692
+					}
693
+				}
694
+				// if locaton still not found then clear location related session variables
695
+				if ($is_geodir_location_found && $geodir_set_location_session) {
696
+					$gd_session->set('gd_multi_location', 1);
697
+					$gd_session->set('gd_country', $gd_country);
698
+					$gd_session->set('gd_region', $gd_region);
699
+					$gd_session->set('gd_city', $gd_city);
700
+				}
701
+
702
+				if ($geodir_show_location_url == 'all') {
703 703
 				} else if ($geodir_show_location_url == 'country_city') {
704 704
 					$gd_region = '';
705 705
 				} else if ($geodir_show_location_url == 'region_city') {
706 706
 					$gd_country = '';
707 707
 				} else {
708 708
 					$gd_country = '';
709
-                    $gd_region = '';
709
+					$gd_region = '';
710
+				}
711
+
712
+				if ($is_geodir_location_found) {
713
+					$wp->query_vars['gd_country'] = $gd_country;
714
+					$wp->query_vars['gd_region'] = $gd_region;
715
+					$wp->query_vars['gd_city'] = $gd_city;
716
+				} else {
717
+					$gd_country = '';
718
+					$gd_region = '';
719
+					$gd_city = '';
710 720
 				}
721
+			}
722
+
723
+			$wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
+			// eliminate location related terms from taxonomy term
725
+			if ($gd_country != '')
726
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
+
728
+			if ($gd_region != '')
729
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
+
731
+			if ($gd_city != '')
732
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
+
734
+
735
+			$wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
+			$wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
711 737
 
712
-                if ($is_geodir_location_found) {
713
-                    $wp->query_vars['gd_country'] = $gd_country;
714
-                    $wp->query_vars['gd_region'] = $gd_region;
715
-                    $wp->query_vars['gd_city'] = $gd_city;
716
-                } else {
717
-                    $gd_country = '';
718
-                    $gd_region = '';
719
-                    $gd_city = '';
720
-                }
721
-            }
722
-
723
-            $wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
-            // eliminate location related terms from taxonomy term
725
-            if ($gd_country != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
-
728
-            if ($gd_region != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
-
731
-            if ($gd_city != '')
732
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
-
734
-
735
-            $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
-            $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
737
-
738
-            $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
-
740
-            if ($wp->query_vars[$geodir_taxonomy] == '') {
741
-                unset($wp->query_vars[$geodir_taxonomy]);
742
-            } else {
743
-                if (!$is_geodir_taxonomy_term) {
744
-                    foreach ($wp->query_vars as $key => $vars) {
745
-                        unset($wp->query_vars[$key]);
746
-                    }
747
-                    $wp->query_vars['error'] = '404';
748
-                }
749
-            }
750
-        }
751
-    }
738
+			$wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
+
740
+			if ($wp->query_vars[$geodir_taxonomy] == '') {
741
+				unset($wp->query_vars[$geodir_taxonomy]);
742
+			} else {
743
+				if (!$is_geodir_taxonomy_term) {
744
+					foreach ($wp->query_vars as $key => $vars) {
745
+						unset($wp->query_vars[$key]);
746
+					}
747
+					$wp->query_vars['error'] = '404';
748
+				}
749
+			}
750
+		}
751
+	}
752 752
 	
753 753
 	// Unset location session if gd page and location not set.
754 754
 	if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
755 755
 		$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
756 756
 	}
757 757
 
758
-    if ($gd_session->get('gd_multi_location') == 1) {
759
-        $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
-        $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
-        $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
-    }
758
+	if ($gd_session->get('gd_multi_location') == 1) {
759
+		$wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
+		$wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
+		$wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
+	}
763 763
 
764
-    // now check if there is location parts in the url or not
765
-    if (get_option('geodir_add_location_url')) {        
764
+	// now check if there is location parts in the url or not
765
+	if (get_option('geodir_add_location_url')) {        
766 766
 		if ($geodir_show_location_url == 'all') {
767 767
 		} else if ($geodir_show_location_url == 'country_city') {
768 768
 			 if (isset($wp->query_vars['gd_region']))
769
-                $wp->query_vars['gd_region'] = '';
769
+				$wp->query_vars['gd_region'] = '';
770 770
 		} else if ($geodir_show_location_url == 'region_city') {
771 771
 			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
772
+				$wp->query_vars['gd_country'] = '';
773 773
 		} else {
774 774
 			if (isset($wp->query_vars['gd_country']))
775
-                $wp->query_vars['gd_country'] = '';
775
+				$wp->query_vars['gd_country'] = '';
776 776
 
777
-            if (isset($wp->query_vars['gd_region']))
778
-                $wp->query_vars['gd_region'] = '';
777
+			if (isset($wp->query_vars['gd_region']))
778
+				$wp->query_vars['gd_region'] = '';
779 779
 		}
780
-    } else {
781
-        if (isset($wp->query_vars['gd_country']))
782
-            $wp->query_vars['gd_country'] = '';
780
+	} else {
781
+		if (isset($wp->query_vars['gd_country']))
782
+			$wp->query_vars['gd_country'] = '';
783 783
 
784
-        if (isset($wp->query_vars['gd_region']))
785
-            $wp->query_vars['gd_region'] = '';
784
+		if (isset($wp->query_vars['gd_region']))
785
+			$wp->query_vars['gd_region'] = '';
786 786
 
787
-        if (isset($wp->query_vars['gd_city']))
788
-            $wp->query_vars['gd_city'] = '';
789
-    }
787
+		if (isset($wp->query_vars['gd_city']))
788
+			$wp->query_vars['gd_city'] = '';
789
+	}
790 790
 }
791 791
 
792 792
 /**
@@ -800,24 +800,24 @@  discard block
 block discarded – undo
800 800
  */
801 801
 function geodir_custom_post_status()
802 802
 {
803
-    // Vertual Page Status
804
-    register_post_status('virtual', array(
805
-        'label' => _x('Virtual', 'page', 'geodirectory'),
806
-        'public' => true,
807
-        'exclude_from_search' => true,
808
-        'show_in_admin_all_list' => true,
809
-        'show_in_admin_status_list' => true,
810
-        'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
-    ));
812
-
813
-    /**
814
-     * Called after we register the custom post status 'Virtual'.
815
-     *
816
-     * Can be use to add more post statuses.
817
-     *
818
-     * @since 1.0.0
819
-     */
820
-    do_action('geodir_custom_post_status');
803
+	// Vertual Page Status
804
+	register_post_status('virtual', array(
805
+		'label' => _x('Virtual', 'page', 'geodirectory'),
806
+		'public' => true,
807
+		'exclude_from_search' => true,
808
+		'show_in_admin_all_list' => true,
809
+		'show_in_admin_status_list' => true,
810
+		'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
+	));
812
+
813
+	/**
814
+	 * Called after we register the custom post status 'Virtual'.
815
+	 *
816
+	 * Can be use to add more post statuses.
817
+	 *
818
+	 * @since 1.0.0
819
+	 */
820
+	do_action('geodir_custom_post_status');
821 821
 }
822 822
 
823 823
 /**
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
  */
833 833
 function geodir_get_term_link($termlink, $term, $taxonomy)
834 834
 {
835
-    return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
835
+	return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
836 836
 }
837 837
 
838 838
 /**
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
  */
847 847
 function geodir_get_posttype_link($link, $post_type)
848 848
 {
849
-    return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
849
+	return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
850 850
 }
851 851
 
852 852
 /**
@@ -861,13 +861,13 @@  discard block
 block discarded – undo
861 861
  */
862 862
 function exclude_from_wp_list_pages($exclude_array)
863 863
 {
864
-    $pages_ids = array();
865
-    $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
-    foreach ($pages_array as $page) {
867
-        $pages_ids[] = $page->ID;
868
-    }
869
-    $exclude_array = $exclude_array + $pages_ids;
870
-    return $exclude_array;
864
+	$pages_ids = array();
865
+	$pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
+	foreach ($pages_array as $page) {
867
+		$pages_ids[] = $page->ID;
868
+	}
869
+	$exclude_array = $exclude_array + $pages_ids;
870
+	return $exclude_array;
871 871
 }
872 872
 
873 873
 /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
  */
881 881
 function geodir_exclude_page($query)
882 882
 {
883
-    add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
-    return $query;
883
+	add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
+	return $query;
885 885
 }
886 886
 
887 887
 /**
@@ -896,9 +896,9 @@  discard block
 block discarded – undo
896 896
  */
897 897
 function geodir_exclude_page_where($where)
898 898
 {
899
-    global $wpdb;
900
-    if (is_admin())
901
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
899
+	global $wpdb;
900
+	if (is_admin())
901
+		$where .= " AND $wpdb->posts.post_status != 'virtual'";
902 902
 
903
-    return $where;
903
+	return $where;
904 904
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 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
 
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 
136 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 146
                 update_option('geodir_taxonomies', $geodir_taxonomies);
147 147
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
             /* --- update taxonomies (tags) --- */
151 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';
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 160
                 update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 161
 
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
             $listing_slug = $args['listing_slug'];
206 206
 
207 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]';
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 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
     }
@@ -247,30 +247,30 @@  discard block
 block discarded – undo
247 247
 		
248 248
 		if ($matches2) {
249 249
 			if ($neighbourhood_active) {
250
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
250
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
251 251
 			}
252
-			$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
252
+			$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
253 253
 		} else {
254 254
 			if ($neighbourhood_active) {
255
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
255
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
256 256
 			}
257 257
 		}
258 258
 		
259
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]';
259
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]';
260 260
 	} else { // country/region/city
261 261
 		if ($neighbourhood_active) {
262
-			$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
262
+			$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
263 263
 		}
264
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
265
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]';
266
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
264
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
265
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]';
266
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]';
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)) {
@@ -289,29 +289,29 @@  discard block
 block discarded – undo
289 289
 					
290 290
 					if ($matches2) {
291 291
 						if ($neighbourhood_active) {
292
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
292
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
293 293
 						}
294
-						$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
294
+						$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
295 295
 					} else {
296 296
 						if ($neighbourhood_active) {
297
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
297
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
298 298
 						}
299 299
 					}
300 300
 					
301
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]';
301
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]';
302 302
 				} else { // country/region/city
303 303
 					if ($neighbourhood_active) {
304
-						$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
304
+						$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
305 305
 					}
306
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
307
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
308
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
306
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
307
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]';
308
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]';
309 309
 				}
310 310
             }
311 311
         }
312 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 316
     $rules = array_merge($newrules, $rules);
317 317
     return $rules;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
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
 
@@ -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
     }
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                             $gd_city = $default_location->city_slug;
470 470
 
471 471
                         $base_location_link = geodir_get_location_link('base');
472
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
472
+                        wp_redirect($base_location_link.'/'.$gd_country.'/'.$gd_region.'/'.$gd_city);
473 473
                         exit();
474 474
                     }
475 475
                 }
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
         $geodir_set_location_session = true;
531 531
         $geodir_taxonomis = geodir_get_taxonomies('', true);
532 532
 
533
-        if(!empty($geodir_taxonomis)){
533
+        if (!empty($geodir_taxonomis)) {
534 534
             foreach ($geodir_taxonomis as $taxonomy) {
535 535
                 if (array_key_exists($taxonomy, $wp->query_vars)) {
536 536
                     $is_geodir_taxonomy = true;
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 				}
588 588
 
589 589
 
590
-				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
590
+				$geodir_term = str_replace('/'.$geodir_last_term, '', $geodir_term, $post_title_replace_count);
591 591
 				if (!$post_title_replace_count)
592 592
 					$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
593 593
 				$geodir_terms = explode('/', $geodir_term);
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665 665
                             $is_geodir_location_found = true;
666 666
                     }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
667
+                } else if ($geodir_show_location_url == 'region_city') {
668 668
                     if (count($geodir_terms) >= 2) {
669 669
                         $gd_region = urldecode($geodir_terms[0]);
670 670
                         $gd_city = urldecode($geodir_terms[1]);
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
             $wp->query_vars[$geodir_taxonomy] = $geodir_term;
724 724
             // eliminate location related terms from taxonomy term
725 725
             if ($gd_country != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
726
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_country).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
727 727
 
728 728
             if ($gd_region != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
729
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_region).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
730 730
 
731 731
             if ($gd_city != '')
732
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
732
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_city).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
733 733
 
734 734
 
735 735
             $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
Please login to merge, or discard this patch.
geodirectory-functions/general_functions.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
  * @global string $plugin_prefix Geodirectory plugin table prefix.
1733 1733
  * @global string $table_prefix WordPress Database Table prefix.
1734 1734
  * @param array $query_args The query array.
1735
- * @param  int|bool $count_only If true returns listings count only, otherwise returns array
1735
+ * @param  boolean $count_only If true returns listings count only, otherwise returns array
1736 1736
  * @return mixed Result object.
1737 1737
  */
1738 1738
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
  *
3265 3265
  * @since 1.0.0
3266 3266
  * @package GeoDirectory
3267
- * @return bool
3267
+ * @return null|boolean
3268 3268
  */
3269 3269
 function geodir_term_review_count_force_update($new_status, $old_status='', $post='')
3270 3270
 {
Please login to merge, or discard this patch.
Braces   +271 added lines, -186 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
 
@@ -67,7 +69,9 @@  discard block
 block discarded – undo
67 69
 {
68 70
     $active_plugins = get_option('active_plugins');
69 71
     foreach ($active_plugins as $key => $active_plugin) {
70
-        if (strstr($active_plugin, $plugin)) return true;
72
+        if (strstr($active_plugin, $plugin)) {
73
+        	return true;
74
+        }
71 75
     }
72 76
     return false;
73 77
 }
@@ -118,12 +122,25 @@  discard block
 block discarded – undo
118 122
  */
119 123
 function geodir_getlink($url, $params = array(), $use_existing_arguments = false)
120 124
 {
121
-    if ($use_existing_arguments) $params = $params + $_GET;
122
-    if (!$params) return $url;
125
+    if ($use_existing_arguments) {
126
+    	$params = $params + $_GET;
127
+    }
128
+    if (!$params) {
129
+    	return $url;
130
+    }
123 131
     $link = $url;
124
-    if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
-    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
126
-    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
132
+    if (strpos($link, '?') === false) {
133
+    	$link .= '?';
134
+    }
135
+    //If there is no '?' add one at the end
136
+    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) {
137
+    	$link .= '&amp;';
138
+    }
139
+    //If there is no '&' at the END, add one.
140
+    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) {
141
+    	$link .= '&';
142
+    }
143
+    //If there is no '&' at the END, add one.
127 144
 
128 145
     $params_arr = array();
129 146
     foreach ($params as $key => $value) {
@@ -161,9 +178,10 @@  discard block
 block discarded – undo
161 178
         $add_listing_link = get_page_link(geodir_add_listing_page_id());
162 179
 
163 180
         return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
-    } else
165
-        return get_bloginfo('url');
166
-}
181
+    } else {
182
+            return get_bloginfo('url');
183
+    }
184
+    }
167 185
 
168 186
 /**
169 187
  * Get the current page URL.
@@ -268,24 +286,28 @@  discard block
 block discarded – undo
268 286
         case 'preview':
269 287
             if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270 288
                 && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
-            )
272
-                return true;
289
+            ) {
290
+                            return true;
291
+            }
273 292
             break;
274 293
         case 'listing-success':
275
-            if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
-                return true;
294
+            if (is_page() && get_query_var('page_id') == geodir_success_page_id()) {
295
+                            return true;
296
+            }
277 297
             break;
278 298
         case 'detail':
279 299
             $post_type = get_query_var('post_type');
280 300
             if(is_array($post_type)){$post_type = reset($post_type);}
281
-            if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
-                return true;
301
+            if (is_single() && in_array($post_type, geodir_get_posttypes())) {
302
+                            return true;
303
+            }
283 304
             break;
284 305
         case 'pt':
285 306
             $post_type = get_query_var('post_type');
286 307
             if(is_array($post_type)){$post_type = reset($post_type);}
287
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
-                return true;
308
+            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) {
309
+                            return true;
310
+            }
289 311
 
290 312
             break;
291 313
         case 'listing':
@@ -296,23 +318,27 @@  discard block
 block discarded – undo
296 318
             }
297 319
             $post_type = get_query_var('post_type');
298 320
             if(is_array($post_type)){$post_type = reset($post_type);}
299
-            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
-                return true;
321
+            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) {
322
+                            return true;
323
+            }
301 324
 
302 325
             break;
303 326
         case 'home':
304 327
 
305
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
-                return true;
328
+            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) {
329
+                            return true;
330
+            }
307 331
 
308 332
             break;
309 333
         case 'location':
310
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
-                return true;
334
+            if (is_page() && get_query_var('page_id') == geodir_location_page_id()) {
335
+                            return true;
336
+            }
312 337
             break;
313 338
         case 'author':
314
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
-                return true;
339
+            if (is_author() && isset($_REQUEST['geodir_dashbord'])) {
340
+                            return true;
341
+            }
316 342
 			
317 343
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
318 344
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
@@ -321,24 +347,29 @@  discard block
 block discarded – undo
321 347
 			}
322 348
             break;
323 349
         case 'search':
324
-            if (is_search() && isset($_REQUEST['geodir_search']))
325
-                return true;
350
+            if (is_search() && isset($_REQUEST['geodir_search'])) {
351
+                            return true;
352
+            }
326 353
             break;
327 354
         case 'info':
328
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
-                return true;
355
+            if (is_page() && get_query_var('page_id') == geodir_info_page_id()) {
356
+                            return true;
357
+            }
330 358
             break;
331 359
         case 'login':
332
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
-                return true;
360
+            if (is_page() && get_query_var('page_id') == geodir_login_page_id()) {
361
+                            return true;
362
+            }
334 363
             break;
335 364
         case 'checkout':
336
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
-                return true;
365
+            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) {
366
+                            return true;
367
+            }
338 368
             break;
339 369
         case 'invoices':
340
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
-                return true;
370
+            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) {
371
+                            return true;
372
+            }
342 373
             break;
343 374
         default:
344 375
             return false;
@@ -366,8 +397,9 @@  discard block
 block discarded – undo
366 397
         //$wp->query_vars['gd_is_geodir_page'] = false;
367 398
         //print_r()
368 399
         if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
-            if (get_option('geodir_set_as_home'))
370
-                $wp->query_vars['gd_is_geodir_page'] = true;
400
+            if (get_option('geodir_set_as_home')) {
401
+                            $wp->query_vars['gd_is_geodir_page'] = true;
402
+            }
371 403
             if(geodir_is_page('home')){
372 404
                 $wp->query_vars['gd_is_geodir_page'] = true;
373 405
             }
@@ -386,8 +418,9 @@  discard block
 block discarded – undo
386 418
                 || $wp->query_vars['page_id'] == geodir_login_page_id()
387 419
                 || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388 420
                 || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
-            )
390
-                $wp->query_vars['gd_is_geodir_page'] = true;
421
+            ) {
422
+                            $wp->query_vars['gd_is_geodir_page'] = true;
423
+            }
391 424
         }
392 425
 
393 426
         if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
@@ -404,8 +437,9 @@  discard block
 block discarded – undo
404 437
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405 438
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406 439
                 )
407
-            )
408
-                $wp->query_vars['gd_is_geodir_page'] = true;
440
+            ) {
441
+                            $wp->query_vars['gd_is_geodir_page'] = true;
442
+            }
409 443
         }
410 444
 
411 445
 
@@ -431,12 +465,14 @@  discard block
 block discarded – undo
431 465
 
432 466
         }
433 467
 
434
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
-            $wp->query_vars['gd_is_geodir_page'] = true;
468
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) {
469
+                    $wp->query_vars['gd_is_geodir_page'] = true;
470
+        }
436 471
 
437 472
 
438
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
-            $wp->query_vars['gd_is_geodir_page'] = true;
473
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) {
474
+                    $wp->query_vars['gd_is_geodir_page'] = true;
475
+        }
440 476
 
441 477
 
442 478
 //check if homepage
@@ -466,11 +502,12 @@  discard block
 block discarded – undo
466 502
 function geodir_is_geodir_page()
467 503
 {
468 504
     global $wp;
469
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
-        return true;
471
-    else
472
-        return false;
473
-}
505
+    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) {
506
+            return true;
507
+    } else {
508
+            return false;
509
+    }
510
+    }
474 511
 
475 512
 if (!function_exists('geodir_get_imagesize')) {
476 513
     /**
@@ -848,20 +885,16 @@  discard block
 block discarded – undo
848 885
             $subject .= ' - ADMIN BCC COPY';
849 886
             $admin_bcc = true;
850 887
 
851
-        }
852
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
888
+        } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
853 889
             $subject .= ' - ADMIN BCC COPY';
854 890
             $admin_bcc = true;
855
-        }
856
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
891
+        } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
857 892
             $subject .= ' - ADMIN BCC COPY';
858 893
             $admin_bcc = true;
859
-        }
860
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
894
+        } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
861 895
             $subject .= ' - ADMIN BCC COPY';
862 896
             $admin_bcc = true;
863
-        }
864
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
897
+        } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
865 898
             $subject .= ' - ADMIN BCC COPY';
866 899
             $admin_bcc = true;
867 900
         }
@@ -1030,21 +1063,24 @@  discard block
 block discarded – undo
1030 1063
             $is_location_last = '';
1031 1064
             $is_taxonomy_last = '';
1032 1065
             $breadcrumb .= '<li>';
1033
-            if (get_query_var($gd_post_type . 'category'))
1034
-                $gd_taxonomy = $gd_post_type . 'category';
1035
-            elseif (get_query_var($gd_post_type . '_tags'))
1036
-                $gd_taxonomy = $gd_post_type . '_tags';
1066
+            if (get_query_var($gd_post_type . 'category')) {
1067
+                            $gd_taxonomy = $gd_post_type . 'category';
1068
+            } elseif (get_query_var($gd_post_type . '_tags')) {
1069
+                            $gd_taxonomy = $gd_post_type . '_tags';
1070
+            }
1037 1071
 
1038 1072
             $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1039
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
1040
-                $is_location_last = false;
1041
-            else
1042
-                $is_location_last = true;
1043
-
1044
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
1045
-                $is_taxonomy_last = true;
1046
-            else
1047
-                $is_taxonomy_last = false;
1073
+            if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
1074
+                            $is_location_last = false;
1075
+            } else {
1076
+                            $is_location_last = true;
1077
+            }
1078
+
1079
+            if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
1080
+                            $is_taxonomy_last = true;
1081
+            } else {
1082
+                            $is_taxonomy_last = false;
1083
+            }
1048 1084
 
1049 1085
             if (!empty($location_terms)) {
1050 1086
                 $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
@@ -1126,8 +1162,9 @@  discard block
 block discarded – undo
1126 1162
                 {
1127 1163
                     if (get_query_var($gd_post_type . '_tags')) {
1128 1164
                         $cat_link = $listing_link . 'tags/';
1129
-                    } else
1130
-                        $cat_link = $listing_link;
1165
+                    } else {
1166
+                                            $cat_link = $listing_link;
1167
+                    }
1131 1168
 
1132 1169
                     foreach ($location_terms as $key => $location_term) {
1133 1170
                         if ($location_manager && in_array($key, $hide_url_part)) {
@@ -1154,9 +1191,9 @@  discard block
 block discarded – undo
1154 1191
                             $term_link_text = geodir_ucwords(urldecode($term_link_text));
1155 1192
                         }
1156 1193
 
1157
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1158
-                            $breadcrumb .= $separator . $term_link_text;
1159
-                        else {
1194
+                        if ($term_index == count($term_array) && $is_taxonomy_last) {
1195
+                                                    $breadcrumb .= $separator . $term_link_text;
1196
+                        } else {
1160 1197
                             $cat_link .= $term . '/';
1161 1198
                             $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1162 1199
                         }
@@ -1167,8 +1204,9 @@  discard block
 block discarded – undo
1167 1204
 
1168 1205
             }
1169 1206
 
1170
-            if (geodir_is_page('detail'))
1171
-                $breadcrumb .= $separator . get_the_title();
1207
+            if (geodir_is_page('detail')) {
1208
+                            $breadcrumb .= $separator . get_the_title();
1209
+            }
1172 1210
 
1173 1211
             $breadcrumb .= '</li>';
1174 1212
 
@@ -1205,8 +1243,9 @@  discard block
 block discarded – undo
1205 1243
 
1206 1244
                 $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1207 1245
                 $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1208
-            } else
1209
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1246
+            } else {
1247
+                            $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1248
+            }
1210 1249
 
1211 1250
             $breadcrumb .= '</li>';
1212 1251
         } elseif (is_category() || is_single()) {
@@ -1285,12 +1324,14 @@  discard block
 block discarded – undo
1285 1324
     function geodir_allow_wpadmin()
1286 1325
     {
1287 1326
         global $wpdb;
1288
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1327
+        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) {
1328
+        	// checking action in request to allow ajax request go through
1289 1329
         {
1290 1330
             if (current_user_can('manage_options')) {
1291 1331
             } else {
1292 1332
 
1293
-                wp_redirect(home_url());
1333
+                wp_redirect(home_url());
1334
+        }
1294 1335
                 exit;
1295 1336
             }
1296 1337
 
@@ -1338,8 +1379,9 @@  discard block
 block discarded – undo
1338 1379
     $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1339 1380
 
1340 1381
     $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1341
-    if ($upload['error'])
1342
-        return new WP_Error('upload_dir_error', $upload['error']);
1382
+    if ($upload['error']) {
1383
+            return new WP_Error('upload_dir_error', $upload['error']);
1384
+    }
1343 1385
 
1344 1386
 
1345 1387
     sleep(0.3);// if multiple remote file this can cause the remote server to timeout so we add a slight delay
@@ -1361,11 +1403,9 @@  discard block
 block discarded – undo
1361 1403
     // make sure the fetch was successful
1362 1404
     elseif ($headers['response']['code'] != '200') {
1363 1405
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1364
-    }
1365
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1406
+    } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1366 1407
         $log_message =  __('Remote file is incorrect size', 'geodirectory');
1367
-    }
1368
-    elseif (0 == $filesize) {
1408
+    } elseif (0 == $filesize) {
1369 1409
         $log_message = __('Zero size file downloaded', 'geodirectory');
1370 1410
     }
1371 1411
 
@@ -1377,10 +1417,11 @@  discard block
 block discarded – undo
1377 1417
 
1378 1418
     if ($dummy && $add_to_cache && is_array($upload)) {
1379 1419
         $images = get_transient('cached_dummy_images');
1380
-        if(is_array($images))
1381
-            $images[$key] = $upload;
1382
-        else
1383
-            $images = array($key => $upload);
1420
+        if(is_array($images)) {
1421
+                    $images[$key] = $upload;
1422
+        } else {
1423
+                    $images = array($key => $upload);
1424
+        }
1384 1425
 
1385 1426
         //setting the cache using the WP Transient API
1386 1427
         set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
@@ -1427,10 +1468,11 @@  discard block
 block discarded – undo
1427 1468
 function geodir_dummy_folder_exists()
1428 1469
 {
1429 1470
     $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1430
-    if (!is_dir($path))
1431
-        return false;
1432
-    else
1433
-        return true;
1471
+    if (!is_dir($path)) {
1472
+            return false;
1473
+    } else {
1474
+            return true;
1475
+    }
1434 1476
 
1435 1477
 }
1436 1478
 
@@ -1701,12 +1743,10 @@  discard block
 block discarded – undo
1701 1743
         if ($message_type == 'registration' && get_option('bcc_new_user')) {
1702 1744
             $subject .= ' - ADMIN BCC COPY';
1703 1745
             $admin_bcc = true;
1704
-        }
1705
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1746
+        } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1706 1747
             $subject .= ' - ADMIN BCC COPY';
1707 1748
             $admin_bcc = true;
1708
-        }
1709
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1749
+        } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1710 1750
             $subject .= ' - ADMIN BCC COPY';
1711 1751
             $admin_bcc = true;
1712 1752
         }
@@ -1750,7 +1790,9 @@  discard block
 block discarded – undo
1750 1790
         $res = array();
1751 1791
         foreach ($ids_array as $id) {
1752 1792
             $xlat = icl_object_id($id, $type, false);
1753
-            if (!is_null($xlat)) $res[] = $xlat;
1793
+            if (!is_null($xlat)) {
1794
+            	$res[] = $xlat;
1795
+            }
1754 1796
         }
1755 1797
         return $res;
1756 1798
     } else {
@@ -2091,8 +2133,9 @@  discard block
 block discarded – undo
2091 2133
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2092 2134
 
2093 2135
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2094
-        if ( !$page )
2095
-            $page = 1;
2136
+        if ( !$page ) {
2137
+                    $page = 1;
2138
+        }
2096 2139
 
2097 2140
         $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2098 2141
 
@@ -2418,7 +2461,7 @@  discard block
 block discarded – undo
2418 2461
     $home_url = str_replace("www.", "", $home_url);
2419 2462
     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')) ) {
2420 2463
         return true;
2421
-    }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')){
2464
+    } 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')){
2422 2465
         return true;
2423 2466
     } else {
2424 2467
         return false;
@@ -2504,9 +2547,9 @@  discard block
 block discarded – undo
2504 2547
     $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2505 2548
     if(!empty($gd_post_type)){
2506 2549
         $default_post_type = $gd_post_type;
2507
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2550
+    } elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2508 2551
         $default_post_type = $instance['default_post_type'];
2509
-    }else{
2552
+    } else{
2510 2553
         $all_gd_post_type = geodir_get_posttypes();
2511 2554
         $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2512 2555
     }
@@ -2930,8 +2973,9 @@  discard block
 block discarded – undo
2930 2973
                         $name = $postobj->labels->name;
2931 2974
 
2932 2975
                         $selected = '';
2933
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2934
-                            $selected = 'selected="selected"';
2976
+                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
2977
+                                                    $selected = 'selected="selected"';
2978
+                        }
2935 2979
 
2936 2980
                         /**
2937 2981
                          * Filter add listing link.
@@ -3398,8 +3442,9 @@  discard block
 block discarded – undo
3398 3442
             $geodir_is_widget_listing = false;
3399 3443
 
3400 3444
             $GLOBALS['post'] = $current_post;
3401
-            if (!empty($current_post))
3402
-                setup_postdata($current_post);
3445
+            if (!empty($current_post)) {
3446
+                            setup_postdata($current_post);
3447
+            }
3403 3448
             $map_jason = $current_map_jason;
3404 3449
             $map_canvas_arr = $current_map_canvas_arr;
3405 3450
             ?>
@@ -3777,11 +3822,15 @@  discard block
 block discarded – undo
3777 3822
 
3778 3823
     $language_file = geodir_plugin_path() . '/db-language.php';
3779 3824
 
3780
-    if(is_file($language_file) && !is_writable($language_file))
3781
-        return false; // Not possible to create.
3825
+    if(is_file($language_file) && !is_writable($language_file)) {
3826
+            return false;
3827
+    }
3828
+    // Not possible to create.
3782 3829
 
3783
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3784
-        return false; // Not possible to create.
3830
+    if(!is_file($language_file) && !is_writable(dirname($language_file))) {
3831
+            return false;
3832
+    }
3833
+    // Not possible to create.
3785 3834
 
3786 3835
     $contents_strings = array();
3787 3836
 
@@ -3824,8 +3873,10 @@  discard block
 block discarded – undo
3824 3873
 
3825 3874
     $contents .= implode(PHP_EOL, $contents_foot);
3826 3875
 
3827
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3828
-        return false; // Failure; could not write file.
3876
+    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) {
3877
+            return false;
3878
+    }
3879
+    // Failure; could not write file.
3829 3880
 
3830 3881
     return true;
3831 3882
 }
@@ -3851,23 +3902,29 @@  discard block
 block discarded – undo
3851 3902
 
3852 3903
     if (!empty($rows)) {
3853 3904
         foreach($rows as $row) {
3854
-            if (!empty($row->admin_title))
3855
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3905
+            if (!empty($row->admin_title)) {
3906
+                            $translation_texts[] = stripslashes_deep($row->admin_title);
3907
+            }
3856 3908
 			
3857
-            if (!empty($row->admin_desc))
3858
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3909
+            if (!empty($row->admin_desc)) {
3910
+                            $translation_texts[] = stripslashes_deep($row->admin_desc);
3911
+            }
3859 3912
 
3860
-            if (!empty($row->site_title))
3861
-                $translation_texts[] = stripslashes_deep($row->site_title);
3913
+            if (!empty($row->site_title)) {
3914
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3915
+            }
3862 3916
 
3863
-            if (!empty($row->clabels))
3864
-                $translation_texts[] = stripslashes_deep($row->clabels);
3917
+            if (!empty($row->clabels)) {
3918
+                            $translation_texts[] = stripslashes_deep($row->clabels);
3919
+            }
3865 3920
 
3866
-            if (!empty($row->required_msg))
3867
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3921
+            if (!empty($row->required_msg)) {
3922
+                            $translation_texts[] = stripslashes_deep($row->required_msg);
3923
+            }
3868 3924
 			
3869
-			if (!empty($row->default_value))
3870
-                $translation_texts[] = stripslashes_deep($row->default_value);
3925
+			if (!empty($row->default_value)) {
3926
+			                $translation_texts[] = stripslashes_deep($row->default_value);
3927
+			}
3871 3928
 			
3872 3929
 			if (!empty($row->option_values)) {
3873 3930
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3889,14 +3946,17 @@  discard block
 block discarded – undo
3889 3946
 
3890 3947
     if (!empty($rows)) {
3891 3948
         foreach($rows as $row) {
3892
-            if (!empty($row->site_title))
3893
-                $translation_texts[] = stripslashes_deep($row->site_title);
3949
+            if (!empty($row->site_title)) {
3950
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3951
+            }
3894 3952
 
3895
-            if (!empty($row->asc_title))
3896
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3953
+            if (!empty($row->asc_title)) {
3954
+                            $translation_texts[] = stripslashes_deep($row->asc_title);
3955
+            }
3897 3956
 
3898
-            if (!empty($row->desc_title))
3899
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3957
+            if (!empty($row->desc_title)) {
3958
+                            $translation_texts[] = stripslashes_deep($row->desc_title);
3959
+            }
3900 3960
         }
3901 3961
     }
3902 3962
 	
@@ -3907,14 +3967,17 @@  discard block
 block discarded – undo
3907 3967
 
3908 3968
 		if (!empty($rows)) {
3909 3969
 			foreach($rows as $row) {
3910
-				if (!empty($row->field_site_name))
3911
-					$translation_texts[] = stripslashes_deep($row->field_site_name);
3970
+				if (!empty($row->field_site_name)) {
3971
+									$translation_texts[] = stripslashes_deep($row->field_site_name);
3972
+				}
3912 3973
 
3913
-				if (!empty($row->front_search_title))
3914
-					$translation_texts[] = stripslashes_deep($row->front_search_title);
3974
+				if (!empty($row->front_search_title)) {
3975
+									$translation_texts[] = stripslashes_deep($row->front_search_title);
3976
+				}
3915 3977
 
3916
-				if (!empty($row->field_desc))
3917
-					$translation_texts[] = stripslashes_deep($row->field_desc);
3978
+				if (!empty($row->field_desc)) {
3979
+									$translation_texts[] = stripslashes_deep($row->field_desc);
3980
+				}
3918 3981
 			}
3919 3982
 		}
3920 3983
 	}
@@ -4505,38 +4568,54 @@  discard block
 block discarded – undo
4505 4568
             $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4506 4569
 
4507 4570
             if (!empty($labels)) {
4508
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4509
-                    $translation_texts[] = $labels['name'];
4510
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4511
-                    $translation_texts[] = $labels['singular_name'];
4512
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4513
-                    $translation_texts[] = $labels['add_new'];
4514
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4515
-                    $translation_texts[] = $labels['add_new_item'];
4516
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4517
-                    $translation_texts[] = $labels['edit_item'];
4518
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4519
-                    $translation_texts[] = $labels['new_item'];
4520
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4521
-                    $translation_texts[] = $labels['view_item'];
4522
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4523
-                    $translation_texts[] = $labels['search_items'];
4524
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4525
-                    $translation_texts[] = $labels['not_found'];
4526
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4527
-                    $translation_texts[] = $labels['not_found_in_trash'];
4528
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4529
-                    $translation_texts[] = $labels['label_post_profile'];
4530
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4531
-                    $translation_texts[] = $labels['label_post_info'];
4532
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4533
-                    $translation_texts[] = $labels['label_post_images'];
4534
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4535
-                    $translation_texts[] = $labels['label_post_map'];
4536
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4537
-                    $translation_texts[] = $labels['label_reviews'];
4538
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4539
-                    $translation_texts[] = $labels['label_related_listing'];
4571
+                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
4572
+                                    $translation_texts[] = $labels['name'];
4573
+                }
4574
+                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
4575
+                                    $translation_texts[] = $labels['singular_name'];
4576
+                }
4577
+                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
4578
+                                    $translation_texts[] = $labels['add_new'];
4579
+                }
4580
+                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
4581
+                                    $translation_texts[] = $labels['add_new_item'];
4582
+                }
4583
+                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
4584
+                                    $translation_texts[] = $labels['edit_item'];
4585
+                }
4586
+                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
4587
+                                    $translation_texts[] = $labels['new_item'];
4588
+                }
4589
+                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
4590
+                                    $translation_texts[] = $labels['view_item'];
4591
+                }
4592
+                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
4593
+                                    $translation_texts[] = $labels['search_items'];
4594
+                }
4595
+                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
4596
+                                    $translation_texts[] = $labels['not_found'];
4597
+                }
4598
+                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
4599
+                                    $translation_texts[] = $labels['not_found_in_trash'];
4600
+                }
4601
+                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
4602
+                                    $translation_texts[] = $labels['label_post_profile'];
4603
+                }
4604
+                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
4605
+                                    $translation_texts[] = $labels['label_post_info'];
4606
+                }
4607
+                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
4608
+                                    $translation_texts[] = $labels['label_post_images'];
4609
+                }
4610
+                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
4611
+                                    $translation_texts[] = $labels['label_post_map'];
4612
+                }
4613
+                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
4614
+                                    $translation_texts[] = $labels['label_reviews'];
4615
+                }
4616
+                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
4617
+                                    $translation_texts[] = $labels['label_related_listing'];
4618
+                }
4540 4619
             }
4541 4620
 
4542 4621
             if ($description != '' && !in_array($description, $translation_texts)) {
@@ -4544,11 +4623,13 @@  discard block
 block discarded – undo
4544 4623
             }
4545 4624
 
4546 4625
             if (!empty($seo)) {
4547
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4548
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4626
+                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
4627
+                                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4628
+                }
4549 4629
 
4550
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4551
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4630
+                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
4631
+                                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4632
+                }
4552 4633
             }
4553 4634
         }
4554 4635
     }
@@ -4574,16 +4655,20 @@  discard block
 block discarded – undo
4574 4655
         $hide_region_part = get_option('geodir_location_hide_region_part');
4575 4656
 
4576 4657
         if ($hide_region_part && $hide_country_part) {
4577
-            if (isset($location_terms['gd_country']))
4578
-                unset($location_terms['gd_country']);
4579
-            if (isset($location_terms['gd_region']))
4580
-                unset($location_terms['gd_region']);
4658
+            if (isset($location_terms['gd_country'])) {
4659
+                            unset($location_terms['gd_country']);
4660
+            }
4661
+            if (isset($location_terms['gd_region'])) {
4662
+                            unset($location_terms['gd_region']);
4663
+            }
4581 4664
         } else if ($hide_region_part && !$hide_country_part) {
4582
-            if (isset($location_terms['gd_region']))
4583
-                unset($location_terms['gd_region']);
4665
+            if (isset($location_terms['gd_region'])) {
4666
+                            unset($location_terms['gd_region']);
4667
+            }
4584 4668
         } else if (!$hide_region_part && $hide_country_part) {
4585
-            if (isset($location_terms['gd_country']))
4586
-                unset($location_terms['gd_country']);
4669
+            if (isset($location_terms['gd_country'])) {
4670
+                            unset($location_terms['gd_country']);
4671
+            }
4587 4672
         }
4588 4673
     }
4589 4674
 
Please login to merge, or discard this patch.
Indentation   +3377 added lines, -3377 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 function geodir_plugin_url()
29 29
 {
30 30
 
31
-    if (is_ssl()) :
32
-        return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
-    else :
34
-        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
35
-    endif;
31
+	if (is_ssl()) :
32
+		return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
+	else :
34
+		return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
35
+	endif;
36 36
 }
37 37
 
38 38
 
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_plugin_path()
49 49
 {
50
-    if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
51
-        return dirname(dirname(__FILE__));
52
-    } else {
53
-        return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
54
-    }
50
+	if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
51
+		return dirname(dirname(__FILE__));
52
+	} else {
53
+		return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
54
+	}
55 55
 }
56 56
 
57 57
 /**
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
  */
66 66
 function geodir_is_plugin_active($plugin)
67 67
 {
68
-    $active_plugins = get_option('active_plugins');
69
-    foreach ($active_plugins as $key => $active_plugin) {
70
-        if (strstr($active_plugin, $plugin)) return true;
71
-    }
72
-    return false;
68
+	$active_plugins = get_option('active_plugins');
69
+	foreach ($active_plugins as $key => $active_plugin) {
70
+		if (strstr($active_plugin, $plugin)) return true;
71
+	}
72
+	return false;
73 73
 }
74 74
 
75 75
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_get_formated_date($date)
87 87
 {
88
-    return mysql2date(get_option('date_format'), $date);
88
+	return mysql2date(get_option('date_format'), $date);
89 89
 }
90 90
 
91 91
 /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_get_formated_time($time)
102 102
 {
103
-    return mysql2date(get_option('time_format'), $time, $translate = true);
103
+	return mysql2date(get_option('time_format'), $time, $translate = true);
104 104
 }
105 105
 
106 106
 
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function geodir_getlink($url, $params = array(), $use_existing_arguments = false)
120 120
 {
121
-    if ($use_existing_arguments) $params = $params + $_GET;
122
-    if (!$params) return $url;
123
-    $link = $url;
124
-    if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
-    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
126
-    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
127
-
128
-    $params_arr = array();
129
-    foreach ($params as $key => $value) {
130
-        if (gettype($value) == 'array') { //Handle array data properly
131
-            foreach ($value as $val) {
132
-                $params_arr[] = $key . '[]=' . urlencode($val);
133
-            }
134
-        } else {
135
-            $params_arr[] = $key . '=' . urlencode($value);
136
-        }
137
-    }
138
-    $link .= implode('&', $params_arr);
139
-
140
-    return $link;
121
+	if ($use_existing_arguments) $params = $params + $_GET;
122
+	if (!$params) return $url;
123
+	$link = $url;
124
+	if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
+	elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
126
+	elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
127
+
128
+	$params_arr = array();
129
+	foreach ($params as $key => $value) {
130
+		if (gettype($value) == 'array') { //Handle array data properly
131
+			foreach ($value as $val) {
132
+				$params_arr[] = $key . '[]=' . urlencode($val);
133
+			}
134
+		} else {
135
+			$params_arr[] = $key . '=' . urlencode($value);
136
+		}
137
+	}
138
+	$link .= implode('&', $params_arr);
139
+
140
+	return $link;
141 141
 }
142 142
 
143 143
 
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
  */
153 153
 function geodir_get_addlisting_link($post_type = '')
154 154
 {
155
-    global $wpdb;
155
+	global $wpdb;
156 156
 
157
-    //$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
158
-    $check_pkg = 1;
159
-    if (post_type_exists($post_type) && $check_pkg) {
157
+	//$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
158
+	$check_pkg = 1;
159
+	if (post_type_exists($post_type) && $check_pkg) {
160 160
 
161
-        $add_listing_link = get_page_link(geodir_add_listing_page_id());
161
+		$add_listing_link = get_page_link(geodir_add_listing_page_id());
162 162
 
163
-        return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
-    } else
165
-        return get_bloginfo('url');
163
+		return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
+	} else
165
+		return get_bloginfo('url');
166 166
 }
167 167
 
168 168
 /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
  */
176 176
 function geodir_curPageURL()
177 177
 {
178
-    $pageURL = 'http';
179
-    if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
180
-        $pageURL .= "s";
181
-    }
182
-    $pageURL .= "://";
183
-    $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
184
-    /**
185
-     * Filter the current page URL returned by function geodir_curPageURL().
186
-     *
187
-     * @since 1.4.1
188
-     * @param string $pageURL The URL of the current page.
189
-     */
190
-    return apply_filters('geodir_curPageURL', $pageURL);
178
+	$pageURL = 'http';
179
+	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
180
+		$pageURL .= "s";
181
+	}
182
+	$pageURL .= "://";
183
+	$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
184
+	/**
185
+	 * Filter the current page URL returned by function geodir_curPageURL().
186
+	 *
187
+	 * @since 1.4.1
188
+	 * @param string $pageURL The URL of the current page.
189
+	 */
190
+	return apply_filters('geodir_curPageURL', $pageURL);
191 191
 }
192 192
 
193 193
 
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 function geodir_clean($string)
205 205
 {
206 206
 
207
-    $string = trim(strip_tags(stripslashes($string)));
208
-    $string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
209
-    $string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
210
-    $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
207
+	$string = trim(strip_tags(stripslashes($string)));
208
+	$string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
209
+	$string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
210
+	$string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
211 211
 
212
-    return $string;
212
+	return $string;
213 213
 }
214 214
 
215 215
 /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  */
222 222
 function geodir_get_weekday()
223 223
 {
224
-    return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
224
+	return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
225 225
 }
226 226
 
227 227
 /**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function geodir_get_weeks()
235 235
 {
236
-    return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
236
+	return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
237 237
 }
238 238
 
239 239
 
@@ -252,103 +252,103 @@  discard block
 block discarded – undo
252 252
 function geodir_is_page($gdpage = '')
253 253
 {
254 254
 
255
-    global $wp_query, $post,$wp;
256
-    //if(!is_admin()):
257
-
258
-    switch ($gdpage):
259
-        case 'add-listing':
260
-
261
-            if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
262
-                return true;
263
-            } elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
264
-                return true;
265
-            }
266
-
267
-            break;
268
-        case 'preview':
269
-            if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270
-                && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
-            )
272
-                return true;
273
-            break;
274
-        case 'listing-success':
275
-            if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
-                return true;
277
-            break;
278
-        case 'detail':
279
-            $post_type = get_query_var('post_type');
280
-            if(is_array($post_type)){$post_type = reset($post_type);}
281
-            if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
-                return true;
283
-            break;
284
-        case 'pt':
285
-            $post_type = get_query_var('post_type');
286
-            if(is_array($post_type)){$post_type = reset($post_type);}
287
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
-                return true;
289
-
290
-            break;
291
-        case 'listing':
292
-            if (is_tax() && geodir_get_taxonomy_posttype()) {
293
-                global $current_term, $taxonomy, $term;
294
-
295
-                return true;
296
-            }
297
-            $post_type = get_query_var('post_type');
298
-            if(is_array($post_type)){$post_type = reset($post_type);}
299
-            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
-                return true;
301
-
302
-            break;
303
-        case 'home':
304
-
305
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
-                return true;
307
-
308
-            break;
309
-        case 'location':
310
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
-                return true;
312
-            break;
313
-        case 'author':
314
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
-                return true;
255
+	global $wp_query, $post,$wp;
256
+	//if(!is_admin()):
257
+
258
+	switch ($gdpage):
259
+		case 'add-listing':
260
+
261
+			if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
262
+				return true;
263
+			} elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
264
+				return true;
265
+			}
266
+
267
+			break;
268
+		case 'preview':
269
+			if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270
+				&& in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
+			)
272
+				return true;
273
+			break;
274
+		case 'listing-success':
275
+			if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
+				return true;
277
+			break;
278
+		case 'detail':
279
+			$post_type = get_query_var('post_type');
280
+			if(is_array($post_type)){$post_type = reset($post_type);}
281
+			if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
+				return true;
283
+			break;
284
+		case 'pt':
285
+			$post_type = get_query_var('post_type');
286
+			if(is_array($post_type)){$post_type = reset($post_type);}
287
+			if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
+				return true;
289
+
290
+			break;
291
+		case 'listing':
292
+			if (is_tax() && geodir_get_taxonomy_posttype()) {
293
+				global $current_term, $taxonomy, $term;
294
+
295
+				return true;
296
+			}
297
+			$post_type = get_query_var('post_type');
298
+			if(is_array($post_type)){$post_type = reset($post_type);}
299
+			if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
+				return true;
301
+
302
+			break;
303
+		case 'home':
304
+
305
+			if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
+				return true;
307
+
308
+			break;
309
+		case 'location':
310
+			if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
+				return true;
312
+			break;
313
+		case 'author':
314
+			if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
+				return true;
316 316
 			
317 317
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
318 318
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
319 319
 					return true;
320 320
 				}
321 321
 			}
322
-            break;
323
-        case 'search':
324
-            if (is_search() && isset($_REQUEST['geodir_search']))
325
-                return true;
326
-            break;
327
-        case 'info':
328
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
-                return true;
330
-            break;
331
-        case 'login':
332
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
-                return true;
334
-            break;
335
-        case 'checkout':
336
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
-                return true;
338
-            break;
339
-        case 'invoices':
340
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
-                return true;
342
-            break;
343
-        default:
344
-            return false;
345
-            break;
346
-
347
-    endswitch;
348
-
349
-    //endif;
350
-
351
-    return false;
322
+			break;
323
+		case 'search':
324
+			if (is_search() && isset($_REQUEST['geodir_search']))
325
+				return true;
326
+			break;
327
+		case 'info':
328
+			if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
+				return true;
330
+			break;
331
+		case 'login':
332
+			if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
+				return true;
334
+			break;
335
+		case 'checkout':
336
+			if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
+				return true;
338
+			break;
339
+		case 'invoices':
340
+			if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
+				return true;
342
+			break;
343
+		default:
344
+			return false;
345
+			break;
346
+
347
+	endswitch;
348
+
349
+	//endif;
350
+
351
+	return false;
352 352
 }
353 353
 
354 354
 /**
@@ -362,97 +362,97 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function geodir_set_is_geodir_page($wp)
364 364
 {
365
-    if (!is_admin()) {
366
-        //$wp->query_vars['gd_is_geodir_page'] = false;
367
-        //print_r()
368
-        if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
-            if (get_option('geodir_set_as_home'))
370
-                $wp->query_vars['gd_is_geodir_page'] = true;
371
-            if(geodir_is_page('home')){
372
-                $wp->query_vars['gd_is_geodir_page'] = true;
373
-            }
374
-
375
-
376
-        }
377
-
378
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
379
-            if (
380
-                $wp->query_vars['page_id'] == geodir_add_listing_page_id()
381
-                || $wp->query_vars['page_id'] == geodir_preview_page_id()
382
-                || $wp->query_vars['page_id'] == geodir_success_page_id()
383
-                || $wp->query_vars['page_id'] == geodir_location_page_id()
384
-                || $wp->query_vars['page_id'] == geodir_home_page_id()
385
-                || $wp->query_vars['page_id'] == geodir_info_page_id()
386
-                || $wp->query_vars['page_id'] == geodir_login_page_id()
387
-                || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388
-                || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
-            )
390
-                $wp->query_vars['gd_is_geodir_page'] = true;
391
-        }
392
-
393
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
394
-            $page = get_page_by_path($wp->query_vars['pagename']);
395
-
396
-            if (!empty($page) && (
397
-                    $page->ID == geodir_add_listing_page_id()
398
-                    || $page->ID == geodir_preview_page_id()
399
-                    || $page->ID == geodir_success_page_id()
400
-                    || $page->ID == geodir_location_page_id()
401
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
402
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
403
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
404
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406
-                )
407
-            )
408
-                $wp->query_vars['gd_is_geodir_page'] = true;
409
-        }
410
-
411
-
412
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
413
-            $requested_post_type = $wp->query_vars['post_type'];
414
-            // check if this post type is geodirectory post types 
415
-            $post_type_array = geodir_get_posttypes();
416
-            if (in_array($requested_post_type, $post_type_array)) {
417
-                $wp->query_vars['gd_is_geodir_page'] = true;
418
-            }
419
-        }
420
-
421
-        if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422
-            $geodir_taxonomis = geodir_get_taxonomies('', true);
423
-            if(!empty($geodir_taxonomis)){
424
-                foreach ($geodir_taxonomis as $taxonomy) {
425
-                    if (array_key_exists($taxonomy, $wp->query_vars)) {
426
-                        $wp->query_vars['gd_is_geodir_page'] = true;
427
-                        break;
428
-                    }
429
-                }
430
-            }
431
-
432
-        }
433
-
434
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
-            $wp->query_vars['gd_is_geodir_page'] = true;
436
-
437
-
438
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
-            $wp->query_vars['gd_is_geodir_page'] = true;
365
+	if (!is_admin()) {
366
+		//$wp->query_vars['gd_is_geodir_page'] = false;
367
+		//print_r()
368
+		if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
+			if (get_option('geodir_set_as_home'))
370
+				$wp->query_vars['gd_is_geodir_page'] = true;
371
+			if(geodir_is_page('home')){
372
+				$wp->query_vars['gd_is_geodir_page'] = true;
373
+			}
374
+
375
+
376
+		}
377
+
378
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
379
+			if (
380
+				$wp->query_vars['page_id'] == geodir_add_listing_page_id()
381
+				|| $wp->query_vars['page_id'] == geodir_preview_page_id()
382
+				|| $wp->query_vars['page_id'] == geodir_success_page_id()
383
+				|| $wp->query_vars['page_id'] == geodir_location_page_id()
384
+				|| $wp->query_vars['page_id'] == geodir_home_page_id()
385
+				|| $wp->query_vars['page_id'] == geodir_info_page_id()
386
+				|| $wp->query_vars['page_id'] == geodir_login_page_id()
387
+				|| (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388
+				|| (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
+			)
390
+				$wp->query_vars['gd_is_geodir_page'] = true;
391
+		}
392
+
393
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
394
+			$page = get_page_by_path($wp->query_vars['pagename']);
395
+
396
+			if (!empty($page) && (
397
+					$page->ID == geodir_add_listing_page_id()
398
+					|| $page->ID == geodir_preview_page_id()
399
+					|| $page->ID == geodir_success_page_id()
400
+					|| $page->ID == geodir_location_page_id()
401
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
402
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
403
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
404
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406
+				)
407
+			)
408
+				$wp->query_vars['gd_is_geodir_page'] = true;
409
+		}
410
+
411
+
412
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
413
+			$requested_post_type = $wp->query_vars['post_type'];
414
+			// check if this post type is geodirectory post types 
415
+			$post_type_array = geodir_get_posttypes();
416
+			if (in_array($requested_post_type, $post_type_array)) {
417
+				$wp->query_vars['gd_is_geodir_page'] = true;
418
+			}
419
+		}
420
+
421
+		if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422
+			$geodir_taxonomis = geodir_get_taxonomies('', true);
423
+			if(!empty($geodir_taxonomis)){
424
+				foreach ($geodir_taxonomis as $taxonomy) {
425
+					if (array_key_exists($taxonomy, $wp->query_vars)) {
426
+						$wp->query_vars['gd_is_geodir_page'] = true;
427
+						break;
428
+					}
429
+				}
430
+			}
431
+
432
+		}
433
+
434
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
+			$wp->query_vars['gd_is_geodir_page'] = true;
436
+
437
+
438
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
+			$wp->query_vars['gd_is_geodir_page'] = true;
440 440
 
441 441
 
442 442
 //check if homepage
443
-        if(!isset($wp->query_vars['gd_is_geodir_page'])
444
-            && !isset($wp->query_vars['page_id'])
445
-            && !isset($wp->query_vars['pagename'])
446
-            && is_page_geodir_home()){
447
-            $wp->query_vars['gd_is_geodir_page'] = true;
448
-        }
449
-        //echo $wp->query_vars['gd_is_geodir_page'] ;
450
-        /*echo "<pre>" ;
443
+		if(!isset($wp->query_vars['gd_is_geodir_page'])
444
+			&& !isset($wp->query_vars['page_id'])
445
+			&& !isset($wp->query_vars['pagename'])
446
+			&& is_page_geodir_home()){
447
+			$wp->query_vars['gd_is_geodir_page'] = true;
448
+		}
449
+		//echo $wp->query_vars['gd_is_geodir_page'] ;
450
+		/*echo "<pre>" ;
451 451
 		print_r($wp) ;
452 452
 		echo "</pre>" ;
453 453
 	//	exit();
454 454
 			*/
455
-    } // end of is admin
455
+	} // end of is admin
456 456
 }
457 457
 
458 458
 /**
@@ -465,56 +465,56 @@  discard block
 block discarded – undo
465 465
  */
466 466
 function geodir_is_geodir_page()
467 467
 {
468
-    global $wp;
469
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
-        return true;
471
-    else
472
-        return false;
468
+	global $wp;
469
+	if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
+		return true;
471
+	else
472
+		return false;
473 473
 }
474 474
 
475 475
 if (!function_exists('geodir_get_imagesize')) {
476
-    /**
477
-     * Get image size using the size key .
478
-     *
479
-     * @since 1.0.0
480
-     * @package GeoDirectory
481
-     * @param string $size The image size key.
482
-     * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
483
-     */
484
-    function geodir_get_imagesize($size = '')
485
-    {
486
-
487
-        $imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
488
-            'thumbnail' => array('w' => 125, 'h' => 125),
489
-            'widget-thumb' => array('w' => 50, 'h' => 50),
490
-            'slider-thumb' => array('w' => 100, 'h' => 100)
491
-        );
492
-
493
-        /**
494
-         * Filter the image sizes array.
495
-         *
496
-         * @since 1.0.0
497
-         * @param array $imagesizes Image size array.
498
-         */
499
-        $imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
500
-
501
-        if (!empty($size) && array_key_exists($size, $imagesizes)) {
502
-            /**
503
-             * Filters image size of the passed key.
504
-             *
505
-             * @since 1.0.0
506
-             * @param array $imagesizes[$size] Image size array of the passed key.
507
-             */
508
-            return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
509
-
510
-        } elseif (!empty($size)) {
511
-
512
-            return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
513
-
514
-        }
515
-
516
-        return $imagesizes;
517
-    }
476
+	/**
477
+	 * Get image size using the size key .
478
+	 *
479
+	 * @since 1.0.0
480
+	 * @package GeoDirectory
481
+	 * @param string $size The image size key.
482
+	 * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
483
+	 */
484
+	function geodir_get_imagesize($size = '')
485
+	{
486
+
487
+		$imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
488
+			'thumbnail' => array('w' => 125, 'h' => 125),
489
+			'widget-thumb' => array('w' => 50, 'h' => 50),
490
+			'slider-thumb' => array('w' => 100, 'h' => 100)
491
+		);
492
+
493
+		/**
494
+		 * Filter the image sizes array.
495
+		 *
496
+		 * @since 1.0.0
497
+		 * @param array $imagesizes Image size array.
498
+		 */
499
+		$imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
500
+
501
+		if (!empty($size) && array_key_exists($size, $imagesizes)) {
502
+			/**
503
+			 * Filters image size of the passed key.
504
+			 *
505
+			 * @since 1.0.0
506
+			 * @param array $imagesizes[$size] Image size array of the passed key.
507
+			 */
508
+			return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
509
+
510
+		} elseif (!empty($size)) {
511
+
512
+			return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
513
+
514
+		}
515
+
516
+		return $imagesizes;
517
+	}
518 518
 }
519 519
 
520 520
 /**
@@ -534,151 +534,151 @@  discard block
 block discarded – undo
534 534
 
535 535
 
536 536
 if (!function_exists('createRandomString')) {
537
-    /**
538
-     * Creates random string.
539
-     *
540
-     * @since 1.0.0
541
-     * @package GeoDirectory
542
-     * @return string Random string.
543
-     */
544
-    function createRandomString()
545
-    {
546
-        $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
-        srand((double)microtime() * 1000000);
548
-        $i = 0;
549
-        $rstring = '';
550
-        while ($i <= 25) {
551
-            $num = rand() % 33;
552
-            $tmp = substr($chars, $num, 1);
553
-            $rstring = $rstring . $tmp;
554
-            $i++;
555
-        }
556
-        return $rstring;
557
-    }
537
+	/**
538
+	 * Creates random string.
539
+	 *
540
+	 * @since 1.0.0
541
+	 * @package GeoDirectory
542
+	 * @return string Random string.
543
+	 */
544
+	function createRandomString()
545
+	{
546
+		$chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
+		srand((double)microtime() * 1000000);
548
+		$i = 0;
549
+		$rstring = '';
550
+		while ($i <= 25) {
551
+			$num = rand() % 33;
552
+			$tmp = substr($chars, $num, 1);
553
+			$rstring = $rstring . $tmp;
554
+			$i++;
555
+		}
556
+		return $rstring;
557
+	}
558 558
 }
559 559
 
560 560
 if (!function_exists('geodir_getDistanceRadius')) {
561
-    /**
562
-     * Calculates the distance radius.
563
-     *
564
-     * @since 1.0.0
565
-     * @package GeoDirectory
566
-     * @param string $uom Measurement unit type.
567
-     * @return float The mean radius.
568
-     */
569
-    function geodir_getDistanceRadius($uom = 'km')
570
-    {
561
+	/**
562
+	 * Calculates the distance radius.
563
+	 *
564
+	 * @since 1.0.0
565
+	 * @package GeoDirectory
566
+	 * @param string $uom Measurement unit type.
567
+	 * @return float The mean radius.
568
+	 */
569
+	function geodir_getDistanceRadius($uom = 'km')
570
+	{
571 571
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
572
-        switch (geodir_strtolower($uom)):
573
-            case 'km'    :
574
-                $earthMeanRadius = 6371.009; // km
575
-                break;
576
-            case 'm'    :
577
-            case 'meters'    :
578
-                $earthMeanRadius = 6371.009 * 1000; // km
579
-                break;
580
-            case 'miles'    :
581
-                $earthMeanRadius = 3958.761; // miles
582
-                break;
583
-            case 'yards'    :
584
-            case 'yds'    :
585
-                $earthMeanRadius = 3958.761 * 1760; // yards
586
-                break;
587
-            case 'feet'    :
588
-            case 'ft'    :
589
-                $earthMeanRadius = 3958.761 * 1760 * 3; // feet
590
-                break;
591
-            case 'nm'    :
592
-                $earthMeanRadius = 3440.069; //  miles
593
-                break;
594
-            default:
595
-                $earthMeanRadius = 3958.761; // miles
596
-                break;
597
-        endswitch;
598
-        return $earthMeanRadius;
599
-    }
572
+		switch (geodir_strtolower($uom)):
573
+			case 'km'    :
574
+				$earthMeanRadius = 6371.009; // km
575
+				break;
576
+			case 'm'    :
577
+			case 'meters'    :
578
+				$earthMeanRadius = 6371.009 * 1000; // km
579
+				break;
580
+			case 'miles'    :
581
+				$earthMeanRadius = 3958.761; // miles
582
+				break;
583
+			case 'yards'    :
584
+			case 'yds'    :
585
+				$earthMeanRadius = 3958.761 * 1760; // yards
586
+				break;
587
+			case 'feet'    :
588
+			case 'ft'    :
589
+				$earthMeanRadius = 3958.761 * 1760 * 3; // feet
590
+				break;
591
+			case 'nm'    :
592
+				$earthMeanRadius = 3440.069; //  miles
593
+				break;
594
+			default:
595
+				$earthMeanRadius = 3958.761; // miles
596
+				break;
597
+		endswitch;
598
+		return $earthMeanRadius;
599
+	}
600 600
 }
601 601
 
602 602
 
603 603
 if (!function_exists('geodir_calculateDistanceFromLatLong')) {
604
-    /**
605
-     * Calculate the great circle distance between two points identified by longitude and latitude.
606
-     *
607
-     * @since 1.0.0
608
-     * @package GeoDirectory
609
-     * @param array $point1 Latitude and Longitude of point 1.
610
-     * @param array $point2 Latitude and Longitude of point 2.
611
-     * @param string $uom Unit of measurement.
612
-     * @return float The distance.
613
-     */
614
-    function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
615
-    {
604
+	/**
605
+	 * Calculate the great circle distance between two points identified by longitude and latitude.
606
+	 *
607
+	 * @since 1.0.0
608
+	 * @package GeoDirectory
609
+	 * @param array $point1 Latitude and Longitude of point 1.
610
+	 * @param array $point2 Latitude and Longitude of point 2.
611
+	 * @param string $uom Unit of measurement.
612
+	 * @return float The distance.
613
+	 */
614
+	function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
615
+	{
616 616
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
617 617
 
618
-        $earthMeanRadius = geodir_getDistanceRadius($uom);
618
+		$earthMeanRadius = geodir_getDistanceRadius($uom);
619 619
 
620
-        $deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']);
621
-        $deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']);
622
-        $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
623
-            cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) *
624
-            sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
625
-        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
626
-        $distance = $earthMeanRadius * $c;
627
-        return $distance;
620
+		$deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']);
621
+		$deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']);
622
+		$a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
623
+			cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) *
624
+			sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
625
+		$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
626
+		$distance = $earthMeanRadius * $c;
627
+		return $distance;
628 628
 
629
-    }
629
+	}
630 630
 }
631 631
 
632 632
 
633 633
 if (!function_exists('geodir_sendEmail')) {
634
-    /**
635
-     * The main function that send transactional emails using the args provided.
636
-     *
637
-     * @since 1.0.0
638
-     * @since 1.5.7 Added db translations for notifications subject and content.
639
-     * @package GeoDirectory
640
-     * @param string $fromEmail Sender email address.
641
-     * @param string $fromEmailName Sender name.
642
-     * @param string $toEmail Receiver email address.
643
-     * @param string $toEmailName Receiver name.
644
-     * @param string $to_subject Email subject.
645
-     * @param string $to_message Email content.
646
-     * @param string $extra Not being used.
647
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
648
-     * @param string $post_id The post ID.
649
-     * @param string $user_id The user ID.
650
-     */
651
-    function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
652
-        $login_details = '';
653
-
654
-        // strip slashes from subject & message text
655
-        $to_subject = stripslashes_deep($to_subject);
656
-        $to_message = stripslashes_deep($to_message);
657
-
658
-        if ($message_type == 'send_friend') {
659
-            $subject = get_option('geodir_email_friend_subject');
660
-            $message = get_option('geodir_email_friend_content');
661
-        } elseif ($message_type == 'send_enquiry') {
662
-            $subject = get_option('geodir_email_enquiry_subject');
663
-            $message = get_option('geodir_email_enquiry_content');
664
-        } elseif ($message_type == 'forgot_password') {
665
-            $subject = get_option('geodir_forgot_password_subject');
666
-            $message = get_option('geodir_forgot_password_content');
667
-            $login_details = $to_message;
668
-        } elseif ($message_type == 'registration') {
669
-            $subject = get_option('geodir_registration_success_email_subject');
670
-            $message = get_option('geodir_registration_success_email_content');
671
-            $login_details = $to_message;
672
-        } elseif ($message_type == 'post_submit') {
673
-            $subject = get_option('geodir_post_submited_success_email_subject');
674
-            $message = get_option('geodir_post_submited_success_email_content');
675
-        } elseif ($message_type == 'listing_published') {
676
-            $subject = get_option('geodir_post_published_email_subject');
677
-            $message = get_option('geodir_post_published_email_content');
678
-        } elseif ($message_type == 'listing_edited') {
679
-            $subject = get_option('geodir_post_edited_email_subject_admin');
680
-            $message = get_option('geodir_post_edited_email_content_admin');
681
-        }
634
+	/**
635
+	 * The main function that send transactional emails using the args provided.
636
+	 *
637
+	 * @since 1.0.0
638
+	 * @since 1.5.7 Added db translations for notifications subject and content.
639
+	 * @package GeoDirectory
640
+	 * @param string $fromEmail Sender email address.
641
+	 * @param string $fromEmailName Sender name.
642
+	 * @param string $toEmail Receiver email address.
643
+	 * @param string $toEmailName Receiver name.
644
+	 * @param string $to_subject Email subject.
645
+	 * @param string $to_message Email content.
646
+	 * @param string $extra Not being used.
647
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
648
+	 * @param string $post_id The post ID.
649
+	 * @param string $user_id The user ID.
650
+	 */
651
+	function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
652
+		$login_details = '';
653
+
654
+		// strip slashes from subject & message text
655
+		$to_subject = stripslashes_deep($to_subject);
656
+		$to_message = stripslashes_deep($to_message);
657
+
658
+		if ($message_type == 'send_friend') {
659
+			$subject = get_option('geodir_email_friend_subject');
660
+			$message = get_option('geodir_email_friend_content');
661
+		} elseif ($message_type == 'send_enquiry') {
662
+			$subject = get_option('geodir_email_enquiry_subject');
663
+			$message = get_option('geodir_email_enquiry_content');
664
+		} elseif ($message_type == 'forgot_password') {
665
+			$subject = get_option('geodir_forgot_password_subject');
666
+			$message = get_option('geodir_forgot_password_content');
667
+			$login_details = $to_message;
668
+		} elseif ($message_type == 'registration') {
669
+			$subject = get_option('geodir_registration_success_email_subject');
670
+			$message = get_option('geodir_registration_success_email_content');
671
+			$login_details = $to_message;
672
+		} elseif ($message_type == 'post_submit') {
673
+			$subject = get_option('geodir_post_submited_success_email_subject');
674
+			$message = get_option('geodir_post_submited_success_email_content');
675
+		} elseif ($message_type == 'listing_published') {
676
+			$subject = get_option('geodir_post_published_email_subject');
677
+			$message = get_option('geodir_post_published_email_content');
678
+		} elseif ($message_type == 'listing_edited') {
679
+			$subject = get_option('geodir_post_edited_email_subject_admin');
680
+			$message = get_option('geodir_post_edited_email_content_admin');
681
+		}
682 682
 		
683 683
 		if (!empty($subject)) {
684 684
 			$subject = __(stripslashes_deep($subject),'geodirectory');
@@ -688,203 +688,203 @@  discard block
 block discarded – undo
688 688
 			$message = __(stripslashes_deep($message),'geodirectory');
689 689
 		}
690 690
 
691
-        $to_message = nl2br($to_message);
692
-        $sitefromEmail = get_option('site_email');
693
-        $sitefromEmailName = get_site_emailName();
694
-        $productlink = get_permalink($post_id);
695
-
696
-        $user_login = '';
697
-        if ($user_id > 0 && $user_info = get_userdata($user_id)) {
698
-            $user_login = $user_info->user_login;
699
-        }
700
-
701
-        $posted_date = '';
702
-        $listingLink = '';
703
-
704
-        $post_info = get_post($post_id);
705
-
706
-        if ($post_info) {
707
-            $posted_date = $post_info->post_date;
708
-            $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
709
-        }
710
-        $siteurl = home_url();
711
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
712
-        $loginurl = geodir_login_url();
713
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
691
+		$to_message = nl2br($to_message);
692
+		$sitefromEmail = get_option('site_email');
693
+		$sitefromEmailName = get_site_emailName();
694
+		$productlink = get_permalink($post_id);
695
+
696
+		$user_login = '';
697
+		if ($user_id > 0 && $user_info = get_userdata($user_id)) {
698
+			$user_login = $user_info->user_login;
699
+		}
700
+
701
+		$posted_date = '';
702
+		$listingLink = '';
703
+
704
+		$post_info = get_post($post_id);
705
+
706
+		if ($post_info) {
707
+			$posted_date = $post_info->post_date;
708
+			$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
709
+		}
710
+		$siteurl = home_url();
711
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
712
+		$loginurl = geodir_login_url();
713
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
714 714
         
715
-        $post_author_id = !empty($post_info) ? $post_info->post_author : 0;
716
-        $post_author_name = geodir_get_client_name($post_author_id);
717
-        $current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
718
-
719
-        if ($fromEmail == '') {
720
-            $fromEmail = get_option('site_email');
721
-        }
722
-
723
-        if ($fromEmailName == '') {
724
-            $fromEmailName = get_option('site_email_name');
725
-        }
726
-
727
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729
-        $message = str_replace($search_array, $replace_array, $message);
730
-
731
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733
-        $subject = str_replace($search_array, $replace_array, $subject);
734
-
735
-        $headers = 'MIME-Version: 1.0' . "\r\n";
736
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
737
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
738
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
739
-
740
-        $to = $toEmail;
741
-
742
-        /**
743
-         * Filter the client email to address.
744
-         *
745
-         * @since 1.6.1
746
-         * @package GeoDirectory
747
-         * @param string $to The email address the email is being sent to.
748
-         * @param string $fromEmail Sender email address.
749
-         * @param string $fromEmailName Sender name.
750
-         * @param string $toEmail Receiver email address.
751
-         * @param string $toEmailName Receiver name.
752
-         * @param string $to_subject Email subject.
753
-         * @param string $to_message Email content.
754
-         * @param string $extra Not being used.
755
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
756
-         * @param string $post_id The post ID.
757
-         * @param string $user_id The user ID.
758
-         */
759
-        $to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
760
-        /**
761
-         * Filter the client email subject.
762
-         *
763
-         * @since 1.6.1
764
-         * @package GeoDirectory_Payment_Manager
765
-         * @param string $subject The email subject.
766
-         * @param string $fromEmail Sender email address.
767
-         * @param string $fromEmailName Sender name.
768
-         * @param string $toEmail Receiver email address.
769
-         * @param string $toEmailName Receiver name.
770
-         * @param string $to_subject Email subject.
771
-         * @param string $to_message Email content.
772
-         * @param string $extra Not being used.
773
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
774
-         * @param string $post_id The post ID.
775
-         * @param string $user_id The user ID.
776
-         */
777
-        $subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
778
-        /**
779
-         * Filter the client email message.
780
-         *
781
-         * @since 1.6.1
782
-         * @package GeoDirectory_Payment_Manager
783
-         * @param string $message The email message text.
784
-         * @param string $fromEmail Sender email address.
785
-         * @param string $fromEmailName Sender name.
786
-         * @param string $toEmail Receiver email address.
787
-         * @param string $toEmailName Receiver name.
788
-         * @param string $to_subject Email subject.
789
-         * @param string $to_message Email content.
790
-         * @param string $extra Not being used.
791
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
792
-         * @param string $post_id The post ID.
793
-         * @param string $user_id The user ID.
794
-         */
795
-        $message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
796
-        /**
797
-         * Filter the client email headers.
798
-         *
799
-         * @since 1.6.1
800
-         * @package GeoDirectory_Payment_Manager
801
-         * @param string $headers The email headers.
802
-         * @param string $fromEmail Sender email address.
803
-         * @param string $fromEmailName Sender name.
804
-         * @param string $toEmail Receiver email address.
805
-         * @param string $toEmailName Receiver name.
806
-         * @param string $to_subject Email subject.
807
-         * @param string $to_message Email content.
808
-         * @param string $extra Not being used.
809
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
810
-         * @param string $post_id The post ID.
811
-         * @param string $user_id The user ID.
812
-         */
813
-        $headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
814
-
815
-        $sent = wp_mail($to, $subject, $message, $headers);
816
-
817
-        if( ! $sent ) {
818
-            if ( is_array( $to ) ) {
819
-                $to = implode( ',', $to );
820
-            }
821
-            $log_message = sprintf(
822
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
823
-                $message_type,
824
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
825
-                $to,
826
-                $subject
827
-            );
828
-            geodir_error_log( $log_message );
829
-        }
830
-
831
-        ///////// ADMIN BCC EMIALS
832
-        $adminEmail = get_bloginfo('admin_email');
833
-        $to = $adminEmail;
834
-
835
-        $admin_bcc = false;
836
-        if ($message_type == 'post_submit') {
837
-            $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
838
-            $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
839
-
840
-            $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#]');
841
-            $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);
842
-            $message = str_replace($search_array, $replace_array, $message);
843
-
844
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
845
-            $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
846
-            $subject = str_replace($search_array, $replace_array, $subject);
847
-
848
-            $subject .= ' - ADMIN BCC COPY';
849
-            $admin_bcc = true;
850
-
851
-        }
852
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
853
-            $subject .= ' - ADMIN BCC COPY';
854
-            $admin_bcc = true;
855
-        }
856
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
857
-            $subject .= ' - ADMIN BCC COPY';
858
-            $admin_bcc = true;
859
-        }
860
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
861
-            $subject .= ' - ADMIN BCC COPY';
862
-            $admin_bcc = true;
863
-        }
864
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
865
-            $subject .= ' - ADMIN BCC COPY';
866
-            $admin_bcc = true;
867
-        }
868
-
869
-        if($admin_bcc===true){
870
-            $sent = wp_mail($to, $subject, $message, $headers);
871
-
872
-            if( ! $sent ) {
873
-                if ( is_array( $to ) ) {
874
-                    $to = implode( ',', $to );
875
-                }
876
-                $log_message = sprintf(
877
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
878
-                    $message_type,
879
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
880
-                    $to,
881
-                    $subject
882
-                );
883
-                geodir_error_log( $log_message );
884
-            }
885
-        }
886
-
887
-    }
715
+		$post_author_id = !empty($post_info) ? $post_info->post_author : 0;
716
+		$post_author_name = geodir_get_client_name($post_author_id);
717
+		$current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
718
+
719
+		if ($fromEmail == '') {
720
+			$fromEmail = get_option('site_email');
721
+		}
722
+
723
+		if ($fromEmailName == '') {
724
+			$fromEmailName = get_option('site_email_name');
725
+		}
726
+
727
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729
+		$message = str_replace($search_array, $replace_array, $message);
730
+
731
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733
+		$subject = str_replace($search_array, $replace_array, $subject);
734
+
735
+		$headers = 'MIME-Version: 1.0' . "\r\n";
736
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
737
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
738
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
739
+
740
+		$to = $toEmail;
741
+
742
+		/**
743
+		 * Filter the client email to address.
744
+		 *
745
+		 * @since 1.6.1
746
+		 * @package GeoDirectory
747
+		 * @param string $to The email address the email is being sent to.
748
+		 * @param string $fromEmail Sender email address.
749
+		 * @param string $fromEmailName Sender name.
750
+		 * @param string $toEmail Receiver email address.
751
+		 * @param string $toEmailName Receiver name.
752
+		 * @param string $to_subject Email subject.
753
+		 * @param string $to_message Email content.
754
+		 * @param string $extra Not being used.
755
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
756
+		 * @param string $post_id The post ID.
757
+		 * @param string $user_id The user ID.
758
+		 */
759
+		$to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
760
+		/**
761
+		 * Filter the client email subject.
762
+		 *
763
+		 * @since 1.6.1
764
+		 * @package GeoDirectory_Payment_Manager
765
+		 * @param string $subject The email subject.
766
+		 * @param string $fromEmail Sender email address.
767
+		 * @param string $fromEmailName Sender name.
768
+		 * @param string $toEmail Receiver email address.
769
+		 * @param string $toEmailName Receiver name.
770
+		 * @param string $to_subject Email subject.
771
+		 * @param string $to_message Email content.
772
+		 * @param string $extra Not being used.
773
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
774
+		 * @param string $post_id The post ID.
775
+		 * @param string $user_id The user ID.
776
+		 */
777
+		$subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
778
+		/**
779
+		 * Filter the client email message.
780
+		 *
781
+		 * @since 1.6.1
782
+		 * @package GeoDirectory_Payment_Manager
783
+		 * @param string $message The email message text.
784
+		 * @param string $fromEmail Sender email address.
785
+		 * @param string $fromEmailName Sender name.
786
+		 * @param string $toEmail Receiver email address.
787
+		 * @param string $toEmailName Receiver name.
788
+		 * @param string $to_subject Email subject.
789
+		 * @param string $to_message Email content.
790
+		 * @param string $extra Not being used.
791
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
792
+		 * @param string $post_id The post ID.
793
+		 * @param string $user_id The user ID.
794
+		 */
795
+		$message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
796
+		/**
797
+		 * Filter the client email headers.
798
+		 *
799
+		 * @since 1.6.1
800
+		 * @package GeoDirectory_Payment_Manager
801
+		 * @param string $headers The email headers.
802
+		 * @param string $fromEmail Sender email address.
803
+		 * @param string $fromEmailName Sender name.
804
+		 * @param string $toEmail Receiver email address.
805
+		 * @param string $toEmailName Receiver name.
806
+		 * @param string $to_subject Email subject.
807
+		 * @param string $to_message Email content.
808
+		 * @param string $extra Not being used.
809
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
810
+		 * @param string $post_id The post ID.
811
+		 * @param string $user_id The user ID.
812
+		 */
813
+		$headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
814
+
815
+		$sent = wp_mail($to, $subject, $message, $headers);
816
+
817
+		if( ! $sent ) {
818
+			if ( is_array( $to ) ) {
819
+				$to = implode( ',', $to );
820
+			}
821
+			$log_message = sprintf(
822
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
823
+				$message_type,
824
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
825
+				$to,
826
+				$subject
827
+			);
828
+			geodir_error_log( $log_message );
829
+		}
830
+
831
+		///////// ADMIN BCC EMIALS
832
+		$adminEmail = get_bloginfo('admin_email');
833
+		$to = $adminEmail;
834
+
835
+		$admin_bcc = false;
836
+		if ($message_type == 'post_submit') {
837
+			$subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
838
+			$message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
839
+
840
+			$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#]');
841
+			$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);
842
+			$message = str_replace($search_array, $replace_array, $message);
843
+
844
+			$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
845
+			$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
846
+			$subject = str_replace($search_array, $replace_array, $subject);
847
+
848
+			$subject .= ' - ADMIN BCC COPY';
849
+			$admin_bcc = true;
850
+
851
+		}
852
+		elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
853
+			$subject .= ' - ADMIN BCC COPY';
854
+			$admin_bcc = true;
855
+		}
856
+		elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
857
+			$subject .= ' - ADMIN BCC COPY';
858
+			$admin_bcc = true;
859
+		}
860
+		elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
861
+			$subject .= ' - ADMIN BCC COPY';
862
+			$admin_bcc = true;
863
+		}
864
+		elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
865
+			$subject .= ' - ADMIN BCC COPY';
866
+			$admin_bcc = true;
867
+		}
868
+
869
+		if($admin_bcc===true){
870
+			$sent = wp_mail($to, $subject, $message, $headers);
871
+
872
+			if( ! $sent ) {
873
+				if ( is_array( $to ) ) {
874
+					$to = implode( ',', $to );
875
+				}
876
+				$log_message = sprintf(
877
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
878
+					$message_type,
879
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
880
+					$to,
881
+					$subject
882
+				);
883
+				geodir_error_log( $log_message );
884
+			}
885
+		}
886
+
887
+	}
888 888
 }
889 889
 
890 890
 
@@ -897,27 +897,27 @@  discard block
 block discarded – undo
897 897
 function geodir_taxonomy_breadcrumb()
898 898
 {
899 899
 
900
-    $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
901
-    $parent = $term->parent;
900
+	$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
901
+	$parent = $term->parent;
902 902
 
903
-    while ($parent):
904
-        $parents[] = $parent;
905
-        $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
906
-        $parent = $new_parent->parent;
907
-    endwhile;
903
+	while ($parent):
904
+		$parents[] = $parent;
905
+		$new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
906
+		$parent = $new_parent->parent;
907
+	endwhile;
908 908
 
909
-    if (!empty($parents)):
910
-        $parents = array_reverse($parents);
909
+	if (!empty($parents)):
910
+		$parents = array_reverse($parents);
911 911
 
912
-        foreach ($parents as $parent):
913
-            $item = get_term_by('id', $parent, get_query_var('taxonomy'));
914
-            $url = get_term_link($item, get_query_var('taxonomy'));
915
-            echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
916
-        endforeach;
912
+		foreach ($parents as $parent):
913
+			$item = get_term_by('id', $parent, get_query_var('taxonomy'));
914
+			$url = get_term_link($item, get_query_var('taxonomy'));
915
+			echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
916
+		endforeach;
917 917
 
918
-    endif;
918
+	endif;
919 919
 
920
-    echo '<li> > ' . $term->name . '</li>';
920
+	echo '<li> > ' . $term->name . '</li>';
921 921
 }
922 922
 
923 923
 
@@ -933,369 +933,369 @@  discard block
 block discarded – undo
933 933
  */
934 934
 function geodir_breadcrumb()
935 935
 {
936
-    global $wp_query, $geodir_add_location_url;
937
-
938
-    /**
939
-     * Filter breadcrumb separator.
940
-     *
941
-     * @since 1.0.0
942
-     */
943
-    $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
944
-
945
-    if (!geodir_is_page('home')) {
946
-        $breadcrumb = '';
947
-        $url_categoris = '';
948
-        $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
949
-        /**
950
-         * Filter breadcrumb's first link.
951
-         *
952
-         * @since 1.0.0
953
-         */
954
-        $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
955
-
956
-        $gd_post_type = geodir_get_current_posttype();
957
-        $post_type_info = get_post_type_object($gd_post_type);
958
-
959
-        remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
960
-
961
-        $listing_link = get_post_type_archive_link($gd_post_type);
962
-
963
-        add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
964
-        $listing_link = rtrim($listing_link, '/');
965
-        $listing_link .= '/';
966
-
967
-        $post_type_for_location_link = $listing_link;
968
-        $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
969
-
970
-        global $wp, $gd_session;
971
-        $location_link = $post_type_for_location_link;
972
-
973
-        if (geodir_is_page('detail') || geodir_is_page('listing')) {
974
-            global $post;
975
-            $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
936
+	global $wp_query, $geodir_add_location_url;
937
+
938
+	/**
939
+	 * Filter breadcrumb separator.
940
+	 *
941
+	 * @since 1.0.0
942
+	 */
943
+	$separator = apply_filters('geodir_breadcrumb_separator', ' > ');
944
+
945
+	if (!geodir_is_page('home')) {
946
+		$breadcrumb = '';
947
+		$url_categoris = '';
948
+		$breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
949
+		/**
950
+		 * Filter breadcrumb's first link.
951
+		 *
952
+		 * @since 1.0.0
953
+		 */
954
+		$breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
955
+
956
+		$gd_post_type = geodir_get_current_posttype();
957
+		$post_type_info = get_post_type_object($gd_post_type);
958
+
959
+		remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
960
+
961
+		$listing_link = get_post_type_archive_link($gd_post_type);
962
+
963
+		add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
964
+		$listing_link = rtrim($listing_link, '/');
965
+		$listing_link .= '/';
966
+
967
+		$post_type_for_location_link = $listing_link;
968
+		$location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
969
+
970
+		global $wp, $gd_session;
971
+		$location_link = $post_type_for_location_link;
972
+
973
+		if (geodir_is_page('detail') || geodir_is_page('listing')) {
974
+			global $post;
975
+			$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
976 976
 			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
977 977
 				
978 978
 			if(geodir_is_page('detail') && isset($post->country_slug)){
979
-                $location_terms = array(
980
-                    'gd_country' => $post->country_slug,
981
-                    'gd_region' => $post->region_slug,
982
-                    'gd_city' => $post->city_slug
983
-                );
979
+				$location_terms = array(
980
+					'gd_country' => $post->country_slug,
981
+					'gd_region' => $post->region_slug,
982
+					'gd_city' => $post->city_slug
983
+				);
984 984
 				
985 985
 				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
986 986
 					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
987 987
 				}
988
-            }
989
-
990
-            $geodir_show_location_url = get_option('geodir_show_location_url');
991
-
992
-            $hide_url_part = array();
993
-            if ($location_manager) {
994
-                $hide_country_part = get_option('geodir_location_hide_country_part');
995
-                $hide_region_part = get_option('geodir_location_hide_region_part');
996
-
997
-                if ($hide_region_part && $hide_country_part) {
998
-                    $hide_url_part = array('gd_country', 'gd_region');
999
-                } else if ($hide_region_part && !$hide_country_part) {
1000
-                    $hide_url_part = array('gd_region');
1001
-                } else if (!$hide_region_part && $hide_country_part) {
1002
-                    $hide_url_part = array('gd_country');
1003
-                }
1004
-            }
1005
-
1006
-            $hide_text_part = array();
1007
-            if ($geodir_show_location_url == 'country_city') {
1008
-                $hide_text_part = array('gd_region');
1009
-
1010
-                if (isset($location_terms['gd_region']) && !$location_manager) {
1011
-                    unset($location_terms['gd_region']);
1012
-                }
1013
-            } else if ($geodir_show_location_url == 'region_city') {
1014
-                $hide_text_part = array('gd_country');
1015
-
1016
-                if (isset($location_terms['gd_country']) && !$location_manager) {
1017
-                    unset($location_terms['gd_country']);
1018
-                }
1019
-            } else if ($geodir_show_location_url == 'city') {
1020
-                $hide_text_part = array('gd_country', 'gd_region');
1021
-
1022
-                if (isset($location_terms['gd_country']) && !$location_manager) {
1023
-                    unset($location_terms['gd_country']);
1024
-                }
1025
-                if (isset($location_terms['gd_region']) && !$location_manager) {
1026
-                    unset($location_terms['gd_region']);
1027
-                }
1028
-            }
1029
-
1030
-            $is_location_last = '';
1031
-            $is_taxonomy_last = '';
1032
-            $breadcrumb .= '<li>';
1033
-            if (get_query_var($gd_post_type . 'category'))
1034
-                $gd_taxonomy = $gd_post_type . 'category';
1035
-            elseif (get_query_var($gd_post_type . '_tags'))
1036
-                $gd_taxonomy = $gd_post_type . '_tags';
1037
-
1038
-            $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1039
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
1040
-                $is_location_last = false;
1041
-            else
1042
-                $is_location_last = true;
1043
-
1044
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
1045
-                $is_taxonomy_last = true;
1046
-            else
1047
-                $is_taxonomy_last = false;
1048
-
1049
-            if (!empty($location_terms)) {
1050
-                $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
1051
-
1052
-                foreach ($location_terms as $key => $location_term) {
1053
-                    if ($location_term != '') {
1054
-                        if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
1055
-                            continue;
1056
-                        }
988
+			}
1057 989
 
1058
-                        $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
1059
-                        $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
1060
-                        $gd_location_link_text = ucfirst($gd_location_link_text);
1061
-
1062
-                        $location_term_actual_country = '';
1063
-                        $location_term_actual_region = '';
1064
-                        $location_term_actual_city = '';
1065
-                        if ($geodir_get_locations) {
1066
-                            if ($key == 'gd_country') {
1067
-                                $location_term_actual_country = get_actual_location_name('country', $location_term, true);
1068
-                            } else if ($key == 'gd_region') {
1069
-                                $location_term_actual_region = get_actual_location_name('region', $location_term, true);
1070
-                            } else if ($key == 'gd_city') {
1071
-                                $location_term_actual_city = get_actual_location_name('city', $location_term, true);
1072
-                            }
1073
-                        } else {
1074
-                            $location_info = geodir_get_location();
1075
-
1076
-                            if (!empty($location_info) && isset($location_info->location_id)) {
1077
-                                if ($key == 'gd_country') {
1078
-                                    $location_term_actual_country = __($location_info->country, 'geodirectory');
1079
-                                } else if ($key == 'gd_region') {
1080
-                                    $location_term_actual_region = __($location_info->region, 'geodirectory');
1081
-                                } else if ($key == 'gd_city') {
1082
-                                    $location_term_actual_city = __($location_info->city, 'geodirectory');
1083
-                                }
1084
-                            }
1085
-                        }
990
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1086 991
 
1087
-                        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'] != '')) {
1088
-                            $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1089
-                        } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1090
-                            $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1091
-                        } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1092
-                            $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1093
-                        } else if ($is_location_last && $key == 'gd_neighbourhood') {
1094
-                            $breadcrumb .= $separator . $gd_location_link_text;
1095
-                        } else {
1096
-                            if (get_option('permalink_structure') != '') {
1097
-                                $location_link .= $location_term . '/';
1098
-                            } else {
1099
-                                $location_link .= "&$key=" . $location_term;
1100
-                            }
992
+			$hide_url_part = array();
993
+			if ($location_manager) {
994
+				$hide_country_part = get_option('geodir_location_hide_country_part');
995
+				$hide_region_part = get_option('geodir_location_hide_region_part');
1101 996
 
1102
-                            if ($key == 'gd_country' && $location_term_actual_country != '') {
1103
-                                $gd_location_link_text = $location_term_actual_country;
1104
-                            } else if ($key == 'gd_region' && $location_term_actual_region != '') {
1105
-                                $gd_location_link_text = $location_term_actual_region;
1106
-                            } else if ($key == 'gd_city' && $location_term_actual_city != '') {
1107
-                                $gd_location_link_text = $location_term_actual_city;
1108
-                            }
997
+				if ($hide_region_part && $hide_country_part) {
998
+					$hide_url_part = array('gd_country', 'gd_region');
999
+				} else if ($hide_region_part && !$hide_country_part) {
1000
+					$hide_url_part = array('gd_region');
1001
+				} else if (!$hide_region_part && $hide_country_part) {
1002
+					$hide_url_part = array('gd_country');
1003
+				}
1004
+			}
1005
+
1006
+			$hide_text_part = array();
1007
+			if ($geodir_show_location_url == 'country_city') {
1008
+				$hide_text_part = array('gd_region');
1009
+
1010
+				if (isset($location_terms['gd_region']) && !$location_manager) {
1011
+					unset($location_terms['gd_region']);
1012
+				}
1013
+			} else if ($geodir_show_location_url == 'region_city') {
1014
+				$hide_text_part = array('gd_country');
1015
+
1016
+				if (isset($location_terms['gd_country']) && !$location_manager) {
1017
+					unset($location_terms['gd_country']);
1018
+				}
1019
+			} else if ($geodir_show_location_url == 'city') {
1020
+				$hide_text_part = array('gd_country', 'gd_region');
1021
+
1022
+				if (isset($location_terms['gd_country']) && !$location_manager) {
1023
+					unset($location_terms['gd_country']);
1024
+				}
1025
+				if (isset($location_terms['gd_region']) && !$location_manager) {
1026
+					unset($location_terms['gd_region']);
1027
+				}
1028
+			}
1109 1029
 
1110
-                            /*
1030
+			$is_location_last = '';
1031
+			$is_taxonomy_last = '';
1032
+			$breadcrumb .= '<li>';
1033
+			if (get_query_var($gd_post_type . 'category'))
1034
+				$gd_taxonomy = $gd_post_type . 'category';
1035
+			elseif (get_query_var($gd_post_type . '_tags'))
1036
+				$gd_taxonomy = $gd_post_type . '_tags';
1037
+
1038
+			$breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1039
+			if (!empty($gd_taxonomy) || geodir_is_page('detail'))
1040
+				$is_location_last = false;
1041
+			else
1042
+				$is_location_last = true;
1043
+
1044
+			if (!empty($gd_taxonomy) && geodir_is_page('listing'))
1045
+				$is_taxonomy_last = true;
1046
+			else
1047
+				$is_taxonomy_last = false;
1048
+
1049
+			if (!empty($location_terms)) {
1050
+				$geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
1051
+
1052
+				foreach ($location_terms as $key => $location_term) {
1053
+					if ($location_term != '') {
1054
+						if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
1055
+							continue;
1056
+						}
1057
+
1058
+						$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
1059
+						$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
1060
+						$gd_location_link_text = ucfirst($gd_location_link_text);
1061
+
1062
+						$location_term_actual_country = '';
1063
+						$location_term_actual_region = '';
1064
+						$location_term_actual_city = '';
1065
+						if ($geodir_get_locations) {
1066
+							if ($key == 'gd_country') {
1067
+								$location_term_actual_country = get_actual_location_name('country', $location_term, true);
1068
+							} else if ($key == 'gd_region') {
1069
+								$location_term_actual_region = get_actual_location_name('region', $location_term, true);
1070
+							} else if ($key == 'gd_city') {
1071
+								$location_term_actual_city = get_actual_location_name('city', $location_term, true);
1072
+							}
1073
+						} else {
1074
+							$location_info = geodir_get_location();
1075
+
1076
+							if (!empty($location_info) && isset($location_info->location_id)) {
1077
+								if ($key == 'gd_country') {
1078
+									$location_term_actual_country = __($location_info->country, 'geodirectory');
1079
+								} else if ($key == 'gd_region') {
1080
+									$location_term_actual_region = __($location_info->region, 'geodirectory');
1081
+								} else if ($key == 'gd_city') {
1082
+									$location_term_actual_city = __($location_info->city, 'geodirectory');
1083
+								}
1084
+							}
1085
+						}
1086
+
1087
+						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'] != '')) {
1088
+							$breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1089
+						} else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1090
+							$breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1091
+						} else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1092
+							$breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1093
+						} else if ($is_location_last && $key == 'gd_neighbourhood') {
1094
+							$breadcrumb .= $separator . $gd_location_link_text;
1095
+						} else {
1096
+							if (get_option('permalink_structure') != '') {
1097
+								$location_link .= $location_term . '/';
1098
+							} else {
1099
+								$location_link .= "&$key=" . $location_term;
1100
+							}
1101
+
1102
+							if ($key == 'gd_country' && $location_term_actual_country != '') {
1103
+								$gd_location_link_text = $location_term_actual_country;
1104
+							} else if ($key == 'gd_region' && $location_term_actual_region != '') {
1105
+								$gd_location_link_text = $location_term_actual_region;
1106
+							} else if ($key == 'gd_city' && $location_term_actual_city != '') {
1107
+								$gd_location_link_text = $location_term_actual_city;
1108
+							}
1109
+
1110
+							/*
1111 1111
                             if (geodir_is_page('detail') && !empty($hide_text_part) && in_array($key, $hide_text_part)) {
1112 1112
                                 continue;
1113 1113
                             }
1114 1114
                             */
1115 1115
 
1116
-                            $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1117
-                        }
1118
-                    }
1119
-                }
1120
-            }
1121
-
1122
-            if (!empty($gd_taxonomy)) {
1123
-                $term_index = 1;
1124
-
1125
-                //if(get_option('geodir_add_categories_url'))
1126
-                {
1127
-                    if (get_query_var($gd_post_type . '_tags')) {
1128
-                        $cat_link = $listing_link . 'tags/';
1129
-                    } else
1130
-                        $cat_link = $listing_link;
1131
-
1132
-                    foreach ($location_terms as $key => $location_term) {
1133
-                        if ($location_manager && in_array($key, $hide_url_part)) {
1134
-                            continue;
1135
-                        }
1116
+							$breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1117
+						}
1118
+					}
1119
+				}
1120
+			}
1136 1121
 
1137
-                        if ($location_term != '') {
1138
-                            if (get_option('permalink_structure') != '') {
1139
-                                $cat_link .= $location_term . '/';
1140
-                            }
1141
-                        }
1142
-                    }
1143
-
1144
-                    $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1145
-                    foreach ($term_array as $term) {
1146
-                        $term_link_text = preg_replace('/-(\d+)$/', '', $term);
1147
-                        $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1148
-
1149
-                        // get term actual name
1150
-                        $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1151
-                        if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1152
-                            $term_link_text = urldecode($term_info['name']);
1153
-                        } else {
1154
-                            $term_link_text = geodir_ucwords(urldecode($term_link_text));
1155
-                        }
1122
+			if (!empty($gd_taxonomy)) {
1123
+				$term_index = 1;
1156 1124
 
1157
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1158
-                            $breadcrumb .= $separator . $term_link_text;
1159
-                        else {
1160
-                            $cat_link .= $term . '/';
1161
-                            $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1162
-                        }
1163
-                        $term_index++;
1164
-                    }
1165
-                }
1166
-
1167
-
1168
-            }
1169
-
1170
-            if (geodir_is_page('detail'))
1171
-                $breadcrumb .= $separator . get_the_title();
1172
-
1173
-            $breadcrumb .= '</li>';
1174
-
1175
-
1176
-        } elseif (geodir_is_page('author')) {
1177
-            $user_id = get_current_user_id();
1178
-            $author_link = get_author_posts_url($user_id);
1179
-            $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1180
-
1181
-            /**
1182
-             * Filter author page link.
1183
-             *
1184
-             * @since 1.0.0
1185
-             * @param string $default_author_link Default author link.
1186
-             * @param int $user_id Author ID.
1187
-             */
1188
-            $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1189
-
1190
-            $breadcrumb .= '<li>';
1191
-            $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1192
-
1193
-            if (isset($_REQUEST['list'])) {
1194
-                $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1195
-
1196
-                /**
1197
-                 * Filter author page link.
1198
-                 *
1199
-                 * @since 1.0.0
1200
-                 * @param string $author_link Author page link.
1201
-                 * @param int $user_id Author ID.
1202
-                 * @param string $_REQUEST['stype'] Post type.
1203
-                 */
1204
-                $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1205
-
1206
-                $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1207
-                $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1208
-            } else
1209
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1210
-
1211
-            $breadcrumb .= '</li>';
1212
-        } elseif (is_category() || is_single()) {
1213
-            $category = get_the_category();
1214
-            if (is_category()) {
1215
-                $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1216
-            }
1217
-            if (is_single()) {
1218
-                $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1219
-                $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1220
-            }
1221
-            /* End of my version ##################################################### */
1222
-        } else if (is_page()) {
1223
-            $page_title = get_the_title();
1224
-
1225
-            if (geodir_is_page('location')) {
1226
-                $location_page_id = geodir_location_page_id();
1227
-                $loc_post = get_post( $location_page_id );
1228
-                $post_name = $loc_post->post_name;
1229
-                $slug= ucwords(str_replace('-',' ',$post_name));
1230
-                $page_title = !empty($slug )? $slug : __('Location', 'geodirectory');
1231
-            }
1232
-
1233
-            $breadcrumb .= '<li>' . $separator;
1234
-            $breadcrumb .= stripslashes_deep($page_title);
1235
-            $breadcrumb .= '</li>';
1236
-        } else if (is_tag()) {
1237
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1238
-        } else if (is_day()) {
1239
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
-            the_time('F jS, Y');
1241
-            $breadcrumb .= '</li>';
1242
-        } else if (is_month()) {
1243
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
-            the_time('F, Y');
1245
-            $breadcrumb .= '</li>';
1246
-        } else if (is_year()) {
1247
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1248
-            the_time('Y');
1249
-            $breadcrumb .= '</li>';
1250
-        } else if (is_author()) {
1251
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1252
-            $breadcrumb .= '</li>';
1253
-        } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1254
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1255
-            $breadcrumb .= '</li>';
1256
-        } else if (is_search()) {
1257
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1258
-            $breadcrumb .= '</li>';
1259
-        }
1260
-        $breadcrumb .= '</ul></div>';
1261
-
1262
-        /**
1263
-         * Filter breadcrumb html output.
1264
-         *
1265
-         * @since 1.0.0
1266
-         * @param string $breadcrumb Breadcrumb HTML.
1267
-         * @param string $separator Breadcrumb separator.
1268
-         */
1269
-        echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1270
-    }
1125
+				//if(get_option('geodir_add_categories_url'))
1126
+				{
1127
+					if (get_query_var($gd_post_type . '_tags')) {
1128
+						$cat_link = $listing_link . 'tags/';
1129
+					} else
1130
+						$cat_link = $listing_link;
1131
+
1132
+					foreach ($location_terms as $key => $location_term) {
1133
+						if ($location_manager && in_array($key, $hide_url_part)) {
1134
+							continue;
1135
+						}
1136
+
1137
+						if ($location_term != '') {
1138
+							if (get_option('permalink_structure') != '') {
1139
+								$cat_link .= $location_term . '/';
1140
+							}
1141
+						}
1142
+					}
1143
+
1144
+					$term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1145
+					foreach ($term_array as $term) {
1146
+						$term_link_text = preg_replace('/-(\d+)$/', '', $term);
1147
+						$term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1148
+
1149
+						// get term actual name
1150
+						$term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1151
+						if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1152
+							$term_link_text = urldecode($term_info['name']);
1153
+						} else {
1154
+							$term_link_text = geodir_ucwords(urldecode($term_link_text));
1155
+						}
1156
+
1157
+						if ($term_index == count($term_array) && $is_taxonomy_last)
1158
+							$breadcrumb .= $separator . $term_link_text;
1159
+						else {
1160
+							$cat_link .= $term . '/';
1161
+							$breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1162
+						}
1163
+						$term_index++;
1164
+					}
1165
+				}
1166
+
1167
+
1168
+			}
1169
+
1170
+			if (geodir_is_page('detail'))
1171
+				$breadcrumb .= $separator . get_the_title();
1172
+
1173
+			$breadcrumb .= '</li>';
1174
+
1175
+
1176
+		} elseif (geodir_is_page('author')) {
1177
+			$user_id = get_current_user_id();
1178
+			$author_link = get_author_posts_url($user_id);
1179
+			$default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1180
+
1181
+			/**
1182
+			 * Filter author page link.
1183
+			 *
1184
+			 * @since 1.0.0
1185
+			 * @param string $default_author_link Default author link.
1186
+			 * @param int $user_id Author ID.
1187
+			 */
1188
+			$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1189
+
1190
+			$breadcrumb .= '<li>';
1191
+			$breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1192
+
1193
+			if (isset($_REQUEST['list'])) {
1194
+				$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1195
+
1196
+				/**
1197
+				 * Filter author page link.
1198
+				 *
1199
+				 * @since 1.0.0
1200
+				 * @param string $author_link Author page link.
1201
+				 * @param int $user_id Author ID.
1202
+				 * @param string $_REQUEST['stype'] Post type.
1203
+				 */
1204
+				$author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1205
+
1206
+				$breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1207
+				$breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1208
+			} else
1209
+				$breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1210
+
1211
+			$breadcrumb .= '</li>';
1212
+		} elseif (is_category() || is_single()) {
1213
+			$category = get_the_category();
1214
+			if (is_category()) {
1215
+				$breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1216
+			}
1217
+			if (is_single()) {
1218
+				$breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1219
+				$breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1220
+			}
1221
+			/* End of my version ##################################################### */
1222
+		} else if (is_page()) {
1223
+			$page_title = get_the_title();
1224
+
1225
+			if (geodir_is_page('location')) {
1226
+				$location_page_id = geodir_location_page_id();
1227
+				$loc_post = get_post( $location_page_id );
1228
+				$post_name = $loc_post->post_name;
1229
+				$slug= ucwords(str_replace('-',' ',$post_name));
1230
+				$page_title = !empty($slug )? $slug : __('Location', 'geodirectory');
1231
+			}
1232
+
1233
+			$breadcrumb .= '<li>' . $separator;
1234
+			$breadcrumb .= stripslashes_deep($page_title);
1235
+			$breadcrumb .= '</li>';
1236
+		} else if (is_tag()) {
1237
+			$breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1238
+		} else if (is_day()) {
1239
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
+			the_time('F jS, Y');
1241
+			$breadcrumb .= '</li>';
1242
+		} else if (is_month()) {
1243
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
+			the_time('F, Y');
1245
+			$breadcrumb .= '</li>';
1246
+		} else if (is_year()) {
1247
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1248
+			the_time('Y');
1249
+			$breadcrumb .= '</li>';
1250
+		} else if (is_author()) {
1251
+			$breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1252
+			$breadcrumb .= '</li>';
1253
+		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1254
+			$breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1255
+			$breadcrumb .= '</li>';
1256
+		} else if (is_search()) {
1257
+			$breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1258
+			$breadcrumb .= '</li>';
1259
+		}
1260
+		$breadcrumb .= '</ul></div>';
1261
+
1262
+		/**
1263
+		 * Filter breadcrumb html output.
1264
+		 *
1265
+		 * @since 1.0.0
1266
+		 * @param string $breadcrumb Breadcrumb HTML.
1267
+		 * @param string $separator Breadcrumb separator.
1268
+		 */
1269
+		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1270
+	}
1271 1271
 }
1272 1272
 
1273 1273
 
1274 1274
 add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
1275 1275
 if (!function_exists('geodir_allow_wpadmin')) {
1276
-    /**
1277
-     * Allow only admins to access wp-admin.
1278
-     *
1279
-     * Normal users will be redirected to home page.
1280
-     *
1281
-     * @since 1.0.0
1282
-     * @package GeoDirectory
1283
-     * @global object $wpdb WordPress Database object.
1284
-     */
1285
-    function geodir_allow_wpadmin()
1286
-    {
1287
-        global $wpdb;
1288
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1289
-        {
1290
-            if (current_user_can('manage_options')) {
1291
-            } else {
1292
-
1293
-                wp_redirect(home_url());
1294
-                exit;
1295
-            }
1296
-
1297
-        }
1298
-    }
1276
+	/**
1277
+	 * Allow only admins to access wp-admin.
1278
+	 *
1279
+	 * Normal users will be redirected to home page.
1280
+	 *
1281
+	 * @since 1.0.0
1282
+	 * @package GeoDirectory
1283
+	 * @global object $wpdb WordPress Database object.
1284
+	 */
1285
+	function geodir_allow_wpadmin()
1286
+	{
1287
+		global $wpdb;
1288
+		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1289
+		{
1290
+			if (current_user_can('manage_options')) {
1291
+			} else {
1292
+
1293
+				wp_redirect(home_url());
1294
+				exit;
1295
+			}
1296
+
1297
+		}
1298
+	}
1299 1299
 }
1300 1300
 
1301 1301
 
@@ -1309,84 +1309,84 @@  discard block
 block discarded – undo
1309 1309
  */
1310 1310
 function fetch_remote_file($url)
1311 1311
 {
1312
-    // extract the file name and extension from the url
1313
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1314
-    $file_name = basename($url);
1315
-    if (strpos($file_name, '?') !== false) {
1316
-        list($file_name) = explode('?', $file_name);
1317
-    }
1318
-    $dummy = false;
1319
-    $add_to_cache = false;
1320
-    $key = null;
1321
-    if (strpos($url, '/dummy/') !== false) {
1322
-        $dummy = true;
1323
-        $key = "dummy_".str_replace('.', '_', $file_name);
1324
-        $value = get_transient('cached_dummy_images');
1325
-        if ($value) {
1326
-            if (isset($value[$key])) {
1327
-                return $value[$key];
1328
-            } else {
1329
-                $add_to_cache = true;
1330
-            }
1331
-        } else {
1332
-            $add_to_cache = true;
1333
-        }
1334
-    }
1335
-
1336
-    // get placeholder file in the upload dir with a unique, sanitized filename
1337
-
1338
-    $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1339
-
1340
-    $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1341
-    if ($upload['error'])
1342
-        return new WP_Error('upload_dir_error', $upload['error']);
1343
-
1344
-
1345
-    sleep(0.3);// if multiple remote file this can cause the remote server to timeout so we add a slight delay
1346
-
1347
-    // fetch the remote url and write it to the placeholder file
1348
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1349
-
1350
-    $log_message = '';
1351
-    if( is_wp_error( $headers  ) ) {
1352
-        echo 'file: '.$url;
1353
-        return new WP_Error('import_file_error',$headers->get_error_message());
1354
-    }
1355
-
1356
-    $filesize = filesize($upload['file']);
1357
-    // request failed
1358
-    if (!$headers) {
1359
-        $log_message = __('Remote server did not respond', 'geodirectory');
1360
-    }
1361
-    // make sure the fetch was successful
1362
-    elseif ($headers['response']['code'] != '200') {
1363
-        $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1364
-    }
1365
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1366
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1367
-    }
1368
-    elseif (0 == $filesize) {
1369
-        $log_message = __('Zero size file downloaded', 'geodirectory');
1370
-    }
1371
-
1372
-    if($log_message){
1373
-        $del = unlink($upload['file']);
1374
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1375
-        return new WP_Error('import_file_error',$log_message );
1376
-    }
1377
-
1378
-    if ($dummy && $add_to_cache && is_array($upload)) {
1379
-        $images = get_transient('cached_dummy_images');
1380
-        if(is_array($images))
1381
-            $images[$key] = $upload;
1382
-        else
1383
-            $images = array($key => $upload);
1384
-
1385
-        //setting the cache using the WP Transient API
1386
-        set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
1387
-    }
1388
-
1389
-    return $upload;
1312
+	// extract the file name and extension from the url
1313
+	require_once(ABSPATH . 'wp-includes/pluggable.php');
1314
+	$file_name = basename($url);
1315
+	if (strpos($file_name, '?') !== false) {
1316
+		list($file_name) = explode('?', $file_name);
1317
+	}
1318
+	$dummy = false;
1319
+	$add_to_cache = false;
1320
+	$key = null;
1321
+	if (strpos($url, '/dummy/') !== false) {
1322
+		$dummy = true;
1323
+		$key = "dummy_".str_replace('.', '_', $file_name);
1324
+		$value = get_transient('cached_dummy_images');
1325
+		if ($value) {
1326
+			if (isset($value[$key])) {
1327
+				return $value[$key];
1328
+			} else {
1329
+				$add_to_cache = true;
1330
+			}
1331
+		} else {
1332
+			$add_to_cache = true;
1333
+		}
1334
+	}
1335
+
1336
+	// get placeholder file in the upload dir with a unique, sanitized filename
1337
+
1338
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1339
+
1340
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1341
+	if ($upload['error'])
1342
+		return new WP_Error('upload_dir_error', $upload['error']);
1343
+
1344
+
1345
+	sleep(0.3);// if multiple remote file this can cause the remote server to timeout so we add a slight delay
1346
+
1347
+	// fetch the remote url and write it to the placeholder file
1348
+	$headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1349
+
1350
+	$log_message = '';
1351
+	if( is_wp_error( $headers  ) ) {
1352
+		echo 'file: '.$url;
1353
+		return new WP_Error('import_file_error',$headers->get_error_message());
1354
+	}
1355
+
1356
+	$filesize = filesize($upload['file']);
1357
+	// request failed
1358
+	if (!$headers) {
1359
+		$log_message = __('Remote server did not respond', 'geodirectory');
1360
+	}
1361
+	// make sure the fetch was successful
1362
+	elseif ($headers['response']['code'] != '200') {
1363
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1364
+	}
1365
+	elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1366
+		$log_message =  __('Remote file is incorrect size', 'geodirectory');
1367
+	}
1368
+	elseif (0 == $filesize) {
1369
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1370
+	}
1371
+
1372
+	if($log_message){
1373
+		$del = unlink($upload['file']);
1374
+		if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1375
+		return new WP_Error('import_file_error',$log_message );
1376
+	}
1377
+
1378
+	if ($dummy && $add_to_cache && is_array($upload)) {
1379
+		$images = get_transient('cached_dummy_images');
1380
+		if(is_array($images))
1381
+			$images[$key] = $upload;
1382
+		else
1383
+			$images = array($key => $upload);
1384
+
1385
+		//setting the cache using the WP Transient API
1386
+		set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
1387
+	}
1388
+
1389
+	return $upload;
1390 1390
 }
1391 1391
 
1392 1392
 /**
@@ -1398,21 +1398,21 @@  discard block
 block discarded – undo
1398 1398
  */
1399 1399
 function geodir_max_upload_size()
1400 1400
 {
1401
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1402
-
1403
-    if ($max_filesize > 0 && $max_filesize < 1) {
1404
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1405
-    } else {
1406
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1407
-    }
1408
-
1409
-    /**
1410
-     * Filter default image upload size limit.
1411
-     *
1412
-     * @since 1.0.0
1413
-     * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1414
-     */
1415
-    return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1401
+	$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1402
+
1403
+	if ($max_filesize > 0 && $max_filesize < 1) {
1404
+		$max_filesize = (int)($max_filesize * 1024) . 'kb';
1405
+	} else {
1406
+		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1407
+	}
1408
+
1409
+	/**
1410
+	 * Filter default image upload size limit.
1411
+	 *
1412
+	 * @since 1.0.0
1413
+	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1414
+	 */
1415
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1416 1416
 }
1417 1417
 
1418 1418
 /**
@@ -1426,11 +1426,11 @@  discard block
 block discarded – undo
1426 1426
  */
1427 1427
 function geodir_dummy_folder_exists()
1428 1428
 {
1429
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1430
-    if (!is_dir($path))
1431
-        return false;
1432
-    else
1433
-        return true;
1429
+	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1430
+	if (!is_dir($path))
1431
+		return false;
1432
+	else
1433
+		return true;
1434 1434
 
1435 1435
 }
1436 1436
 
@@ -1445,290 +1445,290 @@  discard block
 block discarded – undo
1445 1445
  */
1446 1446
 function  geodir_get_author_info($aid)
1447 1447
 {
1448
-    global $wpdb;
1449
-    /*$infosql = "select * from $wpdb->users where ID=$aid";*/
1450
-    $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1451
-    $info = $wpdb->get_results($infosql);
1452
-    if ($info) {
1453
-        return $info[0];
1454
-    }
1448
+	global $wpdb;
1449
+	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1450
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1451
+	$info = $wpdb->get_results($infosql);
1452
+	if ($info) {
1453
+		return $info[0];
1454
+	}
1455 1455
 }
1456 1456
 
1457 1457
 if (!function_exists('adminEmail')) {
1458
-    /**
1459
-     * Send emails to client on post submission, renew etc.
1460
-     *
1461
-     * @since 1.0.0
1462
-     * @package GeoDirectory
1463
-     * @global object $wpdb WordPress Database object.
1464
-     * @param int|string $page_id Page ID.
1465
-     * @param int|string $user_id User ID.
1466
-     * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1467
-     * @param string $custom_1 Custom data to be sent.
1468
-     */
1469
-    function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1470
-    {
1471
-        global $wpdb;
1472
-        if ($message_type == 'expiration') {
1473
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1474
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1475
-        } elseif ($message_type == 'post_submited') {
1476
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1477
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1478
-        } elseif ($message_type == 'renew') {
1479
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1480
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1481
-        } elseif ($message_type == 'upgrade') {
1482
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1483
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1484
-        } elseif ($message_type == 'claim_approved') {
1485
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1486
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1487
-        } elseif ($message_type == 'claim_rejected') {
1488
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1489
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1490
-        } elseif ($message_type == 'claim_requested') {
1491
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1492
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1493
-        } elseif ($message_type == 'auto_claim') {
1494
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1495
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1496
-        } elseif ($message_type == 'payment_success') {
1497
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1498
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1499
-        } elseif ($message_type == 'payment_fail') {
1500
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1501
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1502
-        }
1503
-        $transaction_details = $custom_1;
1504
-        $fromEmail = get_option('site_email');
1505
-        $fromEmailName = get_site_emailName();
1458
+	/**
1459
+	 * Send emails to client on post submission, renew etc.
1460
+	 *
1461
+	 * @since 1.0.0
1462
+	 * @package GeoDirectory
1463
+	 * @global object $wpdb WordPress Database object.
1464
+	 * @param int|string $page_id Page ID.
1465
+	 * @param int|string $user_id User ID.
1466
+	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1467
+	 * @param string $custom_1 Custom data to be sent.
1468
+	 */
1469
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1470
+	{
1471
+		global $wpdb;
1472
+		if ($message_type == 'expiration') {
1473
+			$subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1474
+			$client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1475
+		} elseif ($message_type == 'post_submited') {
1476
+			$subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1477
+			$client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1478
+		} elseif ($message_type == 'renew') {
1479
+			$subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1480
+			$client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1481
+		} elseif ($message_type == 'upgrade') {
1482
+			$subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1483
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1484
+		} elseif ($message_type == 'claim_approved') {
1485
+			$subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1486
+			$client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1487
+		} elseif ($message_type == 'claim_rejected') {
1488
+			$subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1489
+			$client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1490
+		} elseif ($message_type == 'claim_requested') {
1491
+			$subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1492
+			$client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1493
+		} elseif ($message_type == 'auto_claim') {
1494
+			$subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1495
+			$client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1496
+		} elseif ($message_type == 'payment_success') {
1497
+			$subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1498
+			$client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1499
+		} elseif ($message_type == 'payment_fail') {
1500
+			$subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1501
+			$client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1502
+		}
1503
+		$transaction_details = $custom_1;
1504
+		$fromEmail = get_option('site_email');
1505
+		$fromEmailName = get_site_emailName();
1506 1506
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1507
-        $pkg_limit = get_property_price_info_listing($page_id);
1508
-        $alivedays = $pkg_limit['days'];
1509
-        $productlink = get_permalink($page_id);
1510
-        $post_info = get_post($page_id);
1511
-        $post_date = date('dS F,Y', strtotime($post_info->post_date));
1512
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1513
-        $loginurl = geodir_login_url();
1514
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1515
-        $siteurl = home_url();
1516
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1517
-        $user_info = get_userdata($user_id);
1518
-        $user_email = $user_info->user_email;
1519
-        $display_name = geodir_get_client_name($user_id);
1520
-        $user_login = $user_info->user_login;
1521
-        $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1522
-        if ($number_of_grace_days == '') {
1523
-            $number_of_grace_days = 1;
1524
-        }
1525
-        if ($post_info->post_type == 'event') {
1526
-            $post_type = 'event';
1527
-        } else {
1528
-            $post_type = 'listing';
1529
-        }
1530
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1531
-        $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#]');
1532
-        $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);
1533
-        $client_message = str_replace($search_array, $replace_array, $client_message);
1534
-        $subject = str_replace($search_array, $replace_array, $subject);
1535
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1536
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1537
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1538
-
1539
-        $to = $fromEmail;
1540
-        $message = $client_message;
1541
-
1542
-
1543
-        /**
1544
-         * Filter the admin email to address.
1545
-         *
1546
-         * @since 1.6.1
1547
-         * @package GeoDirectory
1548
-         * @param string $to The email address the email is being sent to.
1549
-         * @param int|string $page_id Page ID.
1550
-         * @param int|string $user_id User ID.
1551
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1552
-         * @param string $custom_1 Custom data to be sent.
1553
-         */
1554
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1555
-        /**
1556
-         * Filter the admin email subject.
1557
-         *
1558
-         * @since 1.6.1
1559
-         * @package GeoDirectory_Payment_Manager
1560
-         * @param string $subject The email subject.
1561
-         * @param int|string $page_id Page ID.
1562
-         * @param int|string $user_id User ID.
1563
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1564
-         * @param string $custom_1 Custom data to be sent.
1565
-         */
1566
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1567
-        /**
1568
-         * Filter the admin email message.
1569
-         *
1570
-         * @since 1.6.1
1571
-         * @package GeoDirectory_Payment_Manager
1572
-         * @param string $message The email message text.
1573
-         * @param int|string $page_id Page ID.
1574
-         * @param int|string $user_id User ID.
1575
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1576
-         * @param string $custom_1 Custom data to be sent.
1577
-         */
1578
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1579
-        /**
1580
-         * Filter the admin email headers.
1581
-         *
1582
-         * @since 1.6.1
1583
-         * @package GeoDirectory_Payment_Manager
1584
-         * @param string $headers The email headers.
1585
-         * @param int|string $page_id Page ID.
1586
-         * @param int|string $user_id User ID.
1587
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1588
-         * @param string $custom_1 Custom data to be sent.
1589
-         */
1590
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1591
-
1592
-
1593
-
1594
-        $sent = wp_mail($to, $subject, $message, $headers);
1595
-        if( ! $sent ) {
1596
-            if ( is_array( $to ) ) {
1597
-                $to = implode( ',', $to );
1598
-            }
1599
-            $log_message = sprintf(
1600
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1601
-                $message_type,
1602
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1603
-                $to,
1604
-                $subject
1605
-            );
1606
-            geodir_error_log( $log_message );
1607
-        }
1608
-    }
1507
+		$pkg_limit = get_property_price_info_listing($page_id);
1508
+		$alivedays = $pkg_limit['days'];
1509
+		$productlink = get_permalink($page_id);
1510
+		$post_info = get_post($page_id);
1511
+		$post_date = date('dS F,Y', strtotime($post_info->post_date));
1512
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1513
+		$loginurl = geodir_login_url();
1514
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1515
+		$siteurl = home_url();
1516
+		$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1517
+		$user_info = get_userdata($user_id);
1518
+		$user_email = $user_info->user_email;
1519
+		$display_name = geodir_get_client_name($user_id);
1520
+		$user_login = $user_info->user_login;
1521
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1522
+		if ($number_of_grace_days == '') {
1523
+			$number_of_grace_days = 1;
1524
+		}
1525
+		if ($post_info->post_type == 'event') {
1526
+			$post_type = 'event';
1527
+		} else {
1528
+			$post_type = 'listing';
1529
+		}
1530
+		$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1531
+		$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#]');
1532
+		$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);
1533
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1534
+		$subject = str_replace($search_array, $replace_array, $subject);
1535
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1536
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1537
+		$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1538
+
1539
+		$to = $fromEmail;
1540
+		$message = $client_message;
1541
+
1542
+
1543
+		/**
1544
+		 * Filter the admin email to address.
1545
+		 *
1546
+		 * @since 1.6.1
1547
+		 * @package GeoDirectory
1548
+		 * @param string $to The email address the email is being sent to.
1549
+		 * @param int|string $page_id Page ID.
1550
+		 * @param int|string $user_id User ID.
1551
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1552
+		 * @param string $custom_1 Custom data to be sent.
1553
+		 */
1554
+		$to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1555
+		/**
1556
+		 * Filter the admin email subject.
1557
+		 *
1558
+		 * @since 1.6.1
1559
+		 * @package GeoDirectory_Payment_Manager
1560
+		 * @param string $subject The email subject.
1561
+		 * @param int|string $page_id Page ID.
1562
+		 * @param int|string $user_id User ID.
1563
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1564
+		 * @param string $custom_1 Custom data to be sent.
1565
+		 */
1566
+		$subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1567
+		/**
1568
+		 * Filter the admin email message.
1569
+		 *
1570
+		 * @since 1.6.1
1571
+		 * @package GeoDirectory_Payment_Manager
1572
+		 * @param string $message The email message text.
1573
+		 * @param int|string $page_id Page ID.
1574
+		 * @param int|string $user_id User ID.
1575
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1576
+		 * @param string $custom_1 Custom data to be sent.
1577
+		 */
1578
+		$message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1579
+		/**
1580
+		 * Filter the admin email headers.
1581
+		 *
1582
+		 * @since 1.6.1
1583
+		 * @package GeoDirectory_Payment_Manager
1584
+		 * @param string $headers The email headers.
1585
+		 * @param int|string $page_id Page ID.
1586
+		 * @param int|string $user_id User ID.
1587
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1588
+		 * @param string $custom_1 Custom data to be sent.
1589
+		 */
1590
+		$headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1591
+
1592
+
1593
+
1594
+		$sent = wp_mail($to, $subject, $message, $headers);
1595
+		if( ! $sent ) {
1596
+			if ( is_array( $to ) ) {
1597
+				$to = implode( ',', $to );
1598
+			}
1599
+			$log_message = sprintf(
1600
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1601
+				$message_type,
1602
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1603
+				$to,
1604
+				$subject
1605
+			);
1606
+			geodir_error_log( $log_message );
1607
+		}
1608
+	}
1609 1609
 }
1610 1610
 
1611 1611
 if (!function_exists('sendEmail')) {
1612
-    /**
1613
-     * @todo could be a duplicate of geodir_sendEmail.
1614
-     *
1615
-     * @since 1.0.0
1616
-     * @package GeoDirectory
1617
-     * @param string $fromEmail Sender email address.
1618
-     * @param string $fromEmailName Sender name.
1619
-     * @param string $toEmail Receiver email address.
1620
-     * @param string $toEmailName Receiver name.
1621
-     * @param string $to_subject Email subject.
1622
-     * @param string $to_message Email content.
1623
-     * @param string $extra Not being used.
1624
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1625
-     * @param string $post_id The post ID.
1626
-     * @param string $user_id The user ID.
1627
-     */
1628
-    function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1629
-    {
1630
-        $login_details = '';
1631
-        if ($message_type == 'send_friend') {
1632
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1633
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1634
-        } elseif ($message_type == 'send_enquiry') {
1635
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1636
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1637
-        } elseif ($message_type == 'forgot_password') {
1638
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1639
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1640
-            $login_details = $to_message;
1641
-        } elseif ($message_type == 'registration') {
1642
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1643
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1644
-            $login_details = $to_message;
1645
-        }
1646
-        $to_message = nl2br($to_message);
1647
-        $sitefromEmail = get_option('site_email');
1648
-        $sitefromEmailName = get_site_emailName();
1649
-        $productlink = get_permalink($post_id);
1650
-        $post_info = get_post($post_id);
1651
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1652
-        $siteurl = home_url();
1653
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1654
-        $loginurl = geodir_login_url();
1655
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1656
-        if ($fromEmail == '') {
1657
-            $fromEmail = get_option('site_email');
1658
-        }
1659
-        if ($fromEmailName == '') {
1660
-            $fromEmailName = get_option('site_email_name');
1661
-        }
1662
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1663
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1664
-        $message = str_replace($search_array, $replace_array, $message);
1665
-
1666
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1667
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1668
-        $subject = str_replace($search_array, $replace_array, $subject);
1669
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1670
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1671
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1672
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1673
-
1674
-        $to = $toEmail;
1675
-
1676
-        $sent = wp_mail($to, $subject, $message, $headers);
1677
-        if( ! $sent ) {
1678
-            if ( is_array( $to ) ) {
1679
-                $to = implode( ',', $to );
1680
-            }
1681
-            $log_message = sprintf(
1682
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1683
-                $message_type,
1684
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1685
-                $to,
1686
-                $subject
1687
-            );
1688
-            geodir_error_log( $log_message );
1689
-        }
1690
-
1691
-        ///////// ADMIN BCC EMIALS
1692
-        $admin_bcc = false;
1693
-        if ($message_type == 'registration') {
1694
-            $message_raw = explode(__("Password:", 'geodirectory'), $message);
1695
-            $message_raw2 = explode("</p>", $message_raw[1], 2);
1696
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1697
-        }
1698
-        $adminEmail = get_bloginfo('admin_email');
1699
-        $to = $adminEmail;
1700
-
1701
-        if ($message_type == 'registration' && get_option('bcc_new_user')) {
1702
-            $subject .= ' - ADMIN BCC COPY';
1703
-            $admin_bcc = true;
1704
-        }
1705
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1706
-            $subject .= ' - ADMIN BCC COPY';
1707
-            $admin_bcc = true;
1708
-        }
1709
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1710
-            $subject .= ' - ADMIN BCC COPY';
1711
-            $admin_bcc = true;
1712
-        }
1713
-
1714
-        if($admin_bcc === true){
1715
-            $sent = wp_mail($to, $subject, $message, $headers);
1716
-            if( ! $sent ) {
1717
-                if ( is_array( $to ) ) {
1718
-                    $to = implode( ',', $to );
1719
-                }
1720
-                $log_message = sprintf(
1721
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1722
-                    $message_type,
1723
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1724
-                    $to,
1725
-                    $subject
1726
-                );
1727
-                geodir_error_log( $log_message );
1728
-            }
1729
-        }
1730
-
1731
-    }
1612
+	/**
1613
+	 * @todo could be a duplicate of geodir_sendEmail.
1614
+	 *
1615
+	 * @since 1.0.0
1616
+	 * @package GeoDirectory
1617
+	 * @param string $fromEmail Sender email address.
1618
+	 * @param string $fromEmailName Sender name.
1619
+	 * @param string $toEmail Receiver email address.
1620
+	 * @param string $toEmailName Receiver name.
1621
+	 * @param string $to_subject Email subject.
1622
+	 * @param string $to_message Email content.
1623
+	 * @param string $extra Not being used.
1624
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1625
+	 * @param string $post_id The post ID.
1626
+	 * @param string $user_id The user ID.
1627
+	 */
1628
+	function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1629
+	{
1630
+		$login_details = '';
1631
+		if ($message_type == 'send_friend') {
1632
+			$subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1633
+			$message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1634
+		} elseif ($message_type == 'send_enquiry') {
1635
+			$subject = __(get_option('email_enquiry_subject'),'geodirectory');
1636
+			$message = __(get_option('email_enquiry_content'),'geodirectory');
1637
+		} elseif ($message_type == 'forgot_password') {
1638
+			$subject = __(get_option('forgot_password_subject'),'geodirectory');
1639
+			$message = __(get_option('forgot_password_content'),'geodirectory');
1640
+			$login_details = $to_message;
1641
+		} elseif ($message_type == 'registration') {
1642
+			$subject = __(get_option('registration_success_email_subject'),'geodirectory');
1643
+			$message = __(get_option('registration_success_email_content'),'geodirectory');
1644
+			$login_details = $to_message;
1645
+		}
1646
+		$to_message = nl2br($to_message);
1647
+		$sitefromEmail = get_option('site_email');
1648
+		$sitefromEmailName = get_site_emailName();
1649
+		$productlink = get_permalink($post_id);
1650
+		$post_info = get_post($post_id);
1651
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1652
+		$siteurl = home_url();
1653
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1654
+		$loginurl = geodir_login_url();
1655
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1656
+		if ($fromEmail == '') {
1657
+			$fromEmail = get_option('site_email');
1658
+		}
1659
+		if ($fromEmailName == '') {
1660
+			$fromEmailName = get_option('site_email_name');
1661
+		}
1662
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1663
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1664
+		$message = str_replace($search_array, $replace_array, $message);
1665
+
1666
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1667
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1668
+		$subject = str_replace($search_array, $replace_array, $subject);
1669
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1670
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1671
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
1672
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1673
+
1674
+		$to = $toEmail;
1675
+
1676
+		$sent = wp_mail($to, $subject, $message, $headers);
1677
+		if( ! $sent ) {
1678
+			if ( is_array( $to ) ) {
1679
+				$to = implode( ',', $to );
1680
+			}
1681
+			$log_message = sprintf(
1682
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1683
+				$message_type,
1684
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1685
+				$to,
1686
+				$subject
1687
+			);
1688
+			geodir_error_log( $log_message );
1689
+		}
1690
+
1691
+		///////// ADMIN BCC EMIALS
1692
+		$admin_bcc = false;
1693
+		if ($message_type == 'registration') {
1694
+			$message_raw = explode(__("Password:", 'geodirectory'), $message);
1695
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1696
+			$message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1697
+		}
1698
+		$adminEmail = get_bloginfo('admin_email');
1699
+		$to = $adminEmail;
1700
+
1701
+		if ($message_type == 'registration' && get_option('bcc_new_user')) {
1702
+			$subject .= ' - ADMIN BCC COPY';
1703
+			$admin_bcc = true;
1704
+		}
1705
+		elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1706
+			$subject .= ' - ADMIN BCC COPY';
1707
+			$admin_bcc = true;
1708
+		}
1709
+		elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1710
+			$subject .= ' - ADMIN BCC COPY';
1711
+			$admin_bcc = true;
1712
+		}
1713
+
1714
+		if($admin_bcc === true){
1715
+			$sent = wp_mail($to, $subject, $message, $headers);
1716
+			if( ! $sent ) {
1717
+				if ( is_array( $to ) ) {
1718
+					$to = implode( ',', $to );
1719
+				}
1720
+				$log_message = sprintf(
1721
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1722
+					$message_type,
1723
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1724
+					$to,
1725
+					$subject
1726
+				);
1727
+				geodir_error_log( $log_message );
1728
+			}
1729
+		}
1730
+
1731
+	}
1732 1732
 }
1733 1733
 
1734 1734
 /*
@@ -1746,16 +1746,16 @@  discard block
 block discarded – undo
1746 1746
  */
1747 1747
 function gd_lang_object_ids($ids_array, $type)
1748 1748
 {
1749
-    if (function_exists('icl_object_id')) {
1750
-        $res = array();
1751
-        foreach ($ids_array as $id) {
1752
-            $xlat = icl_object_id($id, $type, false);
1753
-            if (!is_null($xlat)) $res[] = $xlat;
1754
-        }
1755
-        return $res;
1756
-    } else {
1757
-        return $ids_array;
1758
-    }
1749
+	if (function_exists('icl_object_id')) {
1750
+		$res = array();
1751
+		foreach ($ids_array as $id) {
1752
+			$xlat = icl_object_id($id, $type, false);
1753
+			if (!is_null($xlat)) $res[] = $xlat;
1754
+		}
1755
+		return $res;
1756
+	} else {
1757
+		return $ids_array;
1758
+	}
1759 1759
 }
1760 1760
 
1761 1761
 
@@ -1770,31 +1770,31 @@  discard block
 block discarded – undo
1770 1770
  * @return array Modified Body CSS classes.
1771 1771
  */
1772 1772
 function geodir_custom_posts_body_class($classes) {
1773
-    global $wpdb, $wp;
1774
-    $post_types = geodir_get_posttypes('object');
1775
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1776
-        $classes[] = 'geodir_custom_posts';
1777
-    }
1778
-
1779
-    // fix body class for signup page
1780
-    if (geodir_is_page('login')) {
1781
-        $new_classes = array();
1782
-        $new_classes[] = 'signup page-geodir-signup';
1783
-        if (!empty($classes)) {
1784
-            foreach ($classes as $class) {
1785
-                if ($class && $class != 'home' && $class != 'blog') {
1786
-                    $new_classes[] = $class;
1787
-                }
1788
-            }
1789
-        }
1790
-        $classes = $new_classes;
1791
-    }
1792
-
1793
-    if (geodir_is_geodir_page()) {
1794
-        $classes[] = 'geodir-page';
1795
-    }
1796
-
1797
-    return $classes;
1773
+	global $wpdb, $wp;
1774
+	$post_types = geodir_get_posttypes('object');
1775
+	if (!empty($post_types) && count((array)$post_types) > 1) {
1776
+		$classes[] = 'geodir_custom_posts';
1777
+	}
1778
+
1779
+	// fix body class for signup page
1780
+	if (geodir_is_page('login')) {
1781
+		$new_classes = array();
1782
+		$new_classes[] = 'signup page-geodir-signup';
1783
+		if (!empty($classes)) {
1784
+			foreach ($classes as $class) {
1785
+				if ($class && $class != 'home' && $class != 'blog') {
1786
+					$new_classes[] = $class;
1787
+				}
1788
+			}
1789
+		}
1790
+		$classes = $new_classes;
1791
+	}
1792
+
1793
+	if (geodir_is_geodir_page()) {
1794
+		$classes[] = 'geodir-page';
1795
+	}
1796
+
1797
+	return $classes;
1798 1798
 }
1799 1799
 
1800 1800
 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
@@ -1809,12 +1809,12 @@  discard block
 block discarded – undo
1809 1809
  */
1810 1810
 function geodir_map_zoom_level()
1811 1811
 {
1812
-    /**
1813
-     * Filter GD map zoom level.
1814
-     *
1815
-     * @since 1.0.0
1816
-     */
1817
-    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));
1812
+	/**
1813
+	 * Filter GD map zoom level.
1814
+	 *
1815
+	 * @since 1.0.0
1816
+	 */
1817
+	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));
1818 1818
 
1819 1819
 }
1820 1820
 
@@ -1828,12 +1828,12 @@  discard block
 block discarded – undo
1828 1828
  */
1829 1829
 function geodir_option_version_backup($geodir_option_name)
1830 1830
 {
1831
-    $version_date = time();
1832
-    $geodir_option = get_option($geodir_option_name);
1831
+	$version_date = time();
1832
+	$geodir_option = get_option($geodir_option_name);
1833 1833
 
1834
-    if (!empty($geodir_option)) {
1835
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1836
-    }
1834
+	if (!empty($geodir_option)) {
1835
+		add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1836
+	}
1837 1837
 }
1838 1838
 
1839 1839
 /**
@@ -1846,11 +1846,11 @@  discard block
 block discarded – undo
1846 1846
  */
1847 1847
 function get_page_id_geodir_add_listing_page($page_id)
1848 1848
 {
1849
-    if (geodir_wpml_multilingual_status()) {
1850
-        $post_type = 'post_page';
1851
-        $page_id = geodir_get_wpml_element_id($page_id, $post_type);
1852
-    }
1853
-    return $page_id;
1849
+	if (geodir_wpml_multilingual_status()) {
1850
+		$post_type = 'post_page';
1851
+		$page_id = geodir_get_wpml_element_id($page_id, $post_type);
1852
+	}
1853
+	return $page_id;
1854 1854
 }
1855 1855
 
1856 1856
 /**
@@ -1862,10 +1862,10 @@  discard block
 block discarded – undo
1862 1862
  */
1863 1863
 function geodir_wpml_multilingual_status()
1864 1864
 {
1865
-    if (function_exists('icl_object_id')) {
1866
-        return true;
1867
-    }
1868
-    return false;
1865
+	if (function_exists('icl_object_id')) {
1866
+		return true;
1867
+	}
1868
+	return false;
1869 1869
 }
1870 1870
 
1871 1871
 /**
@@ -1879,22 +1879,22 @@  discard block
 block discarded – undo
1879 1879
  */
1880 1880
 function geodir_get_wpml_element_id($page_id, $post_type)
1881 1881
 {
1882
-    global $sitepress;
1883
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1884
-        $trid = $sitepress->get_element_trid($page_id, $post_type);
1885
-
1886
-        if ($trid > 0) {
1887
-            $translations = $sitepress->get_element_translations($trid, $post_type);
1888
-
1889
-            $lang = $sitepress->get_current_language();
1890
-            $lang = $lang ? $lang : $sitepress->get_default_language();
1891
-
1892
-            if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1893
-                $page_id = $translations[$lang]->element_id;
1894
-            }
1895
-        }
1896
-    }
1897
-    return $page_id;
1882
+	global $sitepress;
1883
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1884
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
1885
+
1886
+		if ($trid > 0) {
1887
+			$translations = $sitepress->get_element_translations($trid, $post_type);
1888
+
1889
+			$lang = $sitepress->get_current_language();
1890
+			$lang = $lang ? $lang : $sitepress->get_default_language();
1891
+
1892
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1893
+				$page_id = $translations[$lang]->element_id;
1894
+			}
1895
+		}
1896
+	}
1897
+	return $page_id;
1898 1898
 }
1899 1899
 
1900 1900
 /**
@@ -1906,20 +1906,20 @@  discard block
 block discarded – undo
1906 1906
  */
1907 1907
 function geodir_wpml_check_element_id()
1908 1908
 {
1909
-    global $sitepress;
1910
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1911
-        $el_type = 'post_page';
1912
-        $el_id = get_option('geodir_add_listing_page');
1913
-        $default_lang = $sitepress->get_default_language();
1914
-        $el_details = $sitepress->get_element_language_details($el_id, $el_type);
1915
-
1916
-        if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1917
-            if (!$el_details->source_language_code) {
1918
-                $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1919
-                $sitepress->icl_translations_cache->clear();
1920
-            }
1921
-        }
1922
-    }
1909
+	global $sitepress;
1910
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1911
+		$el_type = 'post_page';
1912
+		$el_id = get_option('geodir_add_listing_page');
1913
+		$default_lang = $sitepress->get_default_language();
1914
+		$el_details = $sitepress->get_element_language_details($el_id, $el_type);
1915
+
1916
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1917
+			if (!$el_details->source_language_code) {
1918
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1919
+				$sitepress->icl_translations_cache->clear();
1920
+			}
1921
+		}
1922
+	}
1923 1923
 }
1924 1924
 
1925 1925
 /**
@@ -1934,44 +1934,44 @@  discard block
 block discarded – undo
1934 1934
  */
1935 1935
 function geodir_widget_listings_get_order($query_args)
1936 1936
 {
1937
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1938
-
1939
-    $query_args = $gd_query_args_widgets;
1940
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1941
-        return $wpdb->posts . ".post_date DESC, ";
1942
-    }
1943
-
1944
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1945
-    $table = $plugin_prefix . $post_type . '_detail';
1946
-
1947
-    $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1948
-
1949
-    switch ($sort_by) {
1950
-        case 'latest':
1951
-        case 'newest':
1952
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1953
-            break;
1954
-        case 'featured':
1955
-            $orderby = $table . ".is_featured ASC, ";
1956
-            break;
1957
-        case 'az':
1958
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1959
-            break;
1960
-        case 'high_review':
1961
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1962
-            break;
1963
-        case 'high_rating':
1964
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1965
-            break;
1966
-        case 'random':
1967
-            $orderby = "RAND(), ";
1968
-            break;
1969
-        default:
1970
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1971
-            break;
1972
-    }
1973
-
1974
-    return $orderby;
1937
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1938
+
1939
+	$query_args = $gd_query_args_widgets;
1940
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1941
+		return $wpdb->posts . ".post_date DESC, ";
1942
+	}
1943
+
1944
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1945
+	$table = $plugin_prefix . $post_type . '_detail';
1946
+
1947
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1948
+
1949
+	switch ($sort_by) {
1950
+		case 'latest':
1951
+		case 'newest':
1952
+			$orderby = $wpdb->posts . ".post_date DESC, ";
1953
+			break;
1954
+		case 'featured':
1955
+			$orderby = $table . ".is_featured ASC, ";
1956
+			break;
1957
+		case 'az':
1958
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1959
+			break;
1960
+		case 'high_review':
1961
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1962
+			break;
1963
+		case 'high_rating':
1964
+			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
1965
+			break;
1966
+		case 'random':
1967
+			$orderby = "RAND(), ";
1968
+			break;
1969
+		default:
1970
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1971
+			break;
1972
+	}
1973
+
1974
+	return $orderby;
1975 1975
 }
1976 1976
 
1977 1977
 /**
@@ -1989,126 +1989,126 @@  discard block
 block discarded – undo
1989 1989
  */
1990 1990
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
1991 1991
 {
1992
-    global $wpdb, $plugin_prefix, $table_prefix;
1993
-    $GLOBALS['gd_query_args_widgets'] = $query_args;
1994
-    $gd_query_args_widgets = $query_args;
1995
-
1996
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1997
-    $table = $plugin_prefix . $post_type . '_detail';
1998
-
1999
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
2000
-    /**
2001
-     * Filter widget listing fields string part that is being used for query.
2002
-     *
2003
-     * @since 1.0.0
2004
-     * @param string $fields Fields string.
2005
-     * @param string $table Table name.
2006
-     * @param string $post_type Post type.
2007
-     */
2008
-    $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
2009
-
2010
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
2011
-
2012
-    ########### WPML ###########
2013
-
2014
-    if (function_exists('icl_object_id')) {
2015
-        global $sitepress;
2016
-        $lang_code = ICL_LANGUAGE_CODE;
2017
-        if ($lang_code) {
2018
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2019
-        }
2020
-    }
2021
-
2022
-    ########### WPML ###########
2023
-
2024
-    /**
2025
-     * Filter widget listing join clause string part that is being used for query.
2026
-     *
2027
-     * @since 1.0.0
2028
-     * @param string $join Join clause string.
2029
-     * @param string $post_type Post type.
2030
-     */
2031
-    $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2032
-
2033
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2034
-
2035
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2036
-
2037
-    ########### WPML ###########
2038
-    if (function_exists('icl_object_id')) {
2039
-        if ($lang_code) {
2040
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2041
-        }
2042
-    }
2043
-    ########### WPML ###########
2044
-    /**
2045
-     * Filter widget listing where clause string part that is being used for query.
2046
-     *
2047
-     * @since 1.0.0
2048
-     * @param string $where Where clause string.
2049
-     * @param string $post_type Post type.
2050
-     */
2051
-    $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2052
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2053
-
2054
-    $groupby = " GROUP BY $wpdb->posts.ID ";
2055
-    /**
2056
-     * Filter widget listing groupby clause string part that is being used for query.
2057
-     *
2058
-     * @since 1.0.0
2059
-     * @param string $groupby Group by clause string.
2060
-     * @param string $post_type Post type.
2061
-     */
2062
-    $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2063
-
2064
-    if ($count_only) {
2065
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1992
+	global $wpdb, $plugin_prefix, $table_prefix;
1993
+	$GLOBALS['gd_query_args_widgets'] = $query_args;
1994
+	$gd_query_args_widgets = $query_args;
1995
+
1996
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1997
+	$table = $plugin_prefix . $post_type . '_detail';
1998
+
1999
+	$fields = $wpdb->posts . ".*, " . $table . ".*";
2000
+	/**
2001
+	 * Filter widget listing fields string part that is being used for query.
2002
+	 *
2003
+	 * @since 1.0.0
2004
+	 * @param string $fields Fields string.
2005
+	 * @param string $table Table name.
2006
+	 * @param string $post_type Post type.
2007
+	 */
2008
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
2009
+
2010
+	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
2011
+
2012
+	########### WPML ###########
2013
+
2014
+	if (function_exists('icl_object_id')) {
2015
+		global $sitepress;
2016
+		$lang_code = ICL_LANGUAGE_CODE;
2017
+		if ($lang_code) {
2018
+			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2019
+		}
2020
+	}
2021
+
2022
+	########### WPML ###########
2023
+
2024
+	/**
2025
+	 * Filter widget listing join clause string part that is being used for query.
2026
+	 *
2027
+	 * @since 1.0.0
2028
+	 * @param string $join Join clause string.
2029
+	 * @param string $post_type Post type.
2030
+	 */
2031
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2032
+
2033
+	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2034
+
2035
+	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2036
+
2037
+	########### WPML ###########
2038
+	if (function_exists('icl_object_id')) {
2039
+		if ($lang_code) {
2040
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2041
+		}
2042
+	}
2043
+	########### WPML ###########
2044
+	/**
2045
+	 * Filter widget listing where clause string part that is being used for query.
2046
+	 *
2047
+	 * @since 1.0.0
2048
+	 * @param string $where Where clause string.
2049
+	 * @param string $post_type Post type.
2050
+	 */
2051
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2052
+	$where = $where != '' ? " WHERE 1=1 " . $where : '';
2053
+
2054
+	$groupby = " GROUP BY $wpdb->posts.ID ";
2055
+	/**
2056
+	 * Filter widget listing groupby clause string part that is being used for query.
2057
+	 *
2058
+	 * @since 1.0.0
2059
+	 * @param string $groupby Group by clause string.
2060
+	 * @param string $post_type Post type.
2061
+	 */
2062
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2063
+
2064
+	if ($count_only) {
2065
+		$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2066 2066
 			" . $join . "
2067 2067
 			" . $where;
2068
-        $rows = (int)$wpdb->get_var($sql);
2069
-    } else {
2070
-        $orderby = geodir_widget_listings_get_order($query_args);
2071
-        /**
2072
-         * Filter widget listing orderby clause string part that is being used for query.
2073
-         *
2074
-         * @since 1.0.0
2075
-         * @param string $orderby Order by clause string.
2076
-         * @param string $table Table name.
2077
-         * @param string $post_type Post type.
2078
-         */
2079
-        $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2080
-        $orderby .= $wpdb->posts . ".post_title ASC";
2081
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2082
-
2083
-        $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2084
-        /**
2085
-         * Filter widget listing limit that is being used for query.
2086
-         *
2087
-         * @since 1.0.0
2088
-         * @param int $limit Query results limit.
2089
-         * @param string $post_type Post type.
2090
-         */
2091
-        $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2092
-
2093
-        $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2094
-        if ( !$page )
2095
-            $page = 1;
2096
-
2097
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2098
-
2099
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2068
+		$rows = (int)$wpdb->get_var($sql);
2069
+	} else {
2070
+		$orderby = geodir_widget_listings_get_order($query_args);
2071
+		/**
2072
+		 * Filter widget listing orderby clause string part that is being used for query.
2073
+		 *
2074
+		 * @since 1.0.0
2075
+		 * @param string $orderby Order by clause string.
2076
+		 * @param string $table Table name.
2077
+		 * @param string $post_type Post type.
2078
+		 */
2079
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2080
+		$orderby .= $wpdb->posts . ".post_title ASC";
2081
+		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2082
+
2083
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2084
+		/**
2085
+		 * Filter widget listing limit that is being used for query.
2086
+		 *
2087
+		 * @since 1.0.0
2088
+		 * @param int $limit Query results limit.
2089
+		 * @param string $post_type Post type.
2090
+		 */
2091
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2092
+
2093
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2094
+		if ( !$page )
2095
+			$page = 1;
2096
+
2097
+		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2098
+
2099
+		$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2100 2100
 			" . $join . "
2101 2101
 			" . $where . "
2102 2102
 			" . $groupby . "
2103 2103
 			" . $orderby . "
2104 2104
 			" . $limit;
2105
-        $rows = $wpdb->get_results($sql);
2106
-    }
2105
+		$rows = $wpdb->get_results($sql);
2106
+	}
2107 2107
 
2108
-    unset($GLOBALS['gd_query_args_widgets']);
2109
-    unset($gd_query_args_widgets);
2108
+	unset($GLOBALS['gd_query_args_widgets']);
2109
+	unset($gd_query_args_widgets);
2110 2110
 
2111
-    return $rows;
2111
+	return $rows;
2112 2112
 }
2113 2113
 
2114 2114
 /**
@@ -2123,14 +2123,14 @@  discard block
 block discarded – undo
2123 2123
  */
2124 2124
 function geodir_function_widget_listings_fields($fields)
2125 2125
 {
2126
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2126
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2127 2127
 
2128
-    $query_args = $gd_query_args_widgets;
2129
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2130
-        return $fields;
2131
-    }
2128
+	$query_args = $gd_query_args_widgets;
2129
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2130
+		return $fields;
2131
+	}
2132 2132
     
2133
-    return $fields;
2133
+	return $fields;
2134 2134
 }
2135 2135
 
2136 2136
 /**
@@ -2145,28 +2145,28 @@  discard block
 block discarded – undo
2145 2145
  */
2146 2146
 function geodir_function_widget_listings_join($join)
2147 2147
 {
2148
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2148
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2149 2149
 
2150
-    $query_args = $gd_query_args_widgets;
2151
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2152
-        return $join;
2153
-    }
2150
+	$query_args = $gd_query_args_widgets;
2151
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2152
+		return $join;
2153
+	}
2154 2154
 
2155
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2156
-    $table = $plugin_prefix . $post_type . '_detail';
2155
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2156
+	$table = $plugin_prefix . $post_type . '_detail';
2157 2157
 
2158
-    if (!empty($query_args['with_pics_only'])) {
2159
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2160
-    }
2158
+	if (!empty($query_args['with_pics_only'])) {
2159
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2160
+	}
2161 2161
 
2162
-    if (!empty($query_args['tax_query'])) {
2163
-        $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2164
-        if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2165
-            $join .= $tax_queries['join'];
2166
-        }
2167
-    }
2162
+	if (!empty($query_args['tax_query'])) {
2163
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2164
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2165
+			$join .= $tax_queries['join'];
2166
+		}
2167
+	}
2168 2168
 
2169
-    return $join;
2169
+	return $join;
2170 2170
 }
2171 2171
 
2172 2172
 /**
@@ -2181,54 +2181,54 @@  discard block
 block discarded – undo
2181 2181
  */
2182 2182
 function geodir_function_widget_listings_where($where)
2183 2183
 {
2184
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2185
-
2186
-    $query_args = $gd_query_args_widgets;
2187
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2188
-        return $where;
2189
-    }
2190
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2191
-    $table = $plugin_prefix . $post_type . '_detail';
2192
-
2193
-    if (!empty($query_args)) {
2194
-        if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2195
-            $where = geodir_default_location_where($where, $table);
2196
-        }
2197
-
2198
-        if (!empty($query_args['post_author'])) {
2199
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2200
-        }
2184
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2185
+
2186
+	$query_args = $gd_query_args_widgets;
2187
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2188
+		return $where;
2189
+	}
2190
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2191
+	$table = $plugin_prefix . $post_type . '_detail';
2192
+
2193
+	if (!empty($query_args)) {
2194
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2195
+			$where = geodir_default_location_where($where, $table);
2196
+		}
2197
+
2198
+		if (!empty($query_args['post_author'])) {
2199
+			$where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2200
+		}
2201 2201
         
2202
-        if (!empty($query_args['show_featured_only'])) {
2203
-            $where .= " AND " . $table . ".is_featured = '1'";
2204
-        }
2202
+		if (!empty($query_args['show_featured_only'])) {
2203
+			$where .= " AND " . $table . ".is_featured = '1'";
2204
+		}
2205 2205
 
2206
-        if (!empty($query_args['show_special_only'])) {
2207
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2208
-        }
2206
+		if (!empty($query_args['show_special_only'])) {
2207
+			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2208
+		}
2209 2209
 
2210
-        if (!empty($query_args['with_pics_only'])) {
2211
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2212
-        }
2210
+		if (!empty($query_args['with_pics_only'])) {
2211
+			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2212
+		}
2213 2213
 
2214
-        if (!empty($query_args['featured_image_only'])) {
2215
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2216
-        }
2214
+		if (!empty($query_args['featured_image_only'])) {
2215
+			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2216
+		}
2217 2217
 
2218
-        if (!empty($query_args['with_videos_only'])) {
2219
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2220
-        }
2218
+		if (!empty($query_args['with_videos_only'])) {
2219
+			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2220
+		}
2221 2221
 
2222
-        if (!empty($query_args['tax_query'])) {
2223
-            $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2222
+		if (!empty($query_args['tax_query'])) {
2223
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2224 2224
 
2225
-            if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2226
-                $where .= $tax_queries['where'];
2227
-            }
2228
-        }
2229
-    }
2225
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2226
+				$where .= $tax_queries['where'];
2227
+			}
2228
+		}
2229
+	}
2230 2230
 
2231
-    return $where;
2231
+	return $where;
2232 2232
 }
2233 2233
 
2234 2234
 /**
@@ -2243,14 +2243,14 @@  discard block
 block discarded – undo
2243 2243
  */
2244 2244
 function geodir_function_widget_listings_orderby($orderby)
2245 2245
 {
2246
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2246
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2247 2247
 
2248
-    $query_args = $gd_query_args_widgets;
2249
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2250
-        return $orderby;
2251
-    }
2248
+	$query_args = $gd_query_args_widgets;
2249
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2250
+		return $orderby;
2251
+	}
2252 2252
 
2253
-    return $orderby;
2253
+	return $orderby;
2254 2254
 }
2255 2255
 
2256 2256
 /**
@@ -2265,18 +2265,18 @@  discard block
 block discarded – undo
2265 2265
  */
2266 2266
 function geodir_function_widget_listings_limit($limit)
2267 2267
 {
2268
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2268
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2269 2269
 
2270
-    $query_args = $gd_query_args_widgets;
2271
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2272
-        return $limit;
2273
-    }
2270
+	$query_args = $gd_query_args_widgets;
2271
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2272
+		return $limit;
2273
+	}
2274 2274
 
2275
-    if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2276
-        $limit = (int)$query_args['posts_per_page'];
2277
-    }
2275
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2276
+		$limit = (int)$query_args['posts_per_page'];
2277
+	}
2278 2278
 
2279
-    return $limit;
2279
+	return $limit;
2280 2280
 }
2281 2281
 
2282 2282
 /**
@@ -2290,24 +2290,24 @@  discard block
 block discarded – undo
2290 2290
  */
2291 2291
 function geodir_media_image_large_width($default = 800, $params = '')
2292 2292
 {
2293
-    $large_size_w = get_option('large_size_w');
2294
-    $large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2295
-    $large_size_w = absint($large_size_w);
2296
-
2297
-    if (!get_option('geodir_use_wp_media_large_size')) {
2298
-        $large_size_w = 800;
2299
-    }
2300
-
2301
-    /**
2302
-     * Filter large image width.
2303
-     *
2304
-     * @since 1.0.0
2305
-     * @param int $large_size_w Large image width.
2306
-     * @param int $default Default width.
2307
-     * @param string|array $params Image parameters.
2308
-     */
2309
-    $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2310
-    return $large_size_w;
2293
+	$large_size_w = get_option('large_size_w');
2294
+	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2295
+	$large_size_w = absint($large_size_w);
2296
+
2297
+	if (!get_option('geodir_use_wp_media_large_size')) {
2298
+		$large_size_w = 800;
2299
+	}
2300
+
2301
+	/**
2302
+	 * Filter large image width.
2303
+	 *
2304
+	 * @since 1.0.0
2305
+	 * @param int $large_size_w Large image width.
2306
+	 * @param int $default Default width.
2307
+	 * @param string|array $params Image parameters.
2308
+	 */
2309
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2310
+	return $large_size_w;
2311 2311
 }
2312 2312
 
2313 2313
 /**
@@ -2321,25 +2321,25 @@  discard block
 block discarded – undo
2321 2321
  */
2322 2322
 function geodir_media_image_large_height($default = 800, $params = '')
2323 2323
 {
2324
-    $large_size_h = get_option('large_size_h');
2325
-    $large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2326
-    $large_size_h = absint($large_size_h);
2327
-
2328
-    if (!get_option('geodir_use_wp_media_large_size')) {
2329
-        $large_size_h = 800;
2330
-    }
2331
-
2332
-    /**
2333
-     * Filter large image height.
2334
-     *
2335
-     * @since 1.0.0
2336
-     * @param int $large_size_h Large image height.
2337
-     * @param int $default Default height.
2338
-     * @param string|array $params Image parameters.
2339
-     */
2340
-    $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2341
-
2342
-    return $large_size_h;
2324
+	$large_size_h = get_option('large_size_h');
2325
+	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2326
+	$large_size_h = absint($large_size_h);
2327
+
2328
+	if (!get_option('geodir_use_wp_media_large_size')) {
2329
+		$large_size_h = 800;
2330
+	}
2331
+
2332
+	/**
2333
+	 * Filter large image height.
2334
+	 *
2335
+	 * @since 1.0.0
2336
+	 * @param int $large_size_h Large image height.
2337
+	 * @param int $default Default height.
2338
+	 * @param string|array $params Image parameters.
2339
+	 */
2340
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2341
+
2342
+	return $large_size_h;
2343 2343
 }
2344 2344
 
2345 2345
 /**
@@ -2354,25 +2354,25 @@  discard block
 block discarded – undo
2354 2354
  */
2355 2355
 function geodir_sanitize_location_name($type, $name, $translate = true)
2356 2356
 {
2357
-    if ($name == '') {
2358
-        return NULL;
2359
-    }
2360
-
2361
-    $type = $type == 'gd_country' ? 'country' : $type;
2362
-    $type = $type == 'gd_region' ? 'region' : $type;
2363
-    $type = $type == 'gd_city' ? 'city' : $type;
2364
-
2365
-    $return = $name;
2366
-    if (function_exists('get_actual_location_name')) {
2367
-        $return = get_actual_location_name($type, $name, $translate);
2368
-    } else {
2369
-        $return = preg_replace('/-(\d+)$/', '', $return);
2370
-        $return = preg_replace('/[_-]/', ' ', $return);
2371
-        $return = geodir_ucwords($return);
2372
-        $return = $translate ? __($return, 'geodirectory') : $return;
2373
-    }
2374
-
2375
-    return $return;
2357
+	if ($name == '') {
2358
+		return NULL;
2359
+	}
2360
+
2361
+	$type = $type == 'gd_country' ? 'country' : $type;
2362
+	$type = $type == 'gd_region' ? 'region' : $type;
2363
+	$type = $type == 'gd_city' ? 'city' : $type;
2364
+
2365
+	$return = $name;
2366
+	if (function_exists('get_actual_location_name')) {
2367
+		$return = get_actual_location_name($type, $name, $translate);
2368
+	} else {
2369
+		$return = preg_replace('/-(\d+)$/', '', $return);
2370
+		$return = preg_replace('/[_-]/', ' ', $return);
2371
+		$return = geodir_ucwords($return);
2372
+		$return = $translate ? __($return, 'geodirectory') : $return;
2373
+	}
2374
+
2375
+	return $return;
2376 2376
 }
2377 2377
 
2378 2378
 
@@ -2386,14 +2386,14 @@  discard block
 block discarded – undo
2386 2386
 function geodir_comments_number($number)
2387 2387
 {
2388 2388
 
2389
-    if ($number > 1) {
2390
-        $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2391
-    } elseif ($number == 0 || $number == '') {
2392
-        $output = __('No Reviews', 'geodirectory');
2393
-    } else { // must be one
2394
-        $output = __('1 Review', 'geodirectory');
2395
-    }
2396
-    echo $output;
2389
+	if ($number > 1) {
2390
+		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2391
+	} elseif ($number == 0 || $number == '') {
2392
+		$output = __('No Reviews', 'geodirectory');
2393
+	} else { // must be one
2394
+		$output = __('1 Review', 'geodirectory');
2395
+	}
2396
+	echo $output;
2397 2397
 }
2398 2398
 
2399 2399
 /**
@@ -2406,23 +2406,23 @@  discard block
 block discarded – undo
2406 2406
  */
2407 2407
 function is_page_geodir_home()
2408 2408
 {
2409
-    global $wpdb;
2410
-    $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2411
-    if (function_exists('geodir_location_geo_home_link')) {
2412
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2413
-    }
2414
-    $home_url = home_url('', 'http');
2415
-    if (function_exists('geodir_location_geo_home_link')) {
2416
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2417
-    }
2418
-    $home_url = str_replace("www.", "", $home_url);
2419
-    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')) ) {
2420
-        return true;
2421
-    }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')){
2422
-        return true;
2423
-    } else {
2424
-        return false;
2425
-    }
2409
+	global $wpdb;
2410
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2411
+	if (function_exists('geodir_location_geo_home_link')) {
2412
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2413
+	}
2414
+	$home_url = home_url('', 'http');
2415
+	if (function_exists('geodir_location_geo_home_link')) {
2416
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2417
+	}
2418
+	$home_url = str_replace("www.", "", $home_url);
2419
+	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')) ) {
2420
+		return true;
2421
+	}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')){
2422
+		return true;
2423
+	} else {
2424
+		return false;
2425
+	}
2426 2426
 
2427 2427
 }
2428 2428
 
@@ -2438,13 +2438,13 @@  discard block
 block discarded – undo
2438 2438
  */
2439 2439
 function geodir_wpseo_homepage_canonical($url)
2440 2440
 {
2441
-    global $post;
2441
+	global $post;
2442 2442
 
2443
-    if (is_page_geodir_home()) {
2444
-        return home_url();
2445
-    }
2443
+	if (is_page_geodir_home()) {
2444
+		return home_url();
2445
+	}
2446 2446
 
2447
-    return $url;
2447
+	return $url;
2448 2448
 }
2449 2449
 
2450 2450
 add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
@@ -2461,16 +2461,16 @@  discard block
 block discarded – undo
2461 2461
  */
2462 2462
 function geodir_googlemap_script_extra_details_page($extra)
2463 2463
 {
2464
-    global $post;
2465
-    $add_google_places_api = false;
2466
-    if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2467
-        $add_google_places_api = true;
2468
-    }
2469
-    if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2470
-        $extra .= "&amp;libraries=places";
2471
-    }
2472
-
2473
-    return $extra;
2464
+	global $post;
2465
+	$add_google_places_api = false;
2466
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2467
+		$add_google_places_api = true;
2468
+	}
2469
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2470
+		$extra .= "&amp;libraries=places";
2471
+	}
2472
+
2473
+	return $extra;
2474 2474
 }
2475 2475
 
2476 2476
 add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
@@ -2490,98 +2490,98 @@  discard block
 block discarded – undo
2490 2490
  */
2491 2491
 function geodir_popular_post_category_output($args = '', $instance = '')
2492 2492
 {
2493
-    // prints the widget
2494
-    global $wpdb, $plugin_prefix, $geodir_post_category_str;
2495
-    extract($args, EXTR_SKIP);
2496
-
2497
-    echo $before_widget;
2498
-
2499
-    /** This filter is documented in geodirectory_widgets.php */
2500
-    $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2501
-
2502
-    $gd_post_type = geodir_get_current_posttype();
2503
-
2504
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2505
-    if(!empty($gd_post_type)){
2506
-        $default_post_type = $gd_post_type;
2507
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2508
-        $default_post_type = $instance['default_post_type'];
2509
-    }else{
2510
-        $all_gd_post_type = geodir_get_posttypes();
2511
-        $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2512
-    }
2513
-
2514
-    $taxonomy = array();
2515
-    if (!empty($gd_post_type)) {
2516
-        $taxonomy[] = $gd_post_type . "category";
2517
-    } else {
2518
-        $taxonomy = geodir_get_taxonomies($gd_post_type);
2519
-    }
2520
-
2521
-    $terms = get_terms($taxonomy);
2522
-    $a_terms = array();
2523
-    $b_terms = array();
2524
-
2525
-    foreach ($terms as $term) {
2526
-        if ($term->count > 0) {
2527
-            $a_terms[$term->taxonomy][] = $term;
2528
-        }
2529
-    }
2530
-
2531
-    if (!empty($a_terms)) {
2532
-        foreach ($a_terms as $b_key => $b_val) {
2533
-            $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2534
-        }
2535
-
2536
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2537
-
2538
-        $tax_change_output = '';
2539
-        if (count($b_terms) > 1) {
2540
-            $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2541
-            foreach ($b_terms as $key => $val) {
2542
-                $ptype = get_post_type_object(str_replace("category", "", $key));
2543
-                $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2544
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2545
-            }
2546
-            $tax_change_output .= "</select>";
2547
-        }
2548
-
2549
-        if (!empty($b_terms)) {
2550
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2551
-            global $cat_count;//make global so we can change via function
2552
-            $cat_count = 0;
2553
-            ?>
2493
+	// prints the widget
2494
+	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2495
+	extract($args, EXTR_SKIP);
2496
+
2497
+	echo $before_widget;
2498
+
2499
+	/** This filter is documented in geodirectory_widgets.php */
2500
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2501
+
2502
+	$gd_post_type = geodir_get_current_posttype();
2503
+
2504
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2505
+	if(!empty($gd_post_type)){
2506
+		$default_post_type = $gd_post_type;
2507
+	}elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2508
+		$default_post_type = $instance['default_post_type'];
2509
+	}else{
2510
+		$all_gd_post_type = geodir_get_posttypes();
2511
+		$default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2512
+	}
2513
+
2514
+	$taxonomy = array();
2515
+	if (!empty($gd_post_type)) {
2516
+		$taxonomy[] = $gd_post_type . "category";
2517
+	} else {
2518
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2519
+	}
2520
+
2521
+	$terms = get_terms($taxonomy);
2522
+	$a_terms = array();
2523
+	$b_terms = array();
2524
+
2525
+	foreach ($terms as $term) {
2526
+		if ($term->count > 0) {
2527
+			$a_terms[$term->taxonomy][] = $term;
2528
+		}
2529
+	}
2530
+
2531
+	if (!empty($a_terms)) {
2532
+		foreach ($a_terms as $b_key => $b_val) {
2533
+			$b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2534
+		}
2535
+
2536
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2537
+
2538
+		$tax_change_output = '';
2539
+		if (count($b_terms) > 1) {
2540
+			$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2541
+			foreach ($b_terms as $key => $val) {
2542
+				$ptype = get_post_type_object(str_replace("category", "", $key));
2543
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2544
+				$tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2545
+			}
2546
+			$tax_change_output .= "</select>";
2547
+		}
2548
+
2549
+		if (!empty($b_terms)) {
2550
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2551
+			global $cat_count;//make global so we can change via function
2552
+			$cat_count = 0;
2553
+			?>
2554 2554
             <div class="geodir-category-list-in clearfix">
2555 2555
                 <div class="geodir-cat-list clearfix">
2556 2556
                     <?php
2557
-                    echo $before_title . __($title) . $after_title;
2557
+					echo $before_title . __($title) . $after_title;
2558 2558
 
2559
-                    echo $tax_change_output;
2559
+					echo $tax_change_output;
2560 2560
 
2561
-                    echo '<ul class="geodir-popular-cat-list">';
2561
+					echo '<ul class="geodir-popular-cat-list">';
2562 2562
 
2563
-                    geodir_helper_cat_list_output($terms, $category_limit);
2563
+					geodir_helper_cat_list_output($terms, $category_limit);
2564 2564
 
2565
-                    echo '</ul>';
2566
-                    ?>
2565
+					echo '</ul>';
2566
+					?>
2567 2567
                 </div>
2568 2568
                 <?php
2569
-                $hide = '';
2570
-                if ($cat_count < $category_limit) {
2571
-                    $hide = 'style="display:none;"';
2572
-                }
2573
-                echo "<div class='geodir-cat-list-more' $hide >";
2574
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2575
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2576
-                echo "</div>";
2577
-                /* add scripts */
2578
-                add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2579
-                ?>
2569
+				$hide = '';
2570
+				if ($cat_count < $category_limit) {
2571
+					$hide = 'style="display:none;"';
2572
+				}
2573
+				echo "<div class='geodir-cat-list-more' $hide >";
2574
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2575
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2576
+				echo "</div>";
2577
+				/* add scripts */
2578
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2579
+				?>
2580 2580
             </div>
2581 2581
         <?php
2582
-        }
2583
-    }
2584
-    echo $after_widget;
2582
+		}
2583
+	}
2584
+	echo $after_widget;
2585 2585
 }
2586 2586
 
2587 2587
 /**
@@ -2595,38 +2595,38 @@  discard block
 block discarded – undo
2595 2595
  */
2596 2596
 function geodir_helper_cat_list_output($terms, $category_limit)
2597 2597
 {
2598
-    global $geodir_post_category_str, $cat_count;
2599
-    $term_icons = geodir_get_term_icon();
2598
+	global $geodir_post_category_str, $cat_count;
2599
+	$term_icons = geodir_get_term_icon();
2600 2600
 
2601
-    $geodir_post_category_str = array();
2601
+	$geodir_post_category_str = array();
2602 2602
 
2603 2603
 
2604
-    foreach ($terms as $cat) {
2605
-        $post_type = str_replace("category", "", $cat->taxonomy);
2606
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2604
+	foreach ($terms as $cat) {
2605
+		$post_type = str_replace("category", "", $cat->taxonomy);
2606
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2607 2607
 
2608
-        $cat_count++;
2608
+		$cat_count++;
2609 2609
 
2610
-        $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2610
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2611 2611
 
2612
-        $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2613
-        $total_post = $cat->count;
2612
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2613
+		$total_post = $cat->count;
2614 2614
 
2615
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2616
-        /**
2617
-         * Filer the category term link.
2618
-         *
2619
-         * @since 1.4.5
2620
-         * @param string $term_link The term permalink.
2621
-         * @param int    $cat->term_id The term id.
2622
-         * @param string $post_type Wordpress post type.
2623
-         */
2624
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2615
+		$term_link = get_term_link( $cat, $cat->taxonomy );
2616
+		/**
2617
+		 * Filer the category term link.
2618
+		 *
2619
+		 * @since 1.4.5
2620
+		 * @param string $term_link The term permalink.
2621
+		 * @param int    $cat->term_id The term id.
2622
+		 * @param string $post_type Wordpress post type.
2623
+		 */
2624
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2625 2625
 
2626
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2627
-        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> ';
2628
-        echo '</a></li>';
2629
-    }
2626
+		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2627
+		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> ';
2628
+		echo '</a></li>';
2629
+	}
2630 2630
 }
2631 2631
 
2632 2632
 /**
@@ -2640,108 +2640,108 @@  discard block
 block discarded – undo
2640 2640
  */
2641 2641
 function geodir_listing_slider_widget_output($args = '', $instance = '')
2642 2642
 {
2643
-    // prints the widget
2644
-    extract($args, EXTR_SKIP);
2645
-
2646
-    echo $before_widget;
2647
-
2648
-    /** This filter is documented in geodirectory_widgets.php */
2649
-    $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2650
-    /**
2651
-     * Filter the widget post type.
2652
-     *
2653
-     * @since 1.0.0
2654
-     * @param string $instance['post_type'] Post type of listing.
2655
-     */
2656
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2657
-    /**
2658
-     * Filter the widget's term.
2659
-     *
2660
-     * @since 1.0.0
2661
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2662
-     */
2663
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2664
-    /**
2665
-     * Filter the widget listings limit.
2666
-     *
2667
-     * @since 1.0.0
2668
-     * @param string $instance['post_number'] Number of listings to display.
2669
-     */
2670
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2671
-    /**
2672
-     * Filter the widget listings limit shown at one time.
2673
-     *
2674
-     * @since 1.5.0
2675
-     * @param string $instance['max_show'] Number of listings to display on screen.
2676
-     */
2677
-    $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2678
-    /**
2679
-     * Filter the widget slide width.
2680
-     *
2681
-     * @since 1.5.0
2682
-     * @param string $instance['slide_width'] Width of the slides shown.
2683
-     */
2684
-    $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2685
-    /**
2686
-     * Filter widget's "show title" value.
2687
-     *
2688
-     * @since 1.0.0
2689
-     * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2690
-     */
2691
-    $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2692
-    /**
2693
-     * Filter widget's "slideshow" value.
2694
-     *
2695
-     * @since 1.0.0
2696
-     * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2697
-     */
2698
-    $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2699
-    /**
2700
-     * Filter widget's "animationLoop" value.
2701
-     *
2702
-     * @since 1.0.0
2703
-     * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2704
-     */
2705
-    $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2706
-    /**
2707
-     * Filter widget's "directionNav" value.
2708
-     *
2709
-     * @since 1.0.0
2710
-     * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2711
-     */
2712
-    $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2713
-    /**
2714
-     * Filter widget's "slideshowSpeed" value.
2715
-     *
2716
-     * @since 1.0.0
2717
-     * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2718
-     */
2719
-    $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2720
-    /**
2721
-     * Filter widget's "animationSpeed" value.
2722
-     *
2723
-     * @since 1.0.0
2724
-     * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2725
-     */
2726
-    $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2727
-    /**
2728
-     * Filter widget's "animation" value.
2729
-     *
2730
-     * @since 1.0.0
2731
-     * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2732
-     */
2733
-    $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2734
-    /**
2735
-     * Filter widget's "list_sort" type.
2736
-     *
2737
-     * @since 1.0.0
2738
-     * @param string $instance['list_sort'] Listing sort by type.
2739
-     */
2740
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2741
-    $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2742
-
2743
-    wp_enqueue_script('geodirectory-jquery-flexslider-js');
2744
-    ?>
2643
+	// prints the widget
2644
+	extract($args, EXTR_SKIP);
2645
+
2646
+	echo $before_widget;
2647
+
2648
+	/** This filter is documented in geodirectory_widgets.php */
2649
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2650
+	/**
2651
+	 * Filter the widget post type.
2652
+	 *
2653
+	 * @since 1.0.0
2654
+	 * @param string $instance['post_type'] Post type of listing.
2655
+	 */
2656
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2657
+	/**
2658
+	 * Filter the widget's term.
2659
+	 *
2660
+	 * @since 1.0.0
2661
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2662
+	 */
2663
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2664
+	/**
2665
+	 * Filter the widget listings limit.
2666
+	 *
2667
+	 * @since 1.0.0
2668
+	 * @param string $instance['post_number'] Number of listings to display.
2669
+	 */
2670
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2671
+	/**
2672
+	 * Filter the widget listings limit shown at one time.
2673
+	 *
2674
+	 * @since 1.5.0
2675
+	 * @param string $instance['max_show'] Number of listings to display on screen.
2676
+	 */
2677
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2678
+	/**
2679
+	 * Filter the widget slide width.
2680
+	 *
2681
+	 * @since 1.5.0
2682
+	 * @param string $instance['slide_width'] Width of the slides shown.
2683
+	 */
2684
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2685
+	/**
2686
+	 * Filter widget's "show title" value.
2687
+	 *
2688
+	 * @since 1.0.0
2689
+	 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2690
+	 */
2691
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2692
+	/**
2693
+	 * Filter widget's "slideshow" value.
2694
+	 *
2695
+	 * @since 1.0.0
2696
+	 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2697
+	 */
2698
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2699
+	/**
2700
+	 * Filter widget's "animationLoop" value.
2701
+	 *
2702
+	 * @since 1.0.0
2703
+	 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2704
+	 */
2705
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2706
+	/**
2707
+	 * Filter widget's "directionNav" value.
2708
+	 *
2709
+	 * @since 1.0.0
2710
+	 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2711
+	 */
2712
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2713
+	/**
2714
+	 * Filter widget's "slideshowSpeed" value.
2715
+	 *
2716
+	 * @since 1.0.0
2717
+	 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2718
+	 */
2719
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2720
+	/**
2721
+	 * Filter widget's "animationSpeed" value.
2722
+	 *
2723
+	 * @since 1.0.0
2724
+	 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2725
+	 */
2726
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2727
+	/**
2728
+	 * Filter widget's "animation" value.
2729
+	 *
2730
+	 * @since 1.0.0
2731
+	 * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2732
+	 */
2733
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2734
+	/**
2735
+	 * Filter widget's "list_sort" type.
2736
+	 *
2737
+	 * @since 1.0.0
2738
+	 * @param string $instance['list_sort'] Listing sort by type.
2739
+	 */
2740
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2741
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2742
+
2743
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
2744
+	?>
2745 2745
     <script type="text/javascript">
2746 2746
         jQuery(window).load(function () {
2747 2747
             jQuery('#geodir_widget_carousel').flexslider({
@@ -2782,86 +2782,86 @@  discard block
 block discarded – undo
2782 2782
         });
2783 2783
     </script>
2784 2784
     <?php
2785
-    $query_args = array(
2786
-        'posts_per_page' => $post_number,
2787
-        'is_geodir_loop' => true,
2788
-        'post_type' => $post_type,
2789
-        'order_by' => $list_sort
2790
-    );
2791
-    if ($show_featured_only) {
2792
-        $query_args['show_featured_only'] = 1;
2793
-    }
2794
-
2795
-    if ($category != 0 || $category != '') {
2796
-        $category_taxonomy = geodir_get_taxonomies($post_type);
2797
-        $tax_query = array(
2798
-            'taxonomy' => $category_taxonomy[0],
2799
-            'field' => 'id',
2800
-            'terms' => $category
2801
-        );
2802
-
2803
-        $query_args['tax_query'] = array($tax_query);
2804
-    }
2805
-
2806
-    // we want listings with featured image only
2807
-    $query_args['featured_image_only'] = 1;
2808
-
2809
-    if ($post_type == 'gd_event') {
2810
-        $query_args['gedir_event_listing_filter'] = 'upcoming';
2811
-    }// show only upcoming events
2812
-
2813
-    $widget_listings = geodir_get_widget_listings($query_args);
2814
-    if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2815
-        if ($title) {
2816
-            echo $before_title . $title . $after_title;
2817
-        }
2818
-
2819
-        global $post;
2820
-
2821
-        $current_post = $post;// keep current post info
2822
-
2823
-        $widget_main_slides = '';
2824
-        $nav_slides = '';
2825
-        $widget_slides = 0;
2826
-
2827
-        foreach ($widget_listings as $widget_listing) {
2828
-            global $gd_widget_listing_type;
2829
-            $post = $widget_listing;
2830
-            $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2831
-
2832
-            if (!empty($widget_image)) {
2833
-                if ($widget_image->height >= 200) {
2834
-                    $widget_spacer_height = 0;
2835
-                } else {
2836
-                    $widget_spacer_height = ((200 - $widget_image->height) / 2);
2837
-                }
2838
-
2839
-                $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" />';
2840
-
2841
-                $title = '';
2842
-                if ($show_title) {
2843
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2844
-                    $post_id = $post->ID;
2845
-                    $post_permalink = get_permalink($post->ID);
2846
-                    $post_title = get_the_title($post->ID);
2847
-                    /**
2848
-                     * Filter the listing slider widget title.
2849
-                     *
2850
-                     * @since 1.6.1
2851
-                     * @param string $title_html The html output of the title.
2852
-                     * @param int $post_id The post id.
2853
-                     * @param string $post_permalink The post permalink url.
2854
-                     * @param string $post_title The post title text.
2855
-                     */
2856
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2857
-                }
2858
-
2859
-                $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>';
2860
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2861
-                $widget_slides++;
2862
-            }
2863
-        }
2864
-        ?>
2785
+	$query_args = array(
2786
+		'posts_per_page' => $post_number,
2787
+		'is_geodir_loop' => true,
2788
+		'post_type' => $post_type,
2789
+		'order_by' => $list_sort
2790
+	);
2791
+	if ($show_featured_only) {
2792
+		$query_args['show_featured_only'] = 1;
2793
+	}
2794
+
2795
+	if ($category != 0 || $category != '') {
2796
+		$category_taxonomy = geodir_get_taxonomies($post_type);
2797
+		$tax_query = array(
2798
+			'taxonomy' => $category_taxonomy[0],
2799
+			'field' => 'id',
2800
+			'terms' => $category
2801
+		);
2802
+
2803
+		$query_args['tax_query'] = array($tax_query);
2804
+	}
2805
+
2806
+	// we want listings with featured image only
2807
+	$query_args['featured_image_only'] = 1;
2808
+
2809
+	if ($post_type == 'gd_event') {
2810
+		$query_args['gedir_event_listing_filter'] = 'upcoming';
2811
+	}// show only upcoming events
2812
+
2813
+	$widget_listings = geodir_get_widget_listings($query_args);
2814
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2815
+		if ($title) {
2816
+			echo $before_title . $title . $after_title;
2817
+		}
2818
+
2819
+		global $post;
2820
+
2821
+		$current_post = $post;// keep current post info
2822
+
2823
+		$widget_main_slides = '';
2824
+		$nav_slides = '';
2825
+		$widget_slides = 0;
2826
+
2827
+		foreach ($widget_listings as $widget_listing) {
2828
+			global $gd_widget_listing_type;
2829
+			$post = $widget_listing;
2830
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2831
+
2832
+			if (!empty($widget_image)) {
2833
+				if ($widget_image->height >= 200) {
2834
+					$widget_spacer_height = 0;
2835
+				} else {
2836
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
2837
+				}
2838
+
2839
+				$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" />';
2840
+
2841
+				$title = '';
2842
+				if ($show_title) {
2843
+					$title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2844
+					$post_id = $post->ID;
2845
+					$post_permalink = get_permalink($post->ID);
2846
+					$post_title = get_the_title($post->ID);
2847
+					/**
2848
+					 * Filter the listing slider widget title.
2849
+					 *
2850
+					 * @since 1.6.1
2851
+					 * @param string $title_html The html output of the title.
2852
+					 * @param int $post_id The post id.
2853
+					 * @param string $post_permalink The post permalink url.
2854
+					 * @param string $post_title The post title text.
2855
+					 */
2856
+					$title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2857
+				}
2858
+
2859
+				$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>';
2860
+				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2861
+				$widget_slides++;
2862
+			}
2863
+		}
2864
+		?>
2865 2865
         <div class="flex-container" style="min-height:200px;">
2866 2866
             <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
2867 2867
             <div id="geodir_widget_slider" class="geodir_flexslider">
@@ -2874,10 +2874,10 @@  discard block
 block discarded – undo
2874 2874
             <?php } ?>
2875 2875
         </div>
2876 2876
         <?php
2877
-        $GLOBALS['post'] = $current_post;
2878
-        setup_postdata($current_post);
2879
-    }
2880
-    echo $after_widget;
2877
+		$GLOBALS['post'] = $current_post;
2878
+		setup_postdata($current_post);
2879
+	}
2880
+	echo $after_widget;
2881 2881
 }
2882 2882
 
2883 2883
 
@@ -2892,65 +2892,65 @@  discard block
 block discarded – undo
2892 2892
  */
2893 2893
 function geodir_loginwidget_output($args = '', $instance = '')
2894 2894
 {
2895
-    //print_r($args);
2896
-    //print_r($instance);
2897
-    // prints the widget
2898
-    extract($args, EXTR_SKIP);
2895
+	//print_r($args);
2896
+	//print_r($instance);
2897
+	// prints the widget
2898
+	extract($args, EXTR_SKIP);
2899 2899
 
2900
-    /** This filter is documented in geodirectory_widgets.php */
2901
-    $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2900
+	/** This filter is documented in geodirectory_widgets.php */
2901
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2902 2902
 
2903
-    echo $before_widget;
2904
-    echo $before_title . $title . $after_title;
2903
+	echo $before_widget;
2904
+	echo $before_title . $title . $after_title;
2905 2905
 
2906
-    if (is_user_logged_in()) {
2907
-        global $current_user;
2906
+	if (is_user_logged_in()) {
2907
+		global $current_user;
2908 2908
 
2909
-        $author_link = get_author_posts_url($current_user->data->ID);
2910
-        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2909
+		$author_link = get_author_posts_url($current_user->data->ID);
2910
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2911 2911
 
2912
-        echo '<ul class="geodir-loginbox-list">';
2913
-        ob_start();
2914
-        ?>
2912
+		echo '<ul class="geodir-loginbox-list">';
2913
+		ob_start();
2914
+		?>
2915 2915
         <li><a class="signin"
2916 2916
                href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
2917 2917
         <?php
2918
-        $post_types = geodir_get_posttypes('object');
2919
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2920
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2918
+		$post_types = geodir_get_posttypes('object');
2919
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2920
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2921 2921
 
2922
-        if (!empty($show_add_listing_post_types_main_nav)) {
2923
-            $addlisting_links = '';
2924
-            foreach ($post_types as $key => $postobj) {
2922
+		if (!empty($show_add_listing_post_types_main_nav)) {
2923
+			$addlisting_links = '';
2924
+			foreach ($post_types as $key => $postobj) {
2925 2925
 
2926
-                if (in_array($key, $show_add_listing_post_types_main_nav)) {
2926
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
2927 2927
 
2928
-                    if ($add_link = geodir_get_addlisting_link($key)) {
2928
+					if ($add_link = geodir_get_addlisting_link($key)) {
2929 2929
 
2930
-                        $name = $postobj->labels->name;
2930
+						$name = $postobj->labels->name;
2931 2931
 
2932
-                        $selected = '';
2933
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2934
-                            $selected = 'selected="selected"';
2932
+						$selected = '';
2933
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2934
+							$selected = 'selected="selected"';
2935 2935
 
2936
-                        /**
2937
-                         * Filter add listing link.
2938
-                         *
2939
-                         * @since 1.0.0
2940
-                         * @param string $add_link Add listing link.
2941
-                         * @param string $key Add listing array key.
2942
-                         * @param int $current_user->ID Current user ID.
2943
-                         */
2944
-                        $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2936
+						/**
2937
+						 * Filter add listing link.
2938
+						 *
2939
+						 * @since 1.0.0
2940
+						 * @param string $add_link Add listing link.
2941
+						 * @param string $key Add listing array key.
2942
+						 * @param int $current_user->ID Current user ID.
2943
+						 */
2944
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2945 2945
 
2946
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2946
+						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2947 2947
 
2948
-                    }
2949
-                }
2948
+					}
2949
+				}
2950 2950
 
2951
-            }
2951
+			}
2952 2952
 
2953
-            if ($addlisting_links != '') { ?>
2953
+			if ($addlisting_links != '') { ?>
2954 2954
 
2955 2955
                 <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
2956 2956
                             option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
@@ -2959,42 +2959,42 @@  discard block
 block discarded – undo
2959 2959
                         <?php echo $addlisting_links; ?>
2960 2960
                     </select></li> <?php
2961 2961
 
2962
-            }
2963
-
2964
-        }
2965
-        // My Favourites in Dashboard
2966
-        $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2967
-        $user_favourite = geodir_user_favourite_listing_count();
2968
-
2969
-        if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2970
-            $favourite_links = '';
2971
-
2972
-            foreach ($post_types as $key => $postobj) {
2973
-                if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2974
-                    $name = $postobj->labels->name;
2975
-                    $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2976
-
2977
-                    $selected = '';
2978
-
2979
-                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2980
-                        $selected = 'selected="selected"';
2981
-                    }
2982
-                    /**
2983
-                     * Filter favorite listing link.
2984
-                     *
2985
-                     * @since 1.0.0
2986
-                     * @param string $post_type_link Favorite listing link.
2987
-                     * @param string $key Favorite listing array key.
2988
-                     * @param int $current_user->ID Current user ID.
2989
-                     */
2990
-                    $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2991
-
2992
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2993
-                }
2994
-            }
2995
-
2996
-            if ($favourite_links != '') {
2997
-                ?>
2962
+			}
2963
+
2964
+		}
2965
+		// My Favourites in Dashboard
2966
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2967
+		$user_favourite = geodir_user_favourite_listing_count();
2968
+
2969
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2970
+			$favourite_links = '';
2971
+
2972
+			foreach ($post_types as $key => $postobj) {
2973
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2974
+					$name = $postobj->labels->name;
2975
+					$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2976
+
2977
+					$selected = '';
2978
+
2979
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2980
+						$selected = 'selected="selected"';
2981
+					}
2982
+					/**
2983
+					 * Filter favorite listing link.
2984
+					 *
2985
+					 * @since 1.0.0
2986
+					 * @param string $post_type_link Favorite listing link.
2987
+					 * @param string $key Favorite listing array key.
2988
+					 * @param int $current_user->ID Current user ID.
2989
+					 */
2990
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2991
+
2992
+					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2993
+				}
2994
+			}
2995
+
2996
+			if ($favourite_links != '') {
2997
+				?>
2998 2998
                 <li>
2999 2999
                     <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
3000 3000
                             option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
@@ -3004,42 +3004,42 @@  discard block
 block discarded – undo
3004 3004
                     </select>
3005 3005
                 </li>
3006 3006
             <?php
3007
-            }
3008
-        }
3009
-
3010
-
3011
-        $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
3012
-        $user_listing = geodir_user_post_listing_count();
3013
-
3014
-        if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
3015
-            $listing_links = '';
3016
-
3017
-            foreach ($post_types as $key => $postobj) {
3018
-                if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
3019
-                    $name = $postobj->labels->name;
3020
-                    $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
3021
-
3022
-                    $selected = '';
3023
-                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
3024
-                        $selected = 'selected="selected"';
3025
-                    }
3026
-
3027
-                    /**
3028
-                     * Filter my listing link.
3029
-                     *
3030
-                     * @since 1.0.0
3031
-                     * @param string $listing_link My listing link.
3032
-                     * @param string $key My listing array key.
3033
-                     * @param int $current_user->ID Current user ID.
3034
-                     */
3035
-                    $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3036
-
3037
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3038
-                }
3039
-            }
3040
-
3041
-            if ($listing_links != '') {
3042
-                ?>
3007
+			}
3008
+		}
3009
+
3010
+
3011
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
3012
+		$user_listing = geodir_user_post_listing_count();
3013
+
3014
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
3015
+			$listing_links = '';
3016
+
3017
+			foreach ($post_types as $key => $postobj) {
3018
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
3019
+					$name = $postobj->labels->name;
3020
+					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
3021
+
3022
+					$selected = '';
3023
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
3024
+						$selected = 'selected="selected"';
3025
+					}
3026
+
3027
+					/**
3028
+					 * Filter my listing link.
3029
+					 *
3030
+					 * @since 1.0.0
3031
+					 * @param string $listing_link My listing link.
3032
+					 * @param string $key My listing array key.
3033
+					 * @param int $current_user->ID Current user ID.
3034
+					 */
3035
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3036
+
3037
+					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3038
+				}
3039
+			}
3040
+
3041
+			if ($listing_links != '') {
3042
+				?>
3043 3043
                 <li>
3044 3044
                     <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
3045 3045
                             option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
@@ -3049,27 +3049,27 @@  discard block
 block discarded – undo
3049 3049
                     </select>
3050 3050
                 </li>
3051 3051
             <?php
3052
-            }
3053
-        }
3054
-
3055
-        $dashboard_link = ob_get_clean();
3056
-        /**
3057
-         * Filter dashboard links HTML.
3058
-         *
3059
-         * @since 1.0.0
3060
-         * @param string $dashboard_link Dashboard links HTML.
3061
-         */
3062
-        echo apply_filters('geodir_dashboard_links', $dashboard_link);
3063
-        echo '</ul>';
3064
-    } else {
3065
-        ?>
3052
+			}
3053
+		}
3054
+
3055
+		$dashboard_link = ob_get_clean();
3056
+		/**
3057
+		 * Filter dashboard links HTML.
3058
+		 *
3059
+		 * @since 1.0.0
3060
+		 * @param string $dashboard_link Dashboard links HTML.
3061
+		 */
3062
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
3063
+		echo '</ul>';
3064
+	} else {
3065
+		?>
3066 3066
         <?php
3067
-        /**
3068
-         * Filter signup form action link.
3069
-         *
3070
-         * @since 1.0.0
3071
-         */
3072
-        ?>
3067
+		/**
3068
+		 * Filter signup form action link.
3069
+		 *
3070
+		 * @since 1.0.0
3071
+		 */
3072
+		?>
3073 3073
         <form name="loginform" class="loginform1"
3074 3074
               action="<?php echo geodir_login_url(); ?>"
3075 3075
               method="post">
@@ -3089,28 +3089,28 @@  discard block
 block discarded – undo
3089 3089
 
3090 3090
                 <p class="geodir-new-forgot-link">
3091 3091
                     <?php
3092
-                    /**
3093
-                     * Filter signup page register form link.
3094
-                     *
3095
-                     * @since 1.0.0
3096
-                     */
3097
-                    ?>
3092
+					/**
3093
+					 * Filter signup page register form link.
3094
+					 *
3095
+					 * @since 1.0.0
3096
+					 */
3097
+					?>
3098 3098
                     <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
3099 3099
                        class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
3100 3100
 
3101 3101
                     <?php
3102
-                    /**
3103
-                     * Filter signup page forgot password form link.
3104
-                     *
3105
-                     * @since 1.0.0
3106
-                     */
3107
-                    ?>
3102
+					/**
3103
+					 * Filter signup page forgot password form link.
3104
+					 *
3105
+					 * @since 1.0.0
3106
+					 */
3107
+					?>
3108 3108
                     <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
3109 3109
                        class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
3110 3110
         </form>
3111 3111
     <?php }
3112 3112
 
3113
-    echo $after_widget;
3113
+	echo $after_widget;
3114 3114
 }
3115 3115
 
3116 3116
 
@@ -3129,284 +3129,284 @@  discard block
 block discarded – undo
3129 3129
  * @param array|string $instance The settings for the particular instance of the widget.
3130 3130
  */
3131 3131
 function geodir_popular_postview_output($args = '', $instance = '') {
3132
-    global $gd_session;
3132
+	global $gd_session;
3133 3133
 	
3134
-    // prints the widget
3135
-    extract($args, EXTR_SKIP);
3136
-
3137
-    echo $before_widget;
3138
-
3139
-    /** This filter is documented in geodirectory_widgets.php */
3140
-    $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3141
-    /**
3142
-     * Filter the widget post type.
3143
-     *
3144
-     * @since 1.0.0
3145
-     * @param string $instance['post_type'] Post type of listing.
3146
-     */
3147
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3148
-    /**
3149
-     * Filter the widget's term.
3150
-     *
3151
-     * @since 1.0.0
3152
-     * @param string $instance['category'] Filter by term. Can be any valid term.
3153
-     */
3154
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3155
-    /**
3156
-     * Filter the widget listings limit.
3157
-     *
3158
-     * @since 1.0.0
3159
-     * @param string $instance['post_number'] Number of listings to display.
3160
-     */
3161
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3162
-    /**
3163
-     * Filter widget's "layout" type.
3164
-     *
3165
-     * @since 1.0.0
3166
-     * @param string $instance['layout'] Widget layout type.
3167
-     */
3168
-    $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3169
-    /**
3170
-     * Filter widget's "add_location_filter" value.
3171
-     *
3172
-     * @since 1.0.0
3173
-     * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3174
-     */
3175
-    $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3176
-    /**
3177
-     * Filter widget's listing width.
3178
-     *
3179
-     * @since 1.0.0
3180
-     * @param string $instance['listing_width'] Listing width.
3181
-     */
3182
-    $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3183
-    /**
3184
-     * Filter widget's "list_sort" type.
3185
-     *
3186
-     * @since 1.0.0
3187
-     * @param string $instance['list_sort'] Listing sort by type.
3188
-     */
3189
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3190
-    $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3191
-
3192
-    // set post type to current viewing post type
3193
-    if ($use_viewing_post_type) {
3194
-        $current_post_type = geodir_get_current_posttype();
3195
-        if ($current_post_type != '' && $current_post_type != $post_type) {
3196
-            $post_type = $current_post_type;
3197
-            $category = array(); // old post type category will not work for current changed post type
3198
-        }
3199
-    }
3200
-    // replace widget title dynamically
3201
-    $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3202
-    $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3203
-
3204
-    $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3205
-    $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3206
-
3207
-    if (isset($instance['character_count'])) {
3208
-        /**
3209
-         * Filter the widget's excerpt character count.
3210
-         *
3211
-         * @since 1.0.0
3212
-         * @param int $instance['character_count'] Excerpt character count.
3213
-         */
3214
-        $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3215
-    } else {
3216
-        $character_count = '';
3217
-    }
3218
-
3219
-    if (empty($title) || $title == 'All') {
3220
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3221
-    }
3222
-
3223
-    $location_url = array();
3224
-    $city = get_query_var('gd_city');
3225
-    if (!empty($city)) {
3226
-        $country = get_query_var('gd_country');
3227
-        $region = get_query_var('gd_region');
3228
-
3229
-        $geodir_show_location_url = get_option('geodir_show_location_url');
3230
-
3231
-        if ($geodir_show_location_url == 'all') {
3232
-            if ($country != '') {
3233
-                $location_url[] = $country;
3234
-            }
3235
-
3236
-            if ($region != '') {
3237
-                $location_url[] = $region;
3238
-            }
3239
-        } else if ($geodir_show_location_url == 'country_city') {
3240
-            if ($country != '') {
3241
-                $location_url[] = $country;
3242
-            }
3243
-        } else if ($geodir_show_location_url == 'region_city') {
3244
-            if ($region != '') {
3245
-                $location_url[] = $region;
3246
-            }
3247
-        }
3248
-
3249
-        $location_url[] = $city;
3250
-    }
3251
-
3252
-    $location_url = implode('/', $location_url);
3253
-    $skip_location = false;
3254
-    if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3255
-        $skip_location = true;
3256
-        $gd_session->un_set('gd_multi_location');
3257
-    }
3258
-
3259
-    if (get_option('permalink_structure')) {
3260
-        $viewall_url = get_post_type_archive_link($post_type);
3261
-    } else {
3262
-        $viewall_url = get_post_type_archive_link($post_type);
3263
-    }
3264
-
3265
-    if (!empty($category) && $category[0] != '0') {
3266
-        global $geodir_add_location_url;
3267
-
3268
-        $geodir_add_location_url = '0';
3269
-
3270
-        if ($add_location_filter != '0') {
3271
-            $geodir_add_location_url = '1';
3272
-        }
3273
-
3274
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3275
-
3276
-        $geodir_add_location_url = NULL;
3277
-    }
3278
-    if ($skip_location) {
3279
-        $gd_session->set('gd_multi_location', 1);
3280
-    }
3281
-
3282
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3283
-
3284
-    $query_args = array(
3285
-        'posts_per_page' => $post_number,
3286
-        'is_geodir_loop' => true,
3287
-        'gd_location' => $add_location_filter ? true : false,
3288
-        'post_type' => $post_type,
3289
-        'order_by' => $list_sort
3290
-    );
3291
-
3292
-    if ($character_count) {
3293
-        $query_args['excerpt_length'] = $character_count;
3294
-    }
3295
-
3296
-    if (!empty($instance['show_featured_only'])) {
3297
-        $query_args['show_featured_only'] = 1;
3298
-    }
3299
-
3300
-    if (!empty($instance['show_special_only'])) {
3301
-        $query_args['show_special_only'] = 1;
3302
-    }
3303
-
3304
-    if (!empty($instance['with_pics_only'])) {
3305
-        $query_args['with_pics_only'] = 0;
3306
-        $query_args['featured_image_only'] = 1;
3307
-    }
3308
-
3309
-    if (!empty($instance['with_videos_only'])) {
3310
-        $query_args['with_videos_only'] = 1;
3311
-    }
3312
-    $with_no_results = !empty($instance['without_no_results']) ? false : true;
3313
-
3314
-    if (!empty($category) && $category[0] != '0') {
3315
-        $category_taxonomy = geodir_get_taxonomies($post_type);
3316
-
3317
-        ######### WPML #########
3318
-        if (function_exists('icl_object_id')) {
3319
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
3320
-        }
3321
-        ######### WPML #########
3322
-
3323
-        $tax_query = array(
3324
-            'taxonomy' => $category_taxonomy[0],
3325
-            'field' => 'id',
3326
-            'terms' => $category
3327
-        );
3328
-
3329
-        $query_args['tax_query'] = array($tax_query);
3330
-    }
3331
-
3332
-    global $gridview_columns_widget, $geodir_is_widget_listing;
3333
-
3334
-    $widget_listings = geodir_get_widget_listings($query_args);
3335
-
3336
-    if (!empty($widget_listings) || $with_no_results) {
3337
-        ?>
3134
+	// prints the widget
3135
+	extract($args, EXTR_SKIP);
3136
+
3137
+	echo $before_widget;
3138
+
3139
+	/** This filter is documented in geodirectory_widgets.php */
3140
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3141
+	/**
3142
+	 * Filter the widget post type.
3143
+	 *
3144
+	 * @since 1.0.0
3145
+	 * @param string $instance['post_type'] Post type of listing.
3146
+	 */
3147
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3148
+	/**
3149
+	 * Filter the widget's term.
3150
+	 *
3151
+	 * @since 1.0.0
3152
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
3153
+	 */
3154
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3155
+	/**
3156
+	 * Filter the widget listings limit.
3157
+	 *
3158
+	 * @since 1.0.0
3159
+	 * @param string $instance['post_number'] Number of listings to display.
3160
+	 */
3161
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3162
+	/**
3163
+	 * Filter widget's "layout" type.
3164
+	 *
3165
+	 * @since 1.0.0
3166
+	 * @param string $instance['layout'] Widget layout type.
3167
+	 */
3168
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3169
+	/**
3170
+	 * Filter widget's "add_location_filter" value.
3171
+	 *
3172
+	 * @since 1.0.0
3173
+	 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3174
+	 */
3175
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3176
+	/**
3177
+	 * Filter widget's listing width.
3178
+	 *
3179
+	 * @since 1.0.0
3180
+	 * @param string $instance['listing_width'] Listing width.
3181
+	 */
3182
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3183
+	/**
3184
+	 * Filter widget's "list_sort" type.
3185
+	 *
3186
+	 * @since 1.0.0
3187
+	 * @param string $instance['list_sort'] Listing sort by type.
3188
+	 */
3189
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3190
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3191
+
3192
+	// set post type to current viewing post type
3193
+	if ($use_viewing_post_type) {
3194
+		$current_post_type = geodir_get_current_posttype();
3195
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3196
+			$post_type = $current_post_type;
3197
+			$category = array(); // old post type category will not work for current changed post type
3198
+		}
3199
+	}
3200
+	// replace widget title dynamically
3201
+	$posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3202
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3203
+
3204
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3205
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3206
+
3207
+	if (isset($instance['character_count'])) {
3208
+		/**
3209
+		 * Filter the widget's excerpt character count.
3210
+		 *
3211
+		 * @since 1.0.0
3212
+		 * @param int $instance['character_count'] Excerpt character count.
3213
+		 */
3214
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3215
+	} else {
3216
+		$character_count = '';
3217
+	}
3218
+
3219
+	if (empty($title) || $title == 'All') {
3220
+		$title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3221
+	}
3222
+
3223
+	$location_url = array();
3224
+	$city = get_query_var('gd_city');
3225
+	if (!empty($city)) {
3226
+		$country = get_query_var('gd_country');
3227
+		$region = get_query_var('gd_region');
3228
+
3229
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3230
+
3231
+		if ($geodir_show_location_url == 'all') {
3232
+			if ($country != '') {
3233
+				$location_url[] = $country;
3234
+			}
3235
+
3236
+			if ($region != '') {
3237
+				$location_url[] = $region;
3238
+			}
3239
+		} else if ($geodir_show_location_url == 'country_city') {
3240
+			if ($country != '') {
3241
+				$location_url[] = $country;
3242
+			}
3243
+		} else if ($geodir_show_location_url == 'region_city') {
3244
+			if ($region != '') {
3245
+				$location_url[] = $region;
3246
+			}
3247
+		}
3248
+
3249
+		$location_url[] = $city;
3250
+	}
3251
+
3252
+	$location_url = implode('/', $location_url);
3253
+	$skip_location = false;
3254
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3255
+		$skip_location = true;
3256
+		$gd_session->un_set('gd_multi_location');
3257
+	}
3258
+
3259
+	if (get_option('permalink_structure')) {
3260
+		$viewall_url = get_post_type_archive_link($post_type);
3261
+	} else {
3262
+		$viewall_url = get_post_type_archive_link($post_type);
3263
+	}
3264
+
3265
+	if (!empty($category) && $category[0] != '0') {
3266
+		global $geodir_add_location_url;
3267
+
3268
+		$geodir_add_location_url = '0';
3269
+
3270
+		if ($add_location_filter != '0') {
3271
+			$geodir_add_location_url = '1';
3272
+		}
3273
+
3274
+		$viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3275
+
3276
+		$geodir_add_location_url = NULL;
3277
+	}
3278
+	if ($skip_location) {
3279
+		$gd_session->set('gd_multi_location', 1);
3280
+	}
3281
+
3282
+	if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3283
+
3284
+	$query_args = array(
3285
+		'posts_per_page' => $post_number,
3286
+		'is_geodir_loop' => true,
3287
+		'gd_location' => $add_location_filter ? true : false,
3288
+		'post_type' => $post_type,
3289
+		'order_by' => $list_sort
3290
+	);
3291
+
3292
+	if ($character_count) {
3293
+		$query_args['excerpt_length'] = $character_count;
3294
+	}
3295
+
3296
+	if (!empty($instance['show_featured_only'])) {
3297
+		$query_args['show_featured_only'] = 1;
3298
+	}
3299
+
3300
+	if (!empty($instance['show_special_only'])) {
3301
+		$query_args['show_special_only'] = 1;
3302
+	}
3303
+
3304
+	if (!empty($instance['with_pics_only'])) {
3305
+		$query_args['with_pics_only'] = 0;
3306
+		$query_args['featured_image_only'] = 1;
3307
+	}
3308
+
3309
+	if (!empty($instance['with_videos_only'])) {
3310
+		$query_args['with_videos_only'] = 1;
3311
+	}
3312
+	$with_no_results = !empty($instance['without_no_results']) ? false : true;
3313
+
3314
+	if (!empty($category) && $category[0] != '0') {
3315
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3316
+
3317
+		######### WPML #########
3318
+		if (function_exists('icl_object_id')) {
3319
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3320
+		}
3321
+		######### WPML #########
3322
+
3323
+		$tax_query = array(
3324
+			'taxonomy' => $category_taxonomy[0],
3325
+			'field' => 'id',
3326
+			'terms' => $category
3327
+		);
3328
+
3329
+		$query_args['tax_query'] = array($tax_query);
3330
+	}
3331
+
3332
+	global $gridview_columns_widget, $geodir_is_widget_listing;
3333
+
3334
+	$widget_listings = geodir_get_widget_listings($query_args);
3335
+
3336
+	if (!empty($widget_listings) || $with_no_results) {
3337
+		?>
3338 3338
         <div class="geodir_locations geodir_location_listing">
3339 3339
 
3340 3340
             <?php
3341
-            /**
3342
-             * Called before the div containing the title and view all link in popular post view widget.
3343
-             *
3344
-             * @since 1.0.0
3345
-             */
3346
-            do_action('geodir_before_view_all_link_in_widget'); ?>
3341
+			/**
3342
+			 * Called before the div containing the title and view all link in popular post view widget.
3343
+			 *
3344
+			 * @since 1.0.0
3345
+			 */
3346
+			do_action('geodir_before_view_all_link_in_widget'); ?>
3347 3347
             <div class="geodir_list_heading clearfix">
3348 3348
                 <?php echo $before_title . $title . $after_title; ?>
3349 3349
                 <a href="<?php echo $viewall_url; ?>"
3350 3350
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3351 3351
             </div>
3352 3352
             <?php
3353
-            /**
3354
-             * Called after the div containing the title and view all link in popular post view widget.
3355
-             *
3356
-             * @since 1.0.0
3357
-             */
3358
-            do_action('geodir_after_view_all_link_in_widget'); ?>
3353
+			/**
3354
+			 * Called after the div containing the title and view all link in popular post view widget.
3355
+			 *
3356
+			 * @since 1.0.0
3357
+			 */
3358
+			do_action('geodir_after_view_all_link_in_widget'); ?>
3359 3359
             <?php
3360
-            if (strstr($layout, 'gridview')) {
3361
-                $listing_view_exp = explode('_', $layout);
3362
-                $gridview_columns_widget = $layout;
3363
-                $layout = $listing_view_exp[0];
3364
-            } else {
3365
-                $gridview_columns_widget = '';
3366
-            }
3367
-
3368
-            /**
3369
-             * Filter the widget listing listview template path.
3370
-             *
3371
-             * @since 1.0.0
3372
-             */
3373
-            $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3374
-            if (!isset($character_count)) {
3375
-                /**
3376
-                 * Filter the widget's excerpt character count.
3377
-                 *
3378
-                 * @since 1.0.0
3379
-                 * @param int $instance['character_count'] Excerpt character count.
3380
-                 */
3381
-                $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3382
-            }
3383
-
3384
-            global $post, $map_jason, $map_canvas_arr;
3385
-
3386
-            $current_post = $post;
3387
-            $current_map_jason = $map_jason;
3388
-            $current_map_canvas_arr = $map_canvas_arr;
3389
-            $geodir_is_widget_listing = true;
3390
-
3391
-            /**
3392
-             * Includes related listing listview template.
3393
-             *
3394
-             * @since 1.0.0
3395
-             */
3396
-            include($template);
3397
-
3398
-            $geodir_is_widget_listing = false;
3399
-
3400
-            $GLOBALS['post'] = $current_post;
3401
-            if (!empty($current_post))
3402
-                setup_postdata($current_post);
3403
-            $map_jason = $current_map_jason;
3404
-            $map_canvas_arr = $current_map_canvas_arr;
3405
-            ?>
3360
+			if (strstr($layout, 'gridview')) {
3361
+				$listing_view_exp = explode('_', $layout);
3362
+				$gridview_columns_widget = $layout;
3363
+				$layout = $listing_view_exp[0];
3364
+			} else {
3365
+				$gridview_columns_widget = '';
3366
+			}
3367
+
3368
+			/**
3369
+			 * Filter the widget listing listview template path.
3370
+			 *
3371
+			 * @since 1.0.0
3372
+			 */
3373
+			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3374
+			if (!isset($character_count)) {
3375
+				/**
3376
+				 * Filter the widget's excerpt character count.
3377
+				 *
3378
+				 * @since 1.0.0
3379
+				 * @param int $instance['character_count'] Excerpt character count.
3380
+				 */
3381
+				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3382
+			}
3383
+
3384
+			global $post, $map_jason, $map_canvas_arr;
3385
+
3386
+			$current_post = $post;
3387
+			$current_map_jason = $map_jason;
3388
+			$current_map_canvas_arr = $map_canvas_arr;
3389
+			$geodir_is_widget_listing = true;
3390
+
3391
+			/**
3392
+			 * Includes related listing listview template.
3393
+			 *
3394
+			 * @since 1.0.0
3395
+			 */
3396
+			include($template);
3397
+
3398
+			$geodir_is_widget_listing = false;
3399
+
3400
+			$GLOBALS['post'] = $current_post;
3401
+			if (!empty($current_post))
3402
+				setup_postdata($current_post);
3403
+			$map_jason = $current_map_jason;
3404
+			$map_canvas_arr = $current_map_canvas_arr;
3405
+			?>
3406 3406
         </div>
3407 3407
     <?php
3408
-    }
3409
-    echo $after_widget;
3408
+	}
3409
+	echo $after_widget;
3410 3410
 
3411 3411
 }
3412 3412
 
@@ -3429,26 +3429,26 @@  discard block
 block discarded – undo
3429 3429
  */
3430 3430
 function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type)
3431 3431
 {
3432
-    global $wpdb, $plugin_prefix;
3432
+	global $wpdb, $plugin_prefix;
3433 3433
 
3434
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3434
+	$detail_table = $plugin_prefix . $post_type . '_detail';
3435 3435
 
3436
-    $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 . ")";
3436
+	$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 . ")";
3437 3437
 
3438
-    /**
3439
-     * Filter count review sql query.
3440
-     *
3441
-     * @since 1.5.1
3442
-     * @param string $sql Database sql query..
3443
-     * @param int $term_id The term ID.
3444
-     * @param int $taxonomy The taxonomy Id.
3445
-     * @param string $post_type The post type.
3446
-     */
3447
-    $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3438
+	/**
3439
+	 * Filter count review sql query.
3440
+	 *
3441
+	 * @since 1.5.1
3442
+	 * @param string $sql Database sql query..
3443
+	 * @param int $term_id The term ID.
3444
+	 * @param int $taxonomy The taxonomy Id.
3445
+	 * @param string $post_type The post type.
3446
+	 */
3447
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3448 3448
 
3449
-    $count = $wpdb->get_var($sql);
3449
+	$count = $wpdb->get_var($sql);
3450 3450
 
3451
-    return $count;
3451
+	return $count;
3452 3452
 }
3453 3453
 
3454 3454
 /**
@@ -3464,90 +3464,90 @@  discard block
 block discarded – undo
3464 3464
  * @return array Term array data.
3465 3465
  */
3466 3466
 function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
3467
-    /**
3468
-     * Filter review count option data.
3469
-     *
3470
-     * @since 1.0.0
3471
-     * @since 1.6.1 Added $post_ID param.
3472
-     * @param bool $force_update Force update option value?. Default.false.
3473
-     * @param int $post_ID The post id to update if any.
3474
-     */
3475
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3476
-    if (!empty($option_data)) {
3477
-        return $option_data;
3478
-    }
3479
-
3480
-    $option_data = get_option('geodir_global_review_count');
3481
-
3482
-    if (!$option_data || $force_update) {
3483
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3484
-            global $gd_session;
3485
-            $term_array = (array)$option_data;
3486
-            $post_type = get_post_type($post_ID);
3487
-            $taxonomy = $post_type . 'category';
3488
-            $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3489
-
3490
-            if (!empty($terms) && !is_wp_error($terms)) {
3491
-                foreach ($terms as $term_id) {
3492
-                    $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3493
-                    $children = get_term_children($term_id, $taxonomy);
3494
-                    $term_array[$term_id] = $count;
3495
-                }
3496
-            }
3467
+	/**
3468
+	 * Filter review count option data.
3469
+	 *
3470
+	 * @since 1.0.0
3471
+	 * @since 1.6.1 Added $post_ID param.
3472
+	 * @param bool $force_update Force update option value?. Default.false.
3473
+	 * @param int $post_ID The post id to update if any.
3474
+	 */
3475
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3476
+	if (!empty($option_data)) {
3477
+		return $option_data;
3478
+	}
3479
+
3480
+	$option_data = get_option('geodir_global_review_count');
3481
+
3482
+	if (!$option_data || $force_update) {
3483
+		if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3484
+			global $gd_session;
3485
+			$term_array = (array)$option_data;
3486
+			$post_type = get_post_type($post_ID);
3487
+			$taxonomy = $post_type . 'category';
3488
+			$terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3489
+
3490
+			if (!empty($terms) && !is_wp_error($terms)) {
3491
+				foreach ($terms as $term_id) {
3492
+					$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3493
+					$children = get_term_children($term_id, $taxonomy);
3494
+					$term_array[$term_id] = $count;
3495
+				}
3496
+			}
3497 3497
             
3498
-            $session_listing = $gd_session->get('listing');
3498
+			$session_listing = $gd_session->get('listing');
3499 3499
             
3500
-            $terms = array();
3501
-            if (isset($_POST['post_category'][$taxonomy])) {
3502
-                $terms = (array)$_POST['post_category'][$taxonomy];
3503
-            } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3504
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3505
-            }
3500
+			$terms = array();
3501
+			if (isset($_POST['post_category'][$taxonomy])) {
3502
+				$terms = (array)$_POST['post_category'][$taxonomy];
3503
+			} else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3504
+				$terms = (array)$session_listing['post_category'][$taxonomy];
3505
+			}
3506 3506
             
3507
-            if (!empty($terms)) {
3508
-                foreach ($terms as $term_id) {
3509
-                    if ($term_id > 0) {
3510
-                        $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3511
-                        $children = get_term_children($term_id, $taxonomy);
3512
-                        $term_array[$term_id] = $count;
3513
-                    }
3514
-                }
3515
-            }
3516
-        } else { // Update reviews count for all post categories.
3517
-            $term_array = array();
3518
-            $post_types = geodir_get_posttypes();
3519
-            foreach ($post_types as $post_type) {
3520
-
3521
-                $taxonomy = geodir_get_taxonomies($post_type);
3522
-                $taxonomy = $taxonomy[0];
3523
-
3524
-                $args = array(
3525
-                    'hide_empty' => false
3526
-                );
3527
-
3528
-                $terms = get_terms($taxonomy, $args);
3529
-
3530
-                foreach ($terms as $term) {
3531
-                    $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3532
-                    $children = get_term_children($term->term_id, $taxonomy);
3533
-                    /*if ( is_array( $children ) ) {
3507
+			if (!empty($terms)) {
3508
+				foreach ($terms as $term_id) {
3509
+					if ($term_id > 0) {
3510
+						$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3511
+						$children = get_term_children($term_id, $taxonomy);
3512
+						$term_array[$term_id] = $count;
3513
+					}
3514
+				}
3515
+			}
3516
+		} else { // Update reviews count for all post categories.
3517
+			$term_array = array();
3518
+			$post_types = geodir_get_posttypes();
3519
+			foreach ($post_types as $post_type) {
3520
+
3521
+				$taxonomy = geodir_get_taxonomies($post_type);
3522
+				$taxonomy = $taxonomy[0];
3523
+
3524
+				$args = array(
3525
+					'hide_empty' => false
3526
+				);
3527
+
3528
+				$terms = get_terms($taxonomy, $args);
3529
+
3530
+				foreach ($terms as $term) {
3531
+					$count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3532
+					$children = get_term_children($term->term_id, $taxonomy);
3533
+					/*if ( is_array( $children ) ) {
3534 3534
                         foreach ( $children as $child_id ) {
3535 3535
                             $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
3536 3536
                             $count = $count + $child_count;
3537 3537
                         }
3538 3538
                     }*/
3539
-                    $term_array[$term->term_id] = $count;
3540
-                }
3541
-            }
3542
-        }
3543
-
3544
-        update_option('geodir_global_review_count', $term_array);
3545
-        //clear cache
3546
-        wp_cache_delete('geodir_global_review_count');
3547
-        return $term_array;
3548
-    } else {
3549
-        return $option_data;
3550
-    }
3539
+					$term_array[$term->term_id] = $count;
3540
+				}
3541
+			}
3542
+		}
3543
+
3544
+		update_option('geodir_global_review_count', $term_array);
3545
+		//clear cache
3546
+		wp_cache_delete('geodir_global_review_count');
3547
+		return $term_array;
3548
+	} else {
3549
+		return $option_data;
3550
+	}
3551 3551
 }
3552 3552
 
3553 3553
 /**
@@ -3559,38 +3559,38 @@  discard block
 block discarded – undo
3559 3559
  * @return bool
3560 3560
  */
3561 3561
 function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
3562
-    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3563
-        return; // do not run if importing listings
3564
-    }
3562
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3563
+		return; // do not run if importing listings
3564
+	}
3565 3565
     
3566
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3567
-        return;
3568
-    }
3569
-
3570
-    $post_ID = 0;
3571
-    if (!empty($post)) {
3572
-        if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3573
-            return;
3574
-        }
3566
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3567
+		return;
3568
+	}
3569
+
3570
+	$post_ID = 0;
3571
+	if (!empty($post)) {
3572
+		if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3573
+			return;
3574
+		}
3575 3575
         
3576
-        if ($new_status == 'auto-draft' && $old_status == 'new') {
3577
-            return;
3578
-        }
3576
+		if ($new_status == 'auto-draft' && $old_status == 'new') {
3577
+			return;
3578
+		}
3579 3579
         
3580
-        if (!empty($post->ID)) {
3581
-            $post_ID = $post->ID;
3582
-        }
3583
-    }
3580
+		if (!empty($post->ID)) {
3581
+			$post_ID = $post->ID;
3582
+		}
3583
+	}
3584 3584
 
3585
-    if ($new_status != $old_status) {
3586
-        geodir_count_reviews_by_terms(true, $post_ID);
3587
-    }
3585
+	if ($new_status != $old_status) {
3586
+		geodir_count_reviews_by_terms(true, $post_ID);
3587
+	}
3588 3588
 
3589
-    return true;
3589
+	return true;
3590 3590
 }
3591 3591
 
3592 3592
 function geodir_term_review_count_force_update_single_post($post_id){
3593
-    geodir_count_reviews_by_terms(true, $post_id); 
3593
+	geodir_count_reviews_by_terms(true, $post_id); 
3594 3594
 }
3595 3595
 
3596 3596
 /*-----------------------------------------------------------------------------------*/
@@ -3608,15 +3608,15 @@  discard block
 block discarded – undo
3608 3608
 function geodir_count_posts_by_term($data, $term)
3609 3609
 {
3610 3610
 
3611
-    if ($data) {
3612
-        if (isset($data[$term->term_id])) {
3613
-            return $data[$term->term_id];
3614
-        } else {
3615
-            return 0;
3616
-        }
3617
-    } else {
3618
-        return $term->count;
3619
-    }
3611
+	if ($data) {
3612
+		if (isset($data[$term->term_id])) {
3613
+			return $data[$term->term_id];
3614
+		} else {
3615
+			return 0;
3616
+		}
3617
+	} else {
3618
+		return $term->count;
3619
+	}
3620 3620
 }
3621 3621
 
3622 3622
 /**
@@ -3629,8 +3629,8 @@  discard block
 block discarded – undo
3629 3629
  */
3630 3630
 function geodir_sort_terms_by_count($terms)
3631 3631
 {
3632
-    usort($terms, "geodir_sort_by_count_obj");
3633
-    return $terms;
3632
+	usort($terms, "geodir_sort_by_count_obj");
3633
+	return $terms;
3634 3634
 }
3635 3635
 
3636 3636
 /**
@@ -3643,8 +3643,8 @@  discard block
 block discarded – undo
3643 3643
  */
3644 3644
 function geodir_sort_terms_by_review_count($terms)
3645 3645
 {
3646
-    usort($terms, "geodir_sort_by_review_count_obj");
3647
-    return $terms;
3646
+	usort($terms, "geodir_sort_by_review_count_obj");
3647
+	return $terms;
3648 3648
 }
3649 3649
 
3650 3650
 /**
@@ -3658,12 +3658,12 @@  discard block
 block discarded – undo
3658 3658
  */
3659 3659
 function geodir_sort_terms($terms, $sort = 'count')
3660 3660
 {
3661
-    if ($sort == 'count') {
3662
-        return geodir_sort_terms_by_count($terms);
3663
-    }
3664
-    if ($sort == 'review_count') {
3665
-        return geodir_sort_terms_by_review_count($terms);
3666
-    }
3661
+	if ($sort == 'count') {
3662
+		return geodir_sort_terms_by_count($terms);
3663
+	}
3664
+	if ($sort == 'review_count') {
3665
+		return geodir_sort_terms_by_review_count($terms);
3666
+	}
3667 3667
 }
3668 3668
 
3669 3669
 /*-----------------------------------------------------------------------------------*/
@@ -3680,7 +3680,7 @@  discard block
 block discarded – undo
3680 3680
  */
3681 3681
 function geodir_sort_by_count($a, $b)
3682 3682
 {
3683
-    return $a['count'] < $b['count'];
3683
+	return $a['count'] < $b['count'];
3684 3684
 }
3685 3685
 
3686 3686
 /**
@@ -3694,7 +3694,7 @@  discard block
 block discarded – undo
3694 3694
  */
3695 3695
 function geodir_sort_by_count_obj($a, $b)
3696 3696
 {
3697
-    return $a->count < $b->count;
3697
+	return $a->count < $b->count;
3698 3698
 }
3699 3699
 
3700 3700
 /**
@@ -3708,7 +3708,7 @@  discard block
 block discarded – undo
3708 3708
  */
3709 3709
 function geodir_sort_by_review_count_obj($a, $b)
3710 3710
 {
3711
-    return $a->review_count < $b->review_count;
3711
+	return $a->review_count < $b->review_count;
3712 3712
 }
3713 3713
 
3714 3714
 /**
@@ -3718,43 +3718,43 @@  discard block
 block discarded – undo
3718 3718
  * @package GeoDirectory
3719 3719
  */
3720 3720
 function geodir_load_textdomain() {
3721
-    /**
3722
-     * Filter the plugin locale.
3723
-     *
3724
-     * @since 1.4.2
3725
-     * @package GeoDirectory
3726
-     */
3727
-    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3728
-
3729
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3730
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3731
-
3732
-    /**
3733
-     * Define language constants.
3734
-     *
3735
-     * @since 1.0.0
3736
-     */
3737
-    require_once(geodir_plugin_path() . '/language.php');
3738
-
3739
-    $language_file = geodir_plugin_path() . '/db-language.php';
3740
-
3741
-    // Load language string file if not created yet
3742
-    if (!file_exists($language_file)) {
3743
-        geodirectory_load_db_language();
3744
-    }
3745
-
3746
-    if (file_exists($language_file)) {
3747
-        /**
3748
-         * Language strings from database.
3749
-         *
3750
-         * @since 1.4.2
3751
-         */
3752
-        try {
3753
-            require_once($language_file);
3754
-        } catch(Exception $e) {
3755
-            error_log('Language Error: ' . $e->getMessage());
3756
-        }
3757
-    }
3721
+	/**
3722
+	 * Filter the plugin locale.
3723
+	 *
3724
+	 * @since 1.4.2
3725
+	 * @package GeoDirectory
3726
+	 */
3727
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3728
+
3729
+	load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3730
+	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3731
+
3732
+	/**
3733
+	 * Define language constants.
3734
+	 *
3735
+	 * @since 1.0.0
3736
+	 */
3737
+	require_once(geodir_plugin_path() . '/language.php');
3738
+
3739
+	$language_file = geodir_plugin_path() . '/db-language.php';
3740
+
3741
+	// Load language string file if not created yet
3742
+	if (!file_exists($language_file)) {
3743
+		geodirectory_load_db_language();
3744
+	}
3745
+
3746
+	if (file_exists($language_file)) {
3747
+		/**
3748
+		 * Language strings from database.
3749
+		 *
3750
+		 * @since 1.4.2
3751
+		 */
3752
+		try {
3753
+			require_once($language_file);
3754
+		} catch(Exception $e) {
3755
+			error_log('Language Error: ' . $e->getMessage());
3756
+		}
3757
+	}
3758 3758
 }
3759 3759
 
3760 3760
 /**
@@ -3768,66 +3768,66 @@  discard block
 block discarded – undo
3768 3768
  * @return bool True if file created otherwise false
3769 3769
  */
3770 3770
 function geodirectory_load_db_language() {
3771
-    global $wp_filesystem;
3772
-    if( empty( $wp_filesystem ) ) {
3773
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3774
-        WP_Filesystem();
3775
-        global $wp_filesystem;
3776
-    }
3777
-
3778
-    $language_file = geodir_plugin_path() . '/db-language.php';
3779
-
3780
-    if(is_file($language_file) && !is_writable($language_file))
3781
-        return false; // Not possible to create.
3782
-
3783
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3784
-        return false; // Not possible to create.
3785
-
3786
-    $contents_strings = array();
3787
-
3788
-    /**
3789
-     * Filter the language string from database to translate via po editor
3790
-     *
3791
-     * @since 1.4.2
3792
-     *
3793
-     * @param array $contents_strings Array of strings.
3794
-     */
3795
-    $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3796
-
3797
-    $contents_strings = array_unique($contents_strings);
3798
-
3799
-    $contents_head = array();
3800
-    $contents_head[] = "<?php";
3801
-    $contents_head[] = "/**";
3802
-    $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3803
-    $contents_head[] = " *";
3804
-    $contents_head[] = " * @package GeoDirectory";
3805
-    $contents_head[] = " * @since 1.4.2";
3806
-    $contents_head[] = " */";
3807
-    $contents_head[] = "";
3808
-    $contents_head[] = "// Language keys";
3809
-
3810
-    $contents_foot = array();
3811
-    $contents_foot[] = "";
3812
-    $contents_foot[] = "";
3813
-
3814
-    $contents = implode(PHP_EOL, $contents_head);
3815
-
3816
-    if (!empty($contents_strings)) {
3817
-        foreach ( $contents_strings as $string ) {
3818
-            if (is_scalar($string) && $string != '') {
3819
-                $string = str_replace("'", "\'", $string);
3820
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3821
-            }
3822
-        }
3823
-    }
3824
-
3825
-    $contents .= implode(PHP_EOL, $contents_foot);
3826
-
3827
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3828
-        return false; // Failure; could not write file.
3829
-
3830
-    return true;
3771
+	global $wp_filesystem;
3772
+	if( empty( $wp_filesystem ) ) {
3773
+		require_once( ABSPATH .'/wp-admin/includes/file.php' );
3774
+		WP_Filesystem();
3775
+		global $wp_filesystem;
3776
+	}
3777
+
3778
+	$language_file = geodir_plugin_path() . '/db-language.php';
3779
+
3780
+	if(is_file($language_file) && !is_writable($language_file))
3781
+		return false; // Not possible to create.
3782
+
3783
+	if(!is_file($language_file) && !is_writable(dirname($language_file)))
3784
+		return false; // Not possible to create.
3785
+
3786
+	$contents_strings = array();
3787
+
3788
+	/**
3789
+	 * Filter the language string from database to translate via po editor
3790
+	 *
3791
+	 * @since 1.4.2
3792
+	 *
3793
+	 * @param array $contents_strings Array of strings.
3794
+	 */
3795
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3796
+
3797
+	$contents_strings = array_unique($contents_strings);
3798
+
3799
+	$contents_head = array();
3800
+	$contents_head[] = "<?php";
3801
+	$contents_head[] = "/**";
3802
+	$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3803
+	$contents_head[] = " *";
3804
+	$contents_head[] = " * @package GeoDirectory";
3805
+	$contents_head[] = " * @since 1.4.2";
3806
+	$contents_head[] = " */";
3807
+	$contents_head[] = "";
3808
+	$contents_head[] = "// Language keys";
3809
+
3810
+	$contents_foot = array();
3811
+	$contents_foot[] = "";
3812
+	$contents_foot[] = "";
3813
+
3814
+	$contents = implode(PHP_EOL, $contents_head);
3815
+
3816
+	if (!empty($contents_strings)) {
3817
+		foreach ( $contents_strings as $string ) {
3818
+			if (is_scalar($string) && $string != '') {
3819
+				$string = str_replace("'", "\'", $string);
3820
+				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3821
+			}
3822
+		}
3823
+	}
3824
+
3825
+	$contents .= implode(PHP_EOL, $contents_foot);
3826
+
3827
+	if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3828
+		return false; // Failure; could not write file.
3829
+
3830
+	return true;
3831 3831
 }
3832 3832
 
3833 3833
 /**
@@ -3843,31 +3843,31 @@  discard block
 block discarded – undo
3843 3843
  * @return array Translation texts.
3844 3844
  */
3845 3845
 function geodir_load_custom_field_translation($translation_texts = array()) {
3846
-    global $wpdb;
3846
+	global $wpdb;
3847 3847
 
3848
-    // Custom fields table
3849
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3850
-    $rows = $wpdb->get_results($sql);
3848
+	// Custom fields table
3849
+	$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3850
+	$rows = $wpdb->get_results($sql);
3851 3851
 
3852
-    if (!empty($rows)) {
3853
-        foreach($rows as $row) {
3854
-            if (!empty($row->admin_title))
3855
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3852
+	if (!empty($rows)) {
3853
+		foreach($rows as $row) {
3854
+			if (!empty($row->admin_title))
3855
+				$translation_texts[] = stripslashes_deep($row->admin_title);
3856 3856
 			
3857
-            if (!empty($row->admin_desc))
3858
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3857
+			if (!empty($row->admin_desc))
3858
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
3859 3859
 
3860
-            if (!empty($row->site_title))
3861
-                $translation_texts[] = stripslashes_deep($row->site_title);
3860
+			if (!empty($row->site_title))
3861
+				$translation_texts[] = stripslashes_deep($row->site_title);
3862 3862
 
3863
-            if (!empty($row->clabels))
3864
-                $translation_texts[] = stripslashes_deep($row->clabels);
3863
+			if (!empty($row->clabels))
3864
+				$translation_texts[] = stripslashes_deep($row->clabels);
3865 3865
 
3866
-            if (!empty($row->required_msg))
3867
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3866
+			if (!empty($row->required_msg))
3867
+				$translation_texts[] = stripslashes_deep($row->required_msg);
3868 3868
 			
3869 3869
 			if (!empty($row->default_value))
3870
-                $translation_texts[] = stripslashes_deep($row->default_value);
3870
+				$translation_texts[] = stripslashes_deep($row->default_value);
3871 3871
 			
3872 3872
 			if (!empty($row->option_values)) {
3873 3873
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3880,25 +3880,25 @@  discard block
 block discarded – undo
3880 3880
 					}
3881 3881
 				}
3882 3882
 			}
3883
-        }
3884
-    }
3883
+		}
3884
+	}
3885 3885
 	
3886
-    // Custom sorting fields table
3887
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3888
-    $rows = $wpdb->get_results($sql);
3889
-
3890
-    if (!empty($rows)) {
3891
-        foreach($rows as $row) {
3892
-            if (!empty($row->site_title))
3893
-                $translation_texts[] = stripslashes_deep($row->site_title);
3894
-
3895
-            if (!empty($row->asc_title))
3896
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3897
-
3898
-            if (!empty($row->desc_title))
3899
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3900
-        }
3901
-    }
3886
+	// Custom sorting fields table
3887
+	$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3888
+	$rows = $wpdb->get_results($sql);
3889
+
3890
+	if (!empty($rows)) {
3891
+		foreach($rows as $row) {
3892
+			if (!empty($row->site_title))
3893
+				$translation_texts[] = stripslashes_deep($row->site_title);
3894
+
3895
+			if (!empty($row->asc_title))
3896
+				$translation_texts[] = stripslashes_deep($row->asc_title);
3897
+
3898
+			if (!empty($row->desc_title))
3899
+				$translation_texts[] = stripslashes_deep($row->desc_title);
3900
+		}
3901
+	}
3902 3902
 	
3903 3903
 	// Advance search filter fields table
3904 3904
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
@@ -3919,9 +3919,9 @@  discard block
 block discarded – undo
3919 3919
 		}
3920 3920
 	}
3921 3921
 
3922
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3922
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3923 3923
 
3924
-    return $translation_texts;
3924
+	return $translation_texts;
3925 3925
 }
3926 3926
 
3927 3927
 /**
@@ -3933,71 +3933,71 @@  discard block
 block discarded – undo
3933 3933
  * @return array Array of mime types.
3934 3934
  */
3935 3935
 function geodir_allowed_mime_types() {
3936
-    /**
3937
-     * Filter the list of mime types and file extensions allowed for file upload.
3938
-     *
3939
-     * @since 1.4.7
3940
-     * @package GeoDirectory
3941
-     *
3942
-     * @param array $geodir_allowed_mime_types and file extensions.
3943
-     */
3944
-    return apply_filters( 'geodir_allowed_mime_types', array(
3945
-            'Image' => array( // Image formats.
3946
-                'jpg' => 'image/jpeg',
3947
-                'jpe' => 'image/jpeg',
3948
-                'jpeg' => 'image/jpeg',
3949
-                'gif' => 'image/gif',
3950
-                'png' => 'image/png',
3951
-                'bmp' => 'image/bmp',
3952
-                'ico' => 'image/x-icon',
3953
-            ),
3954
-            'Video' => array( // Video formats.
3955
-                'asf' => 'video/x-ms-asf',
3956
-                'avi' => 'video/avi',
3957
-                'flv' => 'video/x-flv',
3958
-                'mkv' => 'video/x-matroska',
3959
-                'mp4' => 'video/mp4',
3960
-                'mpeg' => 'video/mpeg',
3961
-                'mpg' => 'video/mpeg',
3962
-                'wmv' => 'video/x-ms-wmv',
3963
-                '3gp' => 'video/3gpp',
3964
-            ),
3965
-            'Audio' => array( // Audio formats.
3966
-                'ogg' => 'audio/ogg',
3967
-                'mp3' => 'audio/mpeg',
3968
-                'wav' => 'audio/wav',
3969
-                'wma' => 'audio/x-ms-wma',
3970
-            ),
3971
-            'Text' => array( // Text formats.
3972
-                'css' => 'text/css',
3973
-                'csv' => 'text/csv',
3974
-                'htm' => 'text/html',
3975
-                'html' => 'text/html',
3976
-                'txt' => 'text/plain',
3977
-                'rtx' => 'text/richtext',
3978
-                'vtt' => 'text/vtt',
3979
-            ),
3980
-            'Application' => array( // Application formats.
3981
-                'doc' => 'application/msword',
3982
-                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3983
-                'exe' => 'application/x-msdownload',
3984
-                'js' => 'application/javascript',
3985
-                'odt' => 'application/vnd.oasis.opendocument.text',
3986
-                'pdf' => 'application/pdf',
3987
-                'pot' => 'application/vnd.ms-powerpoint',
3988
-                'ppt' => 'application/vnd.ms-powerpoint',
3989
-                'pptx' => 'application/vnd.ms-powerpoint',
3990
-                'psd' => 'application/octet-stream',
3991
-                'rar' => 'application/rar',
3992
-                'rtf' => 'application/rtf',
3993
-                'swf' => 'application/x-shockwave-flash',
3994
-                'tar' => 'application/x-tar',
3995
-                'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3996
-                'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3997
-                'zip' => 'application/zip',
3998
-            )
3999
-        )
4000
-    );
3936
+	/**
3937
+	 * Filter the list of mime types and file extensions allowed for file upload.
3938
+	 *
3939
+	 * @since 1.4.7
3940
+	 * @package GeoDirectory
3941
+	 *
3942
+	 * @param array $geodir_allowed_mime_types and file extensions.
3943
+	 */
3944
+	return apply_filters( 'geodir_allowed_mime_types', array(
3945
+			'Image' => array( // Image formats.
3946
+				'jpg' => 'image/jpeg',
3947
+				'jpe' => 'image/jpeg',
3948
+				'jpeg' => 'image/jpeg',
3949
+				'gif' => 'image/gif',
3950
+				'png' => 'image/png',
3951
+				'bmp' => 'image/bmp',
3952
+				'ico' => 'image/x-icon',
3953
+			),
3954
+			'Video' => array( // Video formats.
3955
+				'asf' => 'video/x-ms-asf',
3956
+				'avi' => 'video/avi',
3957
+				'flv' => 'video/x-flv',
3958
+				'mkv' => 'video/x-matroska',
3959
+				'mp4' => 'video/mp4',
3960
+				'mpeg' => 'video/mpeg',
3961
+				'mpg' => 'video/mpeg',
3962
+				'wmv' => 'video/x-ms-wmv',
3963
+				'3gp' => 'video/3gpp',
3964
+			),
3965
+			'Audio' => array( // Audio formats.
3966
+				'ogg' => 'audio/ogg',
3967
+				'mp3' => 'audio/mpeg',
3968
+				'wav' => 'audio/wav',
3969
+				'wma' => 'audio/x-ms-wma',
3970
+			),
3971
+			'Text' => array( // Text formats.
3972
+				'css' => 'text/css',
3973
+				'csv' => 'text/csv',
3974
+				'htm' => 'text/html',
3975
+				'html' => 'text/html',
3976
+				'txt' => 'text/plain',
3977
+				'rtx' => 'text/richtext',
3978
+				'vtt' => 'text/vtt',
3979
+			),
3980
+			'Application' => array( // Application formats.
3981
+				'doc' => 'application/msword',
3982
+				'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3983
+				'exe' => 'application/x-msdownload',
3984
+				'js' => 'application/javascript',
3985
+				'odt' => 'application/vnd.oasis.opendocument.text',
3986
+				'pdf' => 'application/pdf',
3987
+				'pot' => 'application/vnd.ms-powerpoint',
3988
+				'ppt' => 'application/vnd.ms-powerpoint',
3989
+				'pptx' => 'application/vnd.ms-powerpoint',
3990
+				'psd' => 'application/octet-stream',
3991
+				'rar' => 'application/rar',
3992
+				'rtf' => 'application/rtf',
3993
+				'swf' => 'application/x-shockwave-flash',
3994
+				'tar' => 'application/x-tar',
3995
+				'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3996
+				'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3997
+				'zip' => 'application/zip',
3998
+			)
3999
+		)
4000
+	);
4001 4001
 }
4002 4002
 
4003 4003
 /**
@@ -4009,21 +4009,21 @@  discard block
 block discarded – undo
4009 4009
  * @return string User display name.
4010 4010
  */
4011 4011
 function geodir_get_client_name($user_id) {
4012
-    $client_name = '';
4012
+	$client_name = '';
4013 4013
 
4014
-    $user_data = get_userdata($user_id);
4014
+	$user_data = get_userdata($user_id);
4015 4015
 
4016
-    if (!empty($user_data)) {
4017
-        if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
4018
-            $client_name = trim($user_data->display_name);
4019
-        } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
4020
-            $client_name = trim($user_data->user_nicename);
4021
-        } else {
4022
-            $client_name = trim($user_data->user_login);
4023
-        }
4024
-    }
4016
+	if (!empty($user_data)) {
4017
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
4018
+			$client_name = trim($user_data->display_name);
4019
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
4020
+			$client_name = trim($user_data->user_nicename);
4021
+		} else {
4022
+			$client_name = trim($user_data->user_login);
4023
+		}
4024
+	}
4025 4025
 
4026
-    return $client_name;
4026
+	return $client_name;
4027 4027
 }
4028 4028
 
4029 4029
 
@@ -4038,125 +4038,125 @@  discard block
 block discarded – undo
4038 4038
  */
4039 4039
 function geodir_wpseo_replacements($vars){
4040 4040
 
4041
-    global $wp;
4042
-    $title = '';
4043
-    // location variables
4044
-    $gd_post_type = geodir_get_current_posttype();
4045
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4046
-    /**
4047
-     * Filter the title variables location variables array
4048
-     *
4049
-     * @since 1.5.5
4050
-     * @package GeoDirectory
4051
-     * @param array $location_array The array of location variables.
4052
-     * @param array $vars The page title variables.
4053
-     */
4054
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4055
-    $location_titles = array();
4056
-    if(get_query_var( 'gd_country_full' )){
4057
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4058
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4059
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4060
-    }
4061
-    $location_single = '';
4062
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4063
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4064
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4065
-
4066
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4067
-
4068
-    if (function_exists('get_actual_location_name')) {
4069
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4070
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4071
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4072
-    }
4073
-
4074
-    if ($gd_city != '') {
4075
-        if ($gd_city_actual != '') {
4076
-            $gd_city = $gd_city_actual;
4077
-        } else {
4078
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4079
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4080
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4081
-        }
4082
-        $location_single = $gd_city;
4083
-
4084
-    } else if ($gd_region != '') {
4085
-        if ($gd_region_actual != '') {
4086
-            $gd_region = $gd_region_actual;
4087
-        } else {
4088
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4089
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4090
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4091
-        }
4092
-
4093
-        $location_single = $gd_region;
4094
-    } else if ($gd_country != '') {
4095
-        if ($gd_country_actual != '') {
4096
-            $gd_country = $gd_country_actual;
4097
-        } else {
4098
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4099
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4100
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4101
-        }
4102
-
4103
-        $location_single = $gd_country;
4104
-    }
4105
-
4106
-    if (!empty($location_array)) {
4107
-
4108
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4109
-        $location_array = array_reverse($location_array);
4110
-
4111
-        foreach ($location_array as $location_type => $location) {
4112
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4113
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4114
-
4115
-            $location_name = geodir_ucwords($gd_location_link_text);
4116
-            $location_name = __($location_name, 'geodirectory');
4117
-
4118
-            if ($actual_location_name) {
4119
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4120
-                $location_name = get_actual_location_name($location_type, $location, true);
4121
-            }
4122
-
4123
-            $location_titles[] = $location_name;
4124
-        }
4125
-        if (!empty($location_titles)) {
4126
-            $location_titles = array_unique($location_titles);
4127
-        }
4128
-    }
4129
-
4130
-
4131
-    if(!empty($location_titles)) {
4132
-        $vars['%%location%%'] = implode(", ", $location_titles);
4133
-    }
4134
-
4135
-
4136
-    if(!empty($location_titles)) {
4137
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4138
-    }
4139
-
4140
-
4141
-
4142
-    if($location_single) {
4143
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4144
-    }
4145
-
4146
-
4147
-    if($location_single) {
4148
-        $vars['%%location_single%%'] = $location_single;
4149
-    }
4150
-
4151
-    /**
4152
-     * Filter the title variables after standard ones have been filtered for wpseo.
4153
-     *
4154
-     * @since 1.5.7
4155
-     * @package GeoDirectory
4156
-     * @param string $vars The title with variables.
4157
-     * @param array $location_array The array of location variables.
4158
-     */
4159
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4041
+	global $wp;
4042
+	$title = '';
4043
+	// location variables
4044
+	$gd_post_type = geodir_get_current_posttype();
4045
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4046
+	/**
4047
+	 * Filter the title variables location variables array
4048
+	 *
4049
+	 * @since 1.5.5
4050
+	 * @package GeoDirectory
4051
+	 * @param array $location_array The array of location variables.
4052
+	 * @param array $vars The page title variables.
4053
+	 */
4054
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4055
+	$location_titles = array();
4056
+	if(get_query_var( 'gd_country_full' )){
4057
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4058
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4059
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4060
+	}
4061
+	$location_single = '';
4062
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4063
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4064
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4065
+
4066
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4067
+
4068
+	if (function_exists('get_actual_location_name')) {
4069
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4070
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4071
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4072
+	}
4073
+
4074
+	if ($gd_city != '') {
4075
+		if ($gd_city_actual != '') {
4076
+			$gd_city = $gd_city_actual;
4077
+		} else {
4078
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4079
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4080
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4081
+		}
4082
+		$location_single = $gd_city;
4083
+
4084
+	} else if ($gd_region != '') {
4085
+		if ($gd_region_actual != '') {
4086
+			$gd_region = $gd_region_actual;
4087
+		} else {
4088
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4089
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4090
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4091
+		}
4092
+
4093
+		$location_single = $gd_region;
4094
+	} else if ($gd_country != '') {
4095
+		if ($gd_country_actual != '') {
4096
+			$gd_country = $gd_country_actual;
4097
+		} else {
4098
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4099
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4100
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4101
+		}
4102
+
4103
+		$location_single = $gd_country;
4104
+	}
4105
+
4106
+	if (!empty($location_array)) {
4107
+
4108
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4109
+		$location_array = array_reverse($location_array);
4110
+
4111
+		foreach ($location_array as $location_type => $location) {
4112
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4113
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4114
+
4115
+			$location_name = geodir_ucwords($gd_location_link_text);
4116
+			$location_name = __($location_name, 'geodirectory');
4117
+
4118
+			if ($actual_location_name) {
4119
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4120
+				$location_name = get_actual_location_name($location_type, $location, true);
4121
+			}
4122
+
4123
+			$location_titles[] = $location_name;
4124
+		}
4125
+		if (!empty($location_titles)) {
4126
+			$location_titles = array_unique($location_titles);
4127
+		}
4128
+	}
4129
+
4130
+
4131
+	if(!empty($location_titles)) {
4132
+		$vars['%%location%%'] = implode(", ", $location_titles);
4133
+	}
4134
+
4135
+
4136
+	if(!empty($location_titles)) {
4137
+		$vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4138
+	}
4139
+
4140
+
4141
+
4142
+	if($location_single) {
4143
+		$vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4144
+	}
4145
+
4146
+
4147
+	if($location_single) {
4148
+		$vars['%%location_single%%'] = $location_single;
4149
+	}
4150
+
4151
+	/**
4152
+	 * Filter the title variables after standard ones have been filtered for wpseo.
4153
+	 *
4154
+	 * @since 1.5.7
4155
+	 * @package GeoDirectory
4156
+	 * @param string $vars The title with variables.
4157
+	 * @param array $location_array The array of location variables.
4158
+	 */
4159
+	return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4160 4160
 }
4161 4161
 
4162 4162
 
@@ -4204,286 +4204,286 @@  discard block
 block discarded – undo
4204 4204
  * @return string Title after filtered variables.
4205 4205
  */
4206 4206
 function geodir_filter_title_variables($title, $gd_page, $sep = '') {
4207
-    global $wp, $post;
4207
+	global $wp, $post;
4208 4208
 
4209
-    if (!$gd_page || !$title) {
4210
-        return $title; // if no a GD page then bail.
4211
-    }
4209
+	if (!$gd_page || !$title) {
4210
+		return $title; // if no a GD page then bail.
4211
+	}
4212 4212
     
4213
-    if ($sep == '') {
4214
-        /**
4215
-         * Filter the page title separator.
4216
-         *
4217
-         * @since 1.0.0
4218
-         * @package GeoDirectory
4219
-         * @param string $sep The separator, default: `|`.
4220
-         */
4221
-        $sep = apply_filters('geodir_page_title_separator', '|');
4222
-    }
4223
-
4224
-    if (strpos($title,'%%title%%') !== false) {
4225
-        $title = str_replace("%%title%%", $post->post_title, $title);
4226
-    }
4227
-
4228
-    if (strpos($title,'%%sitename%%') !== false) {
4229
-        $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4230
-    }
4231
-
4232
-    if (strpos($title,'%%sitedesc%%') !== false) {
4233
-        $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4234
-    }
4235
-
4236
-    if (strpos($title,'%%excerpt%%') !== false) {
4237
-        $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4238
-    }
4213
+	if ($sep == '') {
4214
+		/**
4215
+		 * Filter the page title separator.
4216
+		 *
4217
+		 * @since 1.0.0
4218
+		 * @package GeoDirectory
4219
+		 * @param string $sep The separator, default: `|`.
4220
+		 */
4221
+		$sep = apply_filters('geodir_page_title_separator', '|');
4222
+	}
4223
+
4224
+	if (strpos($title,'%%title%%') !== false) {
4225
+		$title = str_replace("%%title%%", $post->post_title, $title);
4226
+	}
4227
+
4228
+	if (strpos($title,'%%sitename%%') !== false) {
4229
+		$title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4230
+	}
4231
+
4232
+	if (strpos($title,'%%sitedesc%%') !== false) {
4233
+		$title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4234
+	}
4235
+
4236
+	if (strpos($title,'%%excerpt%%') !== false) {
4237
+		$title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4238
+	}
4239 4239
     
4240
-    if ($gd_page == 'search' || $gd_page == 'author') {
4241
-        $post_type = sanitize_text_field($_REQUEST['stype']);
4242
-    } else if ($gd_page == 'add-listing') {
4243
-        $post_type = sanitize_text_field($_REQUEST['listing_type']);
4244
-        $post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int)$_REQUEST['pid']) : $post_type;
4245
-    } else if (isset($post->post_type) && $post->post_type && in_array($post->post_type , geodir_get_posttypes())) {
4246
-        $post_type = $post->post_type;
4247
-    } else {
4248
-        $post_type = get_query_var('post_type');
4249
-    }
4240
+	if ($gd_page == 'search' || $gd_page == 'author') {
4241
+		$post_type = sanitize_text_field($_REQUEST['stype']);
4242
+	} else if ($gd_page == 'add-listing') {
4243
+		$post_type = sanitize_text_field($_REQUEST['listing_type']);
4244
+		$post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int)$_REQUEST['pid']) : $post_type;
4245
+	} else if (isset($post->post_type) && $post->post_type && in_array($post->post_type , geodir_get_posttypes())) {
4246
+		$post_type = $post->post_type;
4247
+	} else {
4248
+		$post_type = get_query_var('post_type');
4249
+	}
4250 4250
     
4251
-    if (strpos($title, '%%pt_single%%') !== false) {        
4252
-        $singular_name = '';
4253
-        if ($post_type && $singular_name = get_post_type_singular_label($post_type)) {
4254
-            $singular_name = __($singular_name, 'geodirectory');
4255
-        }
4251
+	if (strpos($title, '%%pt_single%%') !== false) {        
4252
+		$singular_name = '';
4253
+		if ($post_type && $singular_name = get_post_type_singular_label($post_type)) {
4254
+			$singular_name = __($singular_name, 'geodirectory');
4255
+		}
4256 4256
         
4257
-        $title = str_replace("%%pt_single%%", $singular_name, $title);
4258
-    }
4259
-
4260
-    if (strpos($title, '%%pt_plural%%') !== false) {        
4261
-        $plural_name = '';
4262
-        if ($post_type && $plural_name = get_post_type_plural_label($post_type)) {
4263
-            $plural_name = __($plural_name, 'geodirectory');
4264
-        }
4257
+		$title = str_replace("%%pt_single%%", $singular_name, $title);
4258
+	}
4259
+
4260
+	if (strpos($title, '%%pt_plural%%') !== false) {        
4261
+		$plural_name = '';
4262
+		if ($post_type && $plural_name = get_post_type_plural_label($post_type)) {
4263
+			$plural_name = __($plural_name, 'geodirectory');
4264
+		}
4265 4265
         
4266
-        $title = str_replace("%%pt_plural%%", $plural_name, $title);
4267
-    }
4268
-
4269
-    if (strpos($title, '%%category%%') !== false) {
4270
-        $cat_name = '';
4271
-
4272
-        if ($gd_page=='detail') {
4273
-            if ($post->default_category) {
4274
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4275
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4276
-            }
4277
-        } else if ($gd_page == 'listing') {
4278
-            $queried_object = get_queried_object();
4279
-            if (isset($queried_object->name)) {
4280
-                $cat_name = $queried_object->name;
4281
-            }
4282
-        }
4283
-        $title = str_replace("%%category%%", $cat_name, $title);
4284
-    }
4285
-
4286
-    if (strpos($title, '%%tag%%') !== false) {
4287
-        $cat_name = '';
4288
-
4289
-        if ($gd_page=='detail') {
4290
-            if ($post->default_category) {
4291
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4292
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4293
-            }
4294
-        } else if($gd_page == 'listing') {
4295
-            $queried_object = get_queried_object();
4296
-            if (isset($queried_object->name)) {
4297
-                $cat_name = $queried_object->name;
4298
-            }
4299
-        }
4300
-        $title = str_replace("%%tag%%", $cat_name, $title);
4301
-    }
4302
-
4303
-    if (strpos($title, '%%id%%') !== false) {
4304
-        $ID = (isset($post->ID)) ? $post->ID : '';
4305
-        $title = str_replace("%%id%%", $ID, $title);
4306
-    }
4307
-
4308
-    if (strpos($title,'%%sep%%') !== false) {
4309
-        $title = str_replace("%%sep%%", $sep, $title);
4310
-    }
4311
-
4312
-    // location variables
4313
-    $gd_post_type = geodir_get_current_posttype();
4314
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4315
-    /**
4316
-     * Filter the title variables location variables array
4317
-     *
4318
-     * @since 1.5.5
4319
-     * @package GeoDirectory
4320
-     * @param array $location_array The array of location variables.
4321
-     * @param string $title The title with variables..
4322
-     * @param string $gd_page The page being filtered.
4323
-     * @param string $sep The separator, default: `|`.
4324
-     */
4325
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4326
-    $location_titles = array();
4327
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4328
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4329
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4330
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4331
-    }
4332
-    $location_single = '';
4333
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4334
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4335
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4336
-
4337
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4338
-
4339
-    if (function_exists('get_actual_location_name')) {
4340
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4341
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4342
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4343
-    }
4344
-
4345
-    if ($gd_city != '') {
4346
-        if ($gd_city_actual != '') {
4347
-            $gd_city = $gd_city_actual;
4348
-        } else {
4349
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4350
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4351
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4352
-        }
4353
-        $location_single = $gd_city;
4354
-
4355
-    } else if ($gd_region != '') {
4356
-        if ($gd_region_actual != '') {
4357
-            $gd_region = $gd_region_actual;
4358
-        } else {
4359
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4360
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4361
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4362
-        }
4363
-
4364
-        $location_single = $gd_region;
4365
-    } else if ($gd_country != '') {
4366
-        if ($gd_country_actual != '') {
4367
-            $gd_country = $gd_country_actual;
4368
-        } else {
4369
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4370
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4371
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4372
-        }
4373
-
4374
-        $location_single = $gd_country;
4375
-    }
4376
-
4377
-    if (!empty($location_array)) {
4378
-
4379
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4380
-        $location_array = array_reverse($location_array);
4381
-
4382
-        foreach ($location_array as $location_type => $location) {
4383
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4384
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4385
-
4386
-            $location_name = geodir_ucwords($gd_location_link_text);
4387
-            $location_name = __($location_name, 'geodirectory');
4388
-
4389
-            if ($actual_location_name) {
4390
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4391
-                $location_name = get_actual_location_name($location_type, $location, true);
4392
-            }
4393
-
4394
-            $location_titles[] = $location_name;
4395
-        }
4396
-        if (!empty($location_titles)) {
4397
-            $location_titles = array_unique($location_titles);
4398
-        }
4399
-    }
4400
-
4401
-
4402
-    if(strpos($title,'%%location%%') !== false){
4403
-        $location = '';
4404
-        if($location_titles) {
4405
-            $location = implode(", ", $location_titles);
4406
-        }
4407
-        $title = str_replace("%%location%%",$location,$title);
4408
-    }
4409
-
4410
-    if(strpos($title,'%%in_location%%') !== false){
4411
-        $location = '';
4412
-        if($location_titles) {
4413
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4414
-        }
4415
-        $title = str_replace("%%in_location%%",$location,$title);
4416
-    }
4417
-
4418
-    if(strpos($title,'%%in_location_single%%') !== false){
4419
-        if($location_single) {
4420
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4421
-        }
4422
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4423
-    }
4424
-
4425
-    if(strpos($title,'%%location_single%%') !== false){
4426
-        $title = str_replace("%%location_single%%",$location_single,$title);
4427
-    }
4428
-
4429
-
4430
-    if(strpos($title,'%%search_term%%') !== false){
4431
-        $search_term = '';
4432
-        if(isset($_REQUEST['s'])){
4433
-            $search_term = esc_attr($_REQUEST['s']);
4434
-        }
4435
-        $title = str_replace("%%search_term%%",$search_term,$title);
4436
-    }
4437
-
4438
-    if(strpos($title,'%%search_near%%') !== false){
4439
-        $search_term = '';
4440
-        if(isset($_REQUEST['snear'])){
4441
-            $search_term = esc_attr($_REQUEST['snear']);
4442
-        }
4443
-        $title = str_replace("%%search_near%%",$search_term,$title);
4444
-    }
4445
-
4446
-    if(strpos($title,'%%name%%') !== false){
4447
-        $author_name = get_the_author();
4448
-        if (!$author_name || $author_name === '') {
4449
-            $queried_object = get_queried_object();
4266
+		$title = str_replace("%%pt_plural%%", $plural_name, $title);
4267
+	}
4268
+
4269
+	if (strpos($title, '%%category%%') !== false) {
4270
+		$cat_name = '';
4271
+
4272
+		if ($gd_page=='detail') {
4273
+			if ($post->default_category) {
4274
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4275
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4276
+			}
4277
+		} else if ($gd_page == 'listing') {
4278
+			$queried_object = get_queried_object();
4279
+			if (isset($queried_object->name)) {
4280
+				$cat_name = $queried_object->name;
4281
+			}
4282
+		}
4283
+		$title = str_replace("%%category%%", $cat_name, $title);
4284
+	}
4285
+
4286
+	if (strpos($title, '%%tag%%') !== false) {
4287
+		$cat_name = '';
4288
+
4289
+		if ($gd_page=='detail') {
4290
+			if ($post->default_category) {
4291
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4292
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4293
+			}
4294
+		} else if($gd_page == 'listing') {
4295
+			$queried_object = get_queried_object();
4296
+			if (isset($queried_object->name)) {
4297
+				$cat_name = $queried_object->name;
4298
+			}
4299
+		}
4300
+		$title = str_replace("%%tag%%", $cat_name, $title);
4301
+	}
4302
+
4303
+	if (strpos($title, '%%id%%') !== false) {
4304
+		$ID = (isset($post->ID)) ? $post->ID : '';
4305
+		$title = str_replace("%%id%%", $ID, $title);
4306
+	}
4307
+
4308
+	if (strpos($title,'%%sep%%') !== false) {
4309
+		$title = str_replace("%%sep%%", $sep, $title);
4310
+	}
4311
+
4312
+	// location variables
4313
+	$gd_post_type = geodir_get_current_posttype();
4314
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4315
+	/**
4316
+	 * Filter the title variables location variables array
4317
+	 *
4318
+	 * @since 1.5.5
4319
+	 * @package GeoDirectory
4320
+	 * @param array $location_array The array of location variables.
4321
+	 * @param string $title The title with variables..
4322
+	 * @param string $gd_page The page being filtered.
4323
+	 * @param string $sep The separator, default: `|`.
4324
+	 */
4325
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4326
+	$location_titles = array();
4327
+	if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4328
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4329
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4330
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4331
+	}
4332
+	$location_single = '';
4333
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4334
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4335
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4336
+
4337
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4338
+
4339
+	if (function_exists('get_actual_location_name')) {
4340
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4341
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4342
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4343
+	}
4344
+
4345
+	if ($gd_city != '') {
4346
+		if ($gd_city_actual != '') {
4347
+			$gd_city = $gd_city_actual;
4348
+		} else {
4349
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4350
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4351
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4352
+		}
4353
+		$location_single = $gd_city;
4354
+
4355
+	} else if ($gd_region != '') {
4356
+		if ($gd_region_actual != '') {
4357
+			$gd_region = $gd_region_actual;
4358
+		} else {
4359
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4360
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4361
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4362
+		}
4363
+
4364
+		$location_single = $gd_region;
4365
+	} else if ($gd_country != '') {
4366
+		if ($gd_country_actual != '') {
4367
+			$gd_country = $gd_country_actual;
4368
+		} else {
4369
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4370
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4371
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4372
+		}
4373
+
4374
+		$location_single = $gd_country;
4375
+	}
4376
+
4377
+	if (!empty($location_array)) {
4378
+
4379
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4380
+		$location_array = array_reverse($location_array);
4381
+
4382
+		foreach ($location_array as $location_type => $location) {
4383
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4384
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4385
+
4386
+			$location_name = geodir_ucwords($gd_location_link_text);
4387
+			$location_name = __($location_name, 'geodirectory');
4388
+
4389
+			if ($actual_location_name) {
4390
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4391
+				$location_name = get_actual_location_name($location_type, $location, true);
4392
+			}
4393
+
4394
+			$location_titles[] = $location_name;
4395
+		}
4396
+		if (!empty($location_titles)) {
4397
+			$location_titles = array_unique($location_titles);
4398
+		}
4399
+	}
4400
+
4401
+
4402
+	if(strpos($title,'%%location%%') !== false){
4403
+		$location = '';
4404
+		if($location_titles) {
4405
+			$location = implode(", ", $location_titles);
4406
+		}
4407
+		$title = str_replace("%%location%%",$location,$title);
4408
+	}
4409
+
4410
+	if(strpos($title,'%%in_location%%') !== false){
4411
+		$location = '';
4412
+		if($location_titles) {
4413
+			$location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4414
+		}
4415
+		$title = str_replace("%%in_location%%",$location,$title);
4416
+	}
4417
+
4418
+	if(strpos($title,'%%in_location_single%%') !== false){
4419
+		if($location_single) {
4420
+			$location_single = __('in', 'geodirectory') . ' ' .$location_single;
4421
+		}
4422
+		$title = str_replace("%%in_location_single%%",$location_single,$title);
4423
+	}
4424
+
4425
+	if(strpos($title,'%%location_single%%') !== false){
4426
+		$title = str_replace("%%location_single%%",$location_single,$title);
4427
+	}
4428
+
4429
+
4430
+	if(strpos($title,'%%search_term%%') !== false){
4431
+		$search_term = '';
4432
+		if(isset($_REQUEST['s'])){
4433
+			$search_term = esc_attr($_REQUEST['s']);
4434
+		}
4435
+		$title = str_replace("%%search_term%%",$search_term,$title);
4436
+	}
4437
+
4438
+	if(strpos($title,'%%search_near%%') !== false){
4439
+		$search_term = '';
4440
+		if(isset($_REQUEST['snear'])){
4441
+			$search_term = esc_attr($_REQUEST['snear']);
4442
+		}
4443
+		$title = str_replace("%%search_near%%",$search_term,$title);
4444
+	}
4445
+
4446
+	if(strpos($title,'%%name%%') !== false){
4447
+		$author_name = get_the_author();
4448
+		if (!$author_name || $author_name === '') {
4449
+			$queried_object = get_queried_object();
4450 4450
             
4451
-            if (isset($queried_object->data->user_nicename)) {
4452
-                $author_name = $queried_object->data->display_name;
4453
-            }
4454
-        }
4455
-        $title = str_replace("%%name%%", $author_name, $title);
4456
-    }
4451
+			if (isset($queried_object->data->user_nicename)) {
4452
+				$author_name = $queried_object->data->display_name;
4453
+			}
4454
+		}
4455
+		$title = str_replace("%%name%%", $author_name, $title);
4456
+	}
4457 4457
     
4458
-    if (strpos($title, '%%page%%') !== false) {
4459
-        $page = geodir_title_meta_page($sep);
4460
-        $title = str_replace("%%page%%", $page, $title);
4461
-    }
4462
-    if (strpos($title, '%%pagenumber%%') !== false) {
4463
-        $pagenumber = geodir_title_meta_pagenumber();
4464
-        $title = str_replace("%%pagenumber%%", $pagenumber, $title);
4465
-    }
4466
-    if (strpos($title, '%%pagetotal%%') !== false) {
4467
-        $pagetotal = geodir_title_meta_pagetotal();
4468
-        $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4469
-    }
4470
-
4471
-    $title = wptexturize( $title );
4472
-    $title = convert_chars( $title );
4473
-    $title = esc_html( $title );
4474
-
4475
-    /**
4476
-     * Filter the title variables after standard ones have been filtered.
4477
-     *
4478
-     * @since 1.5.7
4479
-     * @package GeoDirectory
4480
-     * @param string $title The title with variables.
4481
-     * @param array $location_array The array of location variables.
4482
-     * @param string $gd_page The page being filtered.
4483
-     * @param string $sep The separator, default: `|`.
4484
-     */
4485
-
4486
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4458
+	if (strpos($title, '%%page%%') !== false) {
4459
+		$page = geodir_title_meta_page($sep);
4460
+		$title = str_replace("%%page%%", $page, $title);
4461
+	}
4462
+	if (strpos($title, '%%pagenumber%%') !== false) {
4463
+		$pagenumber = geodir_title_meta_pagenumber();
4464
+		$title = str_replace("%%pagenumber%%", $pagenumber, $title);
4465
+	}
4466
+	if (strpos($title, '%%pagetotal%%') !== false) {
4467
+		$pagetotal = geodir_title_meta_pagetotal();
4468
+		$title = str_replace("%%pagetotal%%", $pagetotal, $title);
4469
+	}
4470
+
4471
+	$title = wptexturize( $title );
4472
+	$title = convert_chars( $title );
4473
+	$title = esc_html( $title );
4474
+
4475
+	/**
4476
+	 * Filter the title variables after standard ones have been filtered.
4477
+	 *
4478
+	 * @since 1.5.7
4479
+	 * @package GeoDirectory
4480
+	 * @param string $title The title with variables.
4481
+	 * @param array $location_array The array of location variables.
4482
+	 * @param string $gd_page The page being filtered.
4483
+	 * @param string $sep The separator, default: `|`.
4484
+	 */
4485
+
4486
+	return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4487 4487
 }
4488 4488
 
4489 4489
 /**
@@ -4496,65 +4496,65 @@  discard block
 block discarded – undo
4496 4496
  * @return array Translation texts.
4497 4497
  */
4498 4498
 function geodir_load_cpt_text_translation($translation_texts = array()) {
4499
-    $gd_post_types = geodir_get_posttypes('array');
4500
-
4501
-    if (!empty($gd_post_types)) {
4502
-        foreach ($gd_post_types as $post_type => $cpt_info) {
4503
-            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4504
-            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4505
-            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4506
-
4507
-            if (!empty($labels)) {
4508
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4509
-                    $translation_texts[] = $labels['name'];
4510
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4511
-                    $translation_texts[] = $labels['singular_name'];
4512
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4513
-                    $translation_texts[] = $labels['add_new'];
4514
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4515
-                    $translation_texts[] = $labels['add_new_item'];
4516
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4517
-                    $translation_texts[] = $labels['edit_item'];
4518
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4519
-                    $translation_texts[] = $labels['new_item'];
4520
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4521
-                    $translation_texts[] = $labels['view_item'];
4522
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4523
-                    $translation_texts[] = $labels['search_items'];
4524
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4525
-                    $translation_texts[] = $labels['not_found'];
4526
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4527
-                    $translation_texts[] = $labels['not_found_in_trash'];
4528
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4529
-                    $translation_texts[] = $labels['label_post_profile'];
4530
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4531
-                    $translation_texts[] = $labels['label_post_info'];
4532
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4533
-                    $translation_texts[] = $labels['label_post_images'];
4534
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4535
-                    $translation_texts[] = $labels['label_post_map'];
4536
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4537
-                    $translation_texts[] = $labels['label_reviews'];
4538
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4539
-                    $translation_texts[] = $labels['label_related_listing'];
4540
-            }
4541
-
4542
-            if ($description != '' && !in_array($description, $translation_texts)) {
4543
-                $translation_texts[] = normalize_whitespace($description);
4544
-            }
4545
-
4546
-            if (!empty($seo)) {
4547
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4548
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4549
-
4550
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4551
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4552
-            }
4553
-        }
4554
-    }
4555
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4556
-
4557
-    return $translation_texts;
4499
+	$gd_post_types = geodir_get_posttypes('array');
4500
+
4501
+	if (!empty($gd_post_types)) {
4502
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4503
+			$labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4504
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4505
+			$seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4506
+
4507
+			if (!empty($labels)) {
4508
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4509
+					$translation_texts[] = $labels['name'];
4510
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4511
+					$translation_texts[] = $labels['singular_name'];
4512
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4513
+					$translation_texts[] = $labels['add_new'];
4514
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4515
+					$translation_texts[] = $labels['add_new_item'];
4516
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4517
+					$translation_texts[] = $labels['edit_item'];
4518
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4519
+					$translation_texts[] = $labels['new_item'];
4520
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4521
+					$translation_texts[] = $labels['view_item'];
4522
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4523
+					$translation_texts[] = $labels['search_items'];
4524
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4525
+					$translation_texts[] = $labels['not_found'];
4526
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4527
+					$translation_texts[] = $labels['not_found_in_trash'];
4528
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4529
+					$translation_texts[] = $labels['label_post_profile'];
4530
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4531
+					$translation_texts[] = $labels['label_post_info'];
4532
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4533
+					$translation_texts[] = $labels['label_post_images'];
4534
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4535
+					$translation_texts[] = $labels['label_post_map'];
4536
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4537
+					$translation_texts[] = $labels['label_reviews'];
4538
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4539
+					$translation_texts[] = $labels['label_related_listing'];
4540
+			}
4541
+
4542
+			if ($description != '' && !in_array($description, $translation_texts)) {
4543
+				$translation_texts[] = normalize_whitespace($description);
4544
+			}
4545
+
4546
+			if (!empty($seo)) {
4547
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4548
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4549
+
4550
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4551
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4552
+			}
4553
+		}
4554
+	}
4555
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4556
+
4557
+	return $translation_texts;
4558 4558
 }
4559 4559
 
4560 4560
 /**
@@ -4567,27 +4567,27 @@  discard block
 block discarded – undo
4567 4567
  * @return array Location terms.
4568 4568
  */
4569 4569
 function geodir_remove_location_terms($location_terms = array()) {
4570
-    $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4571
-
4572
-    if (!empty($location_terms) && $location_manager) {
4573
-        $hide_country_part = get_option('geodir_location_hide_country_part');
4574
-        $hide_region_part = get_option('geodir_location_hide_region_part');
4575
-
4576
-        if ($hide_region_part && $hide_country_part) {
4577
-            if (isset($location_terms['gd_country']))
4578
-                unset($location_terms['gd_country']);
4579
-            if (isset($location_terms['gd_region']))
4580
-                unset($location_terms['gd_region']);
4581
-        } else if ($hide_region_part && !$hide_country_part) {
4582
-            if (isset($location_terms['gd_region']))
4583
-                unset($location_terms['gd_region']);
4584
-        } else if (!$hide_region_part && $hide_country_part) {
4585
-            if (isset($location_terms['gd_country']))
4586
-                unset($location_terms['gd_country']);
4587
-        }
4588
-    }
4589
-
4590
-    return $location_terms;
4570
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4571
+
4572
+	if (!empty($location_terms) && $location_manager) {
4573
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4574
+		$hide_region_part = get_option('geodir_location_hide_region_part');
4575
+
4576
+		if ($hide_region_part && $hide_country_part) {
4577
+			if (isset($location_terms['gd_country']))
4578
+				unset($location_terms['gd_country']);
4579
+			if (isset($location_terms['gd_region']))
4580
+				unset($location_terms['gd_region']);
4581
+		} else if ($hide_region_part && !$hide_country_part) {
4582
+			if (isset($location_terms['gd_region']))
4583
+				unset($location_terms['gd_region']);
4584
+		} else if (!$hide_region_part && $hide_country_part) {
4585
+			if (isset($location_terms['gd_country']))
4586
+				unset($location_terms['gd_country']);
4587
+		}
4588
+	}
4589
+
4590
+	return $location_terms;
4591 4591
 }
4592 4592
 
4593 4593
 /**
@@ -4601,47 +4601,47 @@  discard block
 block discarded – undo
4601 4601
  * @param bool $update Whether this is an existing listing being updated or not.
4602 4602
  */
4603 4603
 function geodir_on_wp_insert_post($post_ID, $post, $update) {
4604
-    if (!$update) {
4605
-        return;
4606
-    }
4604
+	if (!$update) {
4605
+		return;
4606
+	}
4607 4607
     
4608
-    $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4609
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4610
-    $inline_save = $action == 'inline-save' ? true : false;
4608
+	$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4609
+	$is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4610
+	$inline_save = $action == 'inline-save' ? true : false;
4611 4611
 
4612
-    if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4613
-        return;
4614
-    }
4612
+	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4613
+		return;
4614
+	}
4615 4615
     
4616
-    if ($action != '' && in_array($action, array('geodir_import_export'))) {
4617
-        return;
4618
-    }
4616
+	if ($action != '' && in_array($action, array('geodir_import_export'))) {
4617
+		return;
4618
+	}
4619 4619
 
4620
-    $user_id = (int)get_current_user_id();
4620
+	$user_id = (int)get_current_user_id();
4621 4621
         
4622
-    if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4623
-        $author_id = !empty($post->post_author) ? $post->post_author : 0;
4622
+	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4623
+		$author_id = !empty($post->post_author) ? $post->post_author : 0;
4624 4624
         
4625
-        if ($user_id == $author_id && !is_super_admin()) {
4626
-            $from_email = get_option('site_email');
4627
-            $from_name = get_site_emailName();
4628
-            $to_email = get_option('admin_email');
4629
-            $to_name = get_option('name');
4630
-            $message_type = 'listing_edited';
4625
+		if ($user_id == $author_id && !is_super_admin()) {
4626
+			$from_email = get_option('site_email');
4627
+			$from_name = get_site_emailName();
4628
+			$to_email = get_option('admin_email');
4629
+			$to_name = get_option('name');
4630
+			$message_type = 'listing_edited';
4631 4631
             
4632
-            $notify_edited = true;
4633
-            /**
4634
-             * Send notification when listing edited by author?
4635
-             *
4636
-             * @since 1.6.0
4637
-             * @param bool $notify_edited Notify on listing edited by author?
4638
-             * @param object $post The current post object.
4639
-             */
4640
-            $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4632
+			$notify_edited = true;
4633
+			/**
4634
+			 * Send notification when listing edited by author?
4635
+			 *
4636
+			 * @since 1.6.0
4637
+			 * @param bool $notify_edited Notify on listing edited by author?
4638
+			 * @param object $post The current post object.
4639
+			 */
4640
+			$notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4641 4641
             
4642
-            geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4643
-        }
4644
-    }
4642
+			geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4643
+		}
4644
+	}
4645 4645
 }
4646 4646
 
4647 4647
 /**
@@ -4655,16 +4655,16 @@  discard block
 block discarded – undo
4655 4655
  * @return string|null The current page start & end numbering.
4656 4656
  */
4657 4657
 function geodir_title_meta_page($sep) {
4658
-    $replacement = null;
4658
+	$replacement = null;
4659 4659
 
4660
-    $max = geodir_title_meta_pagenumbering('max');
4661
-    $nr  = geodir_title_meta_pagenumbering('nr');
4660
+	$max = geodir_title_meta_pagenumbering('max');
4661
+	$nr  = geodir_title_meta_pagenumbering('nr');
4662 4662
 
4663
-    if ($max > 1 && $nr > 1) {
4664
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4665
-    }
4663
+	if ($max > 1 && $nr > 1) {
4664
+		$replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4665
+	}
4666 4666
 
4667
-    return $replacement;
4667
+	return $replacement;
4668 4668
 }
4669 4669
 
4670 4670
 /**
@@ -4676,14 +4676,14 @@  discard block
 block discarded – undo
4676 4676
  * @return string|null The current page number.
4677 4677
  */
4678 4678
 function geodir_title_meta_pagenumber() {
4679
-    $replacement = null;
4679
+	$replacement = null;
4680 4680
 
4681
-    $nr = geodir_title_meta_pagenumbering('nr');
4682
-    if (isset($nr) && $nr > 0) {
4683
-        $replacement = (string)$nr;
4684
-    }
4681
+	$nr = geodir_title_meta_pagenumbering('nr');
4682
+	if (isset($nr) && $nr > 0) {
4683
+		$replacement = (string)$nr;
4684
+	}
4685 4685
 
4686
-    return $replacement;
4686
+	return $replacement;
4687 4687
 }
4688 4688
 
4689 4689
 /**
@@ -4695,14 +4695,14 @@  discard block
 block discarded – undo
4695 4695
  * @return string|null The current page total.
4696 4696
  */
4697 4697
 function geodir_title_meta_pagetotal() {
4698
-    $replacement = null;
4698
+	$replacement = null;
4699 4699
 
4700
-    $max = geodir_title_meta_pagenumbering('max');
4701
-    if (isset($max) && $max > 0) {
4702
-        $replacement = (string)$max;
4703
-    }
4700
+	$max = geodir_title_meta_pagenumbering('max');
4701
+	if (isset($max) && $max > 0) {
4702
+		$replacement = (string)$max;
4703
+	}
4704 4704
 
4705
-    return $replacement;
4705
+	return $replacement;
4706 4706
 }
4707 4707
 
4708 4708
 /**
@@ -4719,44 +4719,44 @@  discard block
 block discarded – undo
4719 4719
  * @return int|null The current page numbering.
4720 4720
  */
4721 4721
 function geodir_title_meta_pagenumbering($request = 'nr') {
4722
-    global $wp_query, $post;
4723
-    $max_num_pages = null;
4724
-    $page_number   = null;
4725
-
4726
-    $max_num_pages = 1;
4727
-
4728
-    if (!is_singular()) {
4729
-        $page_number = get_query_var('paged');
4730
-        if ($page_number === 0 || $page_number === '') {
4731
-            $page_number = 1;
4732
-        }
4733
-
4734
-        if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4735
-            $max_num_pages = $wp_query->max_num_pages;
4736
-        }
4737
-    } else {
4738
-        $page_number = get_query_var('page');
4739
-        if ($page_number === 0 || $page_number === '') {
4740
-            $page_number = 1;
4741
-        }
4742
-
4743
-        if (isset($post->post_content)) {
4744
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4745
-        }
4746
-    }
4747
-
4748
-    $return = null;
4749
-
4750
-    switch ($request) {
4751
-        case 'nr':
4752
-            $return = $page_number;
4753
-            break;
4754
-        case 'max':
4755
-            $return = $max_num_pages;
4756
-            break;
4757
-    }
4758
-
4759
-    return $return;
4722
+	global $wp_query, $post;
4723
+	$max_num_pages = null;
4724
+	$page_number   = null;
4725
+
4726
+	$max_num_pages = 1;
4727
+
4728
+	if (!is_singular()) {
4729
+		$page_number = get_query_var('paged');
4730
+		if ($page_number === 0 || $page_number === '') {
4731
+			$page_number = 1;
4732
+		}
4733
+
4734
+		if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4735
+			$max_num_pages = $wp_query->max_num_pages;
4736
+		}
4737
+	} else {
4738
+		$page_number = get_query_var('page');
4739
+		if ($page_number === 0 || $page_number === '') {
4740
+			$page_number = 1;
4741
+		}
4742
+
4743
+		if (isset($post->post_content)) {
4744
+			$max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4745
+		}
4746
+	}
4747
+
4748
+	$return = null;
4749
+
4750
+	switch ($request) {
4751
+		case 'nr':
4752
+			$return = $page_number;
4753
+			break;
4754
+		case 'max':
4755
+			$return = $max_num_pages;
4756
+			break;
4757
+	}
4758
+
4759
+	return $return;
4760 4760
 }
4761 4761
 
4762 4762
 /**
@@ -4768,17 +4768,17 @@  discard block
 block discarded – undo
4768 4768
  * @return array Terms.
4769 4769
  */
4770 4770
 function geodir_filter_empty_terms($terms) {
4771
-    if (empty($terms)) {
4772
-        return $terms;
4773
-    }
4774
-
4775
-    $return = array();
4776
-    foreach ($terms as $term) {
4777
-        if (isset($term->count) && $term->count > 0) {
4778
-            $return[] = $term;
4779
-        }
4780
-    }
4781
-    return $return;
4771
+	if (empty($terms)) {
4772
+		return $terms;
4773
+	}
4774
+
4775
+	$return = array();
4776
+	foreach ($terms as $term) {
4777
+		if (isset($term->count) && $term->count > 0) {
4778
+			$return[] = $term;
4779
+		}
4780
+	}
4781
+	return $return;
4782 4782
 }
4783 4783
 
4784 4784
 
@@ -4791,9 +4791,9 @@  discard block
 block discarded – undo
4791 4791
  * @return array
4792 4792
  */
4793 4793
 function geodir_remove_hentry( $class ) {
4794
-    if(geodir_is_page('detail')){
4795
-        $class = array_diff( $class, array( 'hentry' ) );
4796
-    }
4797
-    return $class;
4794
+	if(geodir_is_page('detail')){
4795
+		$class = array_diff( $class, array( 'hentry' ) );
4796
+	}
4797
+	return $class;
4798 4798
 }
4799 4799
 add_filter( 'post_class', 'geodir_remove_hentry' );
4800 4800
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * Get All Plugin functions from WordPress
12 12
  */
13
-include_once(ABSPATH . 'wp-admin/includes/plugin.php');
13
+include_once(ABSPATH.'wp-admin/includes/plugin.php');
14 14
 
15 15
 /*-----------------------------------------------------------------------------------*/
16 16
 /* Helper functions */
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 {
30 30
 
31 31
     if (is_ssl()) :
32
-        return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
32
+        return str_replace('http://', 'https://', WP_PLUGIN_URL)."/".plugin_basename(dirname(dirname(__FILE__)));
33 33
     else :
34
-        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
34
+        return WP_PLUGIN_URL."/".plugin_basename(dirname(dirname(__FILE__)));
35 35
     endif;
36 36
 }
37 37
 
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_plugin_path()
49 49
 {
50
-    if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
50
+    if (defined('GD_TESTING_MODE') && GD_TESTING_MODE) {
51 51
         return dirname(dirname(__FILE__));
52 52
     } else {
53
-        return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
53
+        return WP_PLUGIN_DIR."/".plugin_basename(dirname(dirname(__FILE__)));
54 54
     }
55 55
 }
56 56
 
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
     foreach ($params as $key => $value) {
130 130
         if (gettype($value) == 'array') { //Handle array data properly
131 131
             foreach ($value as $val) {
132
-                $params_arr[] = $key . '[]=' . urlencode($val);
132
+                $params_arr[] = $key.'[]='.urlencode($val);
133 133
             }
134 134
         } else {
135
-            $params_arr[] = $key . '=' . urlencode($value);
135
+            $params_arr[] = $key.'='.urlencode($value);
136 136
         }
137 137
     }
138 138
     $link .= implode('&', $params_arr);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
         $add_listing_link = get_page_link(geodir_add_listing_page_id());
162 162
 
163
-        return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
163
+        return esc_url(add_query_arg(array('listing_type' => $post_type), $add_listing_link));
164 164
     } else
165 165
         return get_bloginfo('url');
166 166
 }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         $pageURL .= "s";
181 181
     }
182 182
     $pageURL .= "://";
183
-    $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
183
+    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
184 184
     /**
185 185
      * Filter the current page URL returned by function geodir_curPageURL().
186 186
      *
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 function geodir_is_page($gdpage = '')
253 253
 {
254 254
 
255
-    global $wp_query, $post,$wp;
255
+    global $wp_query, $post, $wp;
256 256
     //if(!is_admin()):
257 257
 
258 258
     switch ($gdpage):
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
             break;
278 278
         case 'detail':
279 279
             $post_type = get_query_var('post_type');
280
-            if(is_array($post_type)){$post_type = reset($post_type);}
280
+            if (is_array($post_type)) {$post_type = reset($post_type); }
281 281
             if (is_single() && in_array($post_type, geodir_get_posttypes()))
282 282
                 return true;
283 283
             break;
284 284
         case 'pt':
285 285
             $post_type = get_query_var('post_type');
286
-            if(is_array($post_type)){$post_type = reset($post_type);}
287
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
286
+            if (is_array($post_type)) {$post_type = reset($post_type); }
287
+            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()) && !is_tax())
288 288
                 return true;
289 289
 
290 290
             break;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                 return true;
296 296
             }
297 297
             $post_type = get_query_var('post_type');
298
-            if(is_array($post_type)){$post_type = reset($post_type);}
298
+            if (is_array($post_type)) {$post_type = reset($post_type); }
299 299
             if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300 300
                 return true;
301 301
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
             if (is_author() && isset($_REQUEST['geodir_dashbord']))
315 315
                 return true;
316 316
 			
317
-			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
318
-				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
317
+			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
318
+				if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
319 319
 					return true;
320 320
 				}
321 321
 			}
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369 369
             if (get_option('geodir_set_as_home'))
370 370
                 $wp->query_vars['gd_is_geodir_page'] = true;
371
-            if(geodir_is_page('home')){
371
+            if (geodir_is_page('home')) {
372 372
                 $wp->query_vars['gd_is_geodir_page'] = true;
373 373
             }
374 374
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
         if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422 422
             $geodir_taxonomis = geodir_get_taxonomies('', true);
423
-            if(!empty($geodir_taxonomis)){
423
+            if (!empty($geodir_taxonomis)) {
424 424
                 foreach ($geodir_taxonomis as $taxonomy) {
425 425
                     if (array_key_exists($taxonomy, $wp->query_vars)) {
426 426
                         $wp->query_vars['gd_is_geodir_page'] = true;
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 
441 441
 
442 442
 //check if homepage
443
-        if(!isset($wp->query_vars['gd_is_geodir_page'])
443
+        if (!isset($wp->query_vars['gd_is_geodir_page'])
444 444
             && !isset($wp->query_vars['page_id'])
445 445
             && !isset($wp->query_vars['pagename'])
446
-            && is_page_geodir_home()){
446
+            && is_page_geodir_home()) {
447 447
             $wp->query_vars['gd_is_geodir_page'] = true;
448 448
         }
449 449
         //echo $wp->query_vars['gd_is_geodir_page'] ;
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
              * @since 1.0.0
506 506
              * @param array $imagesizes[$size] Image size array of the passed key.
507 507
              */
508
-            return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
508
+            return apply_filters('geodir_get_imagesize_'.$size, $imagesizes[$size]);
509 509
 
510 510
         } elseif (!empty($size)) {
511 511
 
@@ -544,13 +544,13 @@  discard block
 block discarded – undo
544 544
     function createRandomString()
545 545
     {
546 546
         $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
-        srand((double)microtime() * 1000000);
547
+        srand((double) microtime() * 1000000);
548 548
         $i = 0;
549 549
         $rstring = '';
550 550
         while ($i <= 25) {
551 551
             $num = rand() % 33;
552 552
             $tmp = substr($chars, $num, 1);
553
-            $rstring = $rstring . $tmp;
553
+            $rstring = $rstring.$tmp;
554 554
             $i++;
555 555
         }
556 556
         return $rstring;
@@ -681,11 +681,11 @@  discard block
 block discarded – undo
681 681
         }
682 682
 		
683 683
 		if (!empty($subject)) {
684
-			$subject = __(stripslashes_deep($subject),'geodirectory');
684
+			$subject = __(stripslashes_deep($subject), 'geodirectory');
685 685
 		}
686 686
 		
687 687
 		if (!empty($message)) {
688
-			$message = __(stripslashes_deep($message),'geodirectory');
688
+			$message = __(stripslashes_deep($message), 'geodirectory');
689 689
 		}
690 690
 
691 691
         $to_message = nl2br($to_message);
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 
706 706
         if ($post_info) {
707 707
             $posted_date = $post_info->post_date;
708
-            $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
708
+            $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
709 709
         }
710 710
         $siteurl = home_url();
711
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
711
+        $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
712 712
         $loginurl = geodir_login_url();
713
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
713
+        $loginurl_link = '<a href="'.$loginurl.'">login</a>';
714 714
         
715 715
         $post_author_id = !empty($post_info) ? $post_info->post_author : 0;
716 716
         $post_author_name = geodir_get_client_name($post_author_id);
@@ -724,18 +724,18 @@  discard block
 block discarded – undo
724 724
             $fromEmailName = get_option('site_email_name');
725 725
         }
726 726
 
727
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
727
+        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]', '[#post_author_id#]', '[#post_author_name#]', '[#current_date#]');
728
+        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729 729
         $message = str_replace($search_array, $replace_array, $message);
730 730
 
731
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
731
+        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]', '[#post_author_id#]', '[#post_author_name#]', '[#current_date#]');
732
+        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733 733
         $subject = str_replace($search_array, $replace_array, $subject);
734 734
 
735
-        $headers = 'MIME-Version: 1.0' . "\r\n";
736
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
737
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
738
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
735
+        $headers = 'MIME-Version: 1.0'."\r\n";
736
+        $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
737
+        $headers .= "Reply-To: ".$fromEmail."\r\n";
738
+        $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'."\r\n";
739 739
 
740 740
         $to = $toEmail;
741 741
 
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
          * @param string $post_id The post ID.
757 757
          * @param string $user_id The user ID.
758 758
          */
759
-        $to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
759
+        $to = apply_filters('geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
760 760
         /**
761 761
          * Filter the client email subject.
762 762
          *
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
          * @param string $post_id The post ID.
775 775
          * @param string $user_id The user ID.
776 776
          */
777
-        $subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
777
+        $subject = apply_filters('geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
778 778
         /**
779 779
          * Filter the client email message.
780 780
          *
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
          * @param string $post_id The post ID.
793 793
          * @param string $user_id The user ID.
794 794
          */
795
-        $message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
795
+        $message = apply_filters('geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
796 796
         /**
797 797
          * Filter the client email headers.
798 798
          *
@@ -810,22 +810,22 @@  discard block
 block discarded – undo
810 810
          * @param string $post_id The post ID.
811 811
          * @param string $user_id The user ID.
812 812
          */
813
-        $headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
813
+        $headers = apply_filters('geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
814 814
 
815 815
         $sent = wp_mail($to, $subject, $message, $headers);
816 816
 
817
-        if( ! $sent ) {
818
-            if ( is_array( $to ) ) {
819
-                $to = implode( ',', $to );
817
+        if (!$sent) {
818
+            if (is_array($to)) {
819
+                $to = implode(',', $to);
820 820
             }
821 821
             $log_message = sprintf(
822
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
822
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
823 823
                 $message_type,
824
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
824
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
825 825
                 $to,
826 826
                 $subject
827 827
             );
828
-            geodir_error_log( $log_message );
828
+            geodir_error_log($log_message);
829 829
         }
830 830
 
831 831
         ///////// ADMIN BCC EMIALS
@@ -837,11 +837,11 @@  discard block
 block discarded – undo
837 837
             $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
838 838
             $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
839 839
 
840
-            $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#]');
840
+            $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#]');
841 841
             $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);
842 842
             $message = str_replace($search_array, $replace_array, $message);
843 843
 
844
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
844
+            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
845 845
             $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
846 846
             $subject = str_replace($search_array, $replace_array, $subject);
847 847
 
@@ -866,21 +866,21 @@  discard block
 block discarded – undo
866 866
             $admin_bcc = true;
867 867
         }
868 868
 
869
-        if($admin_bcc===true){
869
+        if ($admin_bcc === true) {
870 870
             $sent = wp_mail($to, $subject, $message, $headers);
871 871
 
872
-            if( ! $sent ) {
873
-                if ( is_array( $to ) ) {
874
-                    $to = implode( ',', $to );
872
+            if (!$sent) {
873
+                if (is_array($to)) {
874
+                    $to = implode(',', $to);
875 875
                 }
876 876
                 $log_message = sprintf(
877
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
877
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
878 878
                     $message_type,
879
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
879
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
880 880
                     $to,
881 881
                     $subject
882 882
                 );
883
-                geodir_error_log( $log_message );
883
+                geodir_error_log($log_message);
884 884
             }
885 885
         }
886 886
 
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
         foreach ($parents as $parent):
913 913
             $item = get_term_by('id', $parent, get_query_var('taxonomy'));
914 914
             $url = get_term_link($item, get_query_var('taxonomy'));
915
-            echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
915
+            echo '<li> > <a href="'.$url.'">'.$item->name.'</a></li>';
916 916
         endforeach;
917 917
 
918 918
     endif;
919 919
 
920
-    echo '<li> > ' . $term->name . '</li>';
920
+    echo '<li> > '.$term->name.'</li>';
921 921
 }
922 922
 
923 923
 
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
          *
952 952
          * @since 1.0.0
953 953
          */
954
-        $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
954
+        $breadcrumb .= '<li>'.apply_filters('geodir_breadcrumb_first_link', '<a href="'.home_url().'">'.__('Home', 'geodirectory').'</a>').'</li>';
955 955
 
956 956
         $gd_post_type = geodir_get_current_posttype();
957 957
         $post_type_info = get_post_type_object($gd_post_type);
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
             $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
976 976
 			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
977 977
 				
978
-			if(geodir_is_page('detail') && isset($post->country_slug)){
978
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
979 979
                 $location_terms = array(
980 980
                     'gd_country' => $post->country_slug,
981 981
                     'gd_region' => $post->region_slug,
@@ -1030,12 +1030,12 @@  discard block
 block discarded – undo
1030 1030
             $is_location_last = '';
1031 1031
             $is_taxonomy_last = '';
1032 1032
             $breadcrumb .= '<li>';
1033
-            if (get_query_var($gd_post_type . 'category'))
1034
-                $gd_taxonomy = $gd_post_type . 'category';
1035
-            elseif (get_query_var($gd_post_type . '_tags'))
1036
-                $gd_taxonomy = $gd_post_type . '_tags';
1033
+            if (get_query_var($gd_post_type.'category'))
1034
+                $gd_taxonomy = $gd_post_type.'category';
1035
+            elseif (get_query_var($gd_post_type.'_tags'))
1036
+                $gd_taxonomy = $gd_post_type.'_tags';
1037 1037
 
1038
-            $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1038
+            $breadcrumb .= $separator.'<a href="'.$listing_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>';
1039 1039
             if (!empty($gd_taxonomy) || geodir_is_page('detail'))
1040 1040
                 $is_location_last = false;
1041 1041
             else
@@ -1085,18 +1085,18 @@  discard block
 block discarded – undo
1085 1085
                         }
1086 1086
 
1087 1087
                         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'] != '')) {
1088
-                            $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1088
+                            $breadcrumb .= $location_term_actual_country != '' ? $separator.$location_term_actual_country : $separator.$gd_location_link_text;
1089 1089
                         } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1090
-                            $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1090
+                            $breadcrumb .= $location_term_actual_region != '' ? $separator.$location_term_actual_region : $separator.$gd_location_link_text;
1091 1091
                         } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1092
-                            $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1092
+                            $breadcrumb .= $location_term_actual_city != '' ? $separator.$location_term_actual_city : $separator.$gd_location_link_text;
1093 1093
                         } else if ($is_location_last && $key == 'gd_neighbourhood') {
1094
-                            $breadcrumb .= $separator . $gd_location_link_text;
1094
+                            $breadcrumb .= $separator.$gd_location_link_text;
1095 1095
                         } else {
1096 1096
                             if (get_option('permalink_structure') != '') {
1097
-                                $location_link .= $location_term . '/';
1097
+                                $location_link .= $location_term.'/';
1098 1098
                             } else {
1099
-                                $location_link .= "&$key=" . $location_term;
1099
+                                $location_link .= "&$key=".$location_term;
1100 1100
                             }
1101 1101
 
1102 1102
                             if ($key == 'gd_country' && $location_term_actual_country != '') {
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
                             }
1114 1114
                             */
1115 1115
 
1116
-                            $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1116
+                            $breadcrumb .= $separator.'<a href="'.$location_link.'">'.$gd_location_link_text.'</a>';
1117 1117
                         }
1118 1118
                     }
1119 1119
                 }
@@ -1124,8 +1124,8 @@  discard block
 block discarded – undo
1124 1124
 
1125 1125
                 //if(get_option('geodir_add_categories_url'))
1126 1126
                 {
1127
-                    if (get_query_var($gd_post_type . '_tags')) {
1128
-                        $cat_link = $listing_link . 'tags/';
1127
+                    if (get_query_var($gd_post_type.'_tags')) {
1128
+                        $cat_link = $listing_link.'tags/';
1129 1129
                     } else
1130 1130
                         $cat_link = $listing_link;
1131 1131
 
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 
1137 1137
                         if ($location_term != '') {
1138 1138
                             if (get_option('permalink_structure') != '') {
1139
-                                $cat_link .= $location_term . '/';
1139
+                                $cat_link .= $location_term.'/';
1140 1140
                             }
1141 1141
                         }
1142 1142
                     }
@@ -1155,10 +1155,10 @@  discard block
 block discarded – undo
1155 1155
                         }
1156 1156
 
1157 1157
                         if ($term_index == count($term_array) && $is_taxonomy_last)
1158
-                            $breadcrumb .= $separator . $term_link_text;
1158
+                            $breadcrumb .= $separator.$term_link_text;
1159 1159
                         else {
1160
-                            $cat_link .= $term . '/';
1161
-                            $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1160
+                            $cat_link .= $term.'/';
1161
+                            $breadcrumb .= $separator.'<a href="'.$cat_link.'">'.$term_link_text.'</a>';
1162 1162
                         }
1163 1163
                         $term_index++;
1164 1164
                     }
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
             }
1169 1169
 
1170 1170
             if (geodir_is_page('detail'))
1171
-                $breadcrumb .= $separator . get_the_title();
1171
+                $breadcrumb .= $separator.get_the_title();
1172 1172
 
1173 1173
             $breadcrumb .= '</li>';
1174 1174
 
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
             $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1189 1189
 
1190 1190
             $breadcrumb .= '<li>';
1191
-            $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1191
+            $breadcrumb .= $separator.'<a href="'.$default_author_link.'">'.__('My Dashboard', 'geodirectory').'</a>';
1192 1192
 
1193 1193
             if (isset($_REQUEST['list'])) {
1194 1194
                 $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
@@ -1203,20 +1203,20 @@  discard block
 block discarded – undo
1203 1203
                  */
1204 1204
                 $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1205 1205
 
1206
-                $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1207
-                $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1206
+                $breadcrumb .= $separator.'<a href="'.$author_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>';
1207
+                $breadcrumb .= $separator.ucfirst(__('My', 'geodirectory').' '.$_REQUEST['list']);
1208 1208
             } else
1209
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1209
+                $breadcrumb .= $separator.__(ucfirst($post_type_info->label), 'geodirectory');
1210 1210
 
1211 1211
             $breadcrumb .= '</li>';
1212 1212
         } elseif (is_category() || is_single()) {
1213 1213
             $category = get_the_category();
1214 1214
             if (is_category()) {
1215
-                $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1215
+                $breadcrumb .= '<li>'.$separator.$category[0]->cat_name.'</li>';
1216 1216
             }
1217 1217
             if (is_single()) {
1218
-                $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1219
-                $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1218
+                $breadcrumb .= '<li>'.$separator.'<a href="'.get_category_link($category[0]->term_id).'">'.$category[0]->cat_name.'</a></li>';
1219
+                $breadcrumb .= '<li>'.$separator.get_the_title().'</li>';
1220 1220
             }
1221 1221
             /* End of my version ##################################################### */
1222 1222
         } else if (is_page()) {
@@ -1224,37 +1224,37 @@  discard block
 block discarded – undo
1224 1224
 
1225 1225
             if (geodir_is_page('location')) {
1226 1226
                 $location_page_id = geodir_location_page_id();
1227
-                $loc_post = get_post( $location_page_id );
1227
+                $loc_post = get_post($location_page_id);
1228 1228
                 $post_name = $loc_post->post_name;
1229
-                $slug= ucwords(str_replace('-',' ',$post_name));
1230
-                $page_title = !empty($slug )? $slug : __('Location', 'geodirectory');
1229
+                $slug = ucwords(str_replace('-', ' ', $post_name));
1230
+                $page_title = !empty($slug) ? $slug : __('Location', 'geodirectory');
1231 1231
             }
1232 1232
 
1233
-            $breadcrumb .= '<li>' . $separator;
1233
+            $breadcrumb .= '<li>'.$separator;
1234 1234
             $breadcrumb .= stripslashes_deep($page_title);
1235 1235
             $breadcrumb .= '</li>';
1236 1236
         } else if (is_tag()) {
1237
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1237
+            $breadcrumb .= "<li> ".$separator.single_tag_title('', false).'</li>';
1238 1238
         } else if (is_day()) {
1239
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1239
+            $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1240 1240
             the_time('F jS, Y');
1241 1241
             $breadcrumb .= '</li>';
1242 1242
         } else if (is_month()) {
1243
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1243
+            $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1244 1244
             the_time('F, Y');
1245 1245
             $breadcrumb .= '</li>';
1246 1246
         } else if (is_year()) {
1247
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1247
+            $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1248 1248
             the_time('Y');
1249 1249
             $breadcrumb .= '</li>';
1250 1250
         } else if (is_author()) {
1251
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1251
+            $breadcrumb .= "<li> ".$separator.__(" Author Archive", 'geodirectory');
1252 1252
             $breadcrumb .= '</li>';
1253 1253
         } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1254
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1254
+            $breadcrumb .= "<li>".$separator.__("Blog Archives", 'geodirectory');
1255 1255
             $breadcrumb .= '</li>';
1256 1256
         } else if (is_search()) {
1257
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1257
+            $breadcrumb .= "<li> ".$separator.__(" Search Results", 'geodirectory');
1258 1258
             $breadcrumb .= '</li>';
1259 1259
         }
1260 1260
         $breadcrumb .= '</ul></div>';
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 function fetch_remote_file($url)
1311 1311
 {
1312 1312
     // extract the file name and extension from the url
1313
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1313
+    require_once(ABSPATH.'wp-includes/pluggable.php');
1314 1314
     $file_name = basename($url);
1315 1315
     if (strpos($file_name, '?') !== false) {
1316 1316
         list($file_name) = explode('?', $file_name);
@@ -1342,15 +1342,15 @@  discard block
 block discarded – undo
1342 1342
         return new WP_Error('upload_dir_error', $upload['error']);
1343 1343
 
1344 1344
 
1345
-    sleep(0.3);// if multiple remote file this can cause the remote server to timeout so we add a slight delay
1345
+    sleep(0.3); // if multiple remote file this can cause the remote server to timeout so we add a slight delay
1346 1346
 
1347 1347
     // fetch the remote url and write it to the placeholder file
1348
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1348
+    $headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
1349 1349
 
1350 1350
     $log_message = '';
1351
-    if( is_wp_error( $headers  ) ) {
1351
+    if (is_wp_error($headers)) {
1352 1352
         echo 'file: '.$url;
1353
-        return new WP_Error('import_file_error',$headers->get_error_message());
1353
+        return new WP_Error('import_file_error', $headers->get_error_message());
1354 1354
     }
1355 1355
 
1356 1356
     $filesize = filesize($upload['file']);
@@ -1363,21 +1363,21 @@  discard block
 block discarded – undo
1363 1363
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1364 1364
     }
1365 1365
     elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1366
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1366
+        $log_message = __('Remote file is incorrect size', 'geodirectory');
1367 1367
     }
1368 1368
     elseif (0 == $filesize) {
1369 1369
         $log_message = __('Zero size file downloaded', 'geodirectory');
1370 1370
     }
1371 1371
 
1372
-    if($log_message){
1372
+    if ($log_message) {
1373 1373
         $del = unlink($upload['file']);
1374
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1375
-        return new WP_Error('import_file_error',$log_message );
1374
+        if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
1375
+        return new WP_Error('import_file_error', $log_message);
1376 1376
     }
1377 1377
 
1378 1378
     if ($dummy && $add_to_cache && is_array($upload)) {
1379 1379
         $images = get_transient('cached_dummy_images');
1380
-        if(is_array($images))
1380
+        if (is_array($images))
1381 1381
             $images[$key] = $upload;
1382 1382
         else
1383 1383
             $images = array($key => $upload);
@@ -1398,12 +1398,12 @@  discard block
 block discarded – undo
1398 1398
  */
1399 1399
 function geodir_max_upload_size()
1400 1400
 {
1401
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1401
+    $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
1402 1402
 
1403 1403
     if ($max_filesize > 0 && $max_filesize < 1) {
1404
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1404
+        $max_filesize = (int) ($max_filesize * 1024).'kb';
1405 1405
     } else {
1406
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1406
+        $max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb';
1407 1407
     }
1408 1408
 
1409 1409
     /**
@@ -1426,7 +1426,7 @@  discard block
 block discarded – undo
1426 1426
  */
1427 1427
 function geodir_dummy_folder_exists()
1428 1428
 {
1429
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1429
+    $path = geodir_plugin_path().'/geodirectory-admin/dummy/';
1430 1430
     if (!is_dir($path))
1431 1431
         return false;
1432 1432
     else
@@ -1470,35 +1470,35 @@  discard block
 block discarded – undo
1470 1470
     {
1471 1471
         global $wpdb;
1472 1472
         if ($message_type == 'expiration') {
1473
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1474
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1473
+            $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
1474
+            $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
1475 1475
         } elseif ($message_type == 'post_submited') {
1476
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1477
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1476
+            $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
1477
+            $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
1478 1478
         } elseif ($message_type == 'renew') {
1479
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1480
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1479
+            $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
1480
+            $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
1481 1481
         } elseif ($message_type == 'upgrade') {
1482
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1483
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1482
+            $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
1483
+            $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
1484 1484
         } elseif ($message_type == 'claim_approved') {
1485
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1486
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1485
+            $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
1486
+            $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
1487 1487
         } elseif ($message_type == 'claim_rejected') {
1488
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1489
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1488
+            $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
1489
+            $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
1490 1490
         } elseif ($message_type == 'claim_requested') {
1491
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1492
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1491
+            $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
1492
+            $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
1493 1493
         } elseif ($message_type == 'auto_claim') {
1494
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1495
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1494
+            $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
1495
+            $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
1496 1496
         } elseif ($message_type == 'payment_success') {
1497
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1498
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1497
+            $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
1498
+            $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
1499 1499
         } elseif ($message_type == 'payment_fail') {
1500
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1501
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1500
+            $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
1501
+            $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
1502 1502
         }
1503 1503
         $transaction_details = $custom_1;
1504 1504
         $fromEmail = get_option('site_email');
@@ -1509,11 +1509,11 @@  discard block
 block discarded – undo
1509 1509
         $productlink = get_permalink($page_id);
1510 1510
         $post_info = get_post($page_id);
1511 1511
         $post_date = date('dS F,Y', strtotime($post_info->post_date));
1512
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1512
+        $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
1513 1513
         $loginurl = geodir_login_url();
1514
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1514
+        $loginurl_link = '<a href="'.$loginurl.'">login</a>';
1515 1515
         $siteurl = home_url();
1516
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1516
+        $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>';
1517 1517
         $user_info = get_userdata($user_id);
1518 1518
         $user_email = $user_info->user_email;
1519 1519
         $display_name = geodir_get_client_name($user_id);
@@ -1527,14 +1527,14 @@  discard block
 block discarded – undo
1527 1527
         } else {
1528 1528
             $post_type = 'listing';
1529 1529
         }
1530
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1530
+        $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>';
1531 1531
         $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#]');
1532 1532
         $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);
1533 1533
         $client_message = str_replace($search_array, $replace_array, $client_message);
1534 1534
         $subject = str_replace($search_array, $replace_array, $subject);
1535
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1536
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1537
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1535
+        $headers = 'MIME-Version: 1.0'."\r\n";
1536
+        $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
1537
+        $headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>'."\r\n";
1538 1538
 
1539 1539
         $to = $fromEmail;
1540 1540
         $message = $client_message;
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1552 1552
          * @param string $custom_1 Custom data to be sent.
1553 1553
          */
1554
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1554
+        $to = apply_filters('geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1);
1555 1555
         /**
1556 1556
          * Filter the admin email subject.
1557 1557
          *
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1564 1564
          * @param string $custom_1 Custom data to be sent.
1565 1565
          */
1566
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1566
+        $subject = apply_filters('geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1);
1567 1567
         /**
1568 1568
          * Filter the admin email message.
1569 1569
          *
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1576 1576
          * @param string $custom_1 Custom data to be sent.
1577 1577
          */
1578
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1578
+        $message = apply_filters('geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1);
1579 1579
         /**
1580 1580
          * Filter the admin email headers.
1581 1581
          *
@@ -1587,23 +1587,23 @@  discard block
 block discarded – undo
1587 1587
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1588 1588
          * @param string $custom_1 Custom data to be sent.
1589 1589
          */
1590
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1590
+        $headers = apply_filters('geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1);
1591 1591
 
1592 1592
 
1593 1593
 
1594 1594
         $sent = wp_mail($to, $subject, $message, $headers);
1595
-        if( ! $sent ) {
1596
-            if ( is_array( $to ) ) {
1597
-                $to = implode( ',', $to );
1595
+        if (!$sent) {
1596
+            if (is_array($to)) {
1597
+                $to = implode(',', $to);
1598 1598
             }
1599 1599
             $log_message = sprintf(
1600
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1600
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1601 1601
                 $message_type,
1602
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1602
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1603 1603
                 $to,
1604 1604
                 $subject
1605 1605
             );
1606
-            geodir_error_log( $log_message );
1606
+            geodir_error_log($log_message);
1607 1607
         }
1608 1608
     }
1609 1609
 }
@@ -1629,18 +1629,18 @@  discard block
 block discarded – undo
1629 1629
     {
1630 1630
         $login_details = '';
1631 1631
         if ($message_type == 'send_friend') {
1632
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1633
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1632
+            $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
1633
+            $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
1634 1634
         } elseif ($message_type == 'send_enquiry') {
1635
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1636
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1635
+            $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
1636
+            $message = __(get_option('email_enquiry_content'), 'geodirectory');
1637 1637
         } elseif ($message_type == 'forgot_password') {
1638
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1639
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1638
+            $subject = __(get_option('forgot_password_subject'), 'geodirectory');
1639
+            $message = __(get_option('forgot_password_content'), 'geodirectory');
1640 1640
             $login_details = $to_message;
1641 1641
         } elseif ($message_type == 'registration') {
1642
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1643
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1642
+            $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
1643
+            $message = __(get_option('registration_success_email_content'), 'geodirectory');
1644 1644
             $login_details = $to_message;
1645 1645
         }
1646 1646
         $to_message = nl2br($to_message);
@@ -1648,11 +1648,11 @@  discard block
 block discarded – undo
1648 1648
         $sitefromEmailName = get_site_emailName();
1649 1649
         $productlink = get_permalink($post_id);
1650 1650
         $post_info = get_post($post_id);
1651
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1651
+        $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
1652 1652
         $siteurl = home_url();
1653
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1653
+        $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
1654 1654
         $loginurl = geodir_login_url();
1655
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1655
+        $loginurl_link = '<a href="'.$loginurl.'">login</a>';
1656 1656
         if ($fromEmail == '') {
1657 1657
             $fromEmail = get_option('site_email');
1658 1658
         }
@@ -1666,26 +1666,26 @@  discard block
 block discarded – undo
1666 1666
         $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1667 1667
         $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1668 1668
         $subject = str_replace($search_array, $replace_array, $subject);
1669
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1670
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1671
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1672
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1669
+        $headers = 'MIME-Version: 1.0'."\r\n";
1670
+        $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
1671
+        $headers .= "Reply-To: ".$fromEmail."\r\n";
1672
+        $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'."\r\n";
1673 1673
 
1674 1674
         $to = $toEmail;
1675 1675
 
1676 1676
         $sent = wp_mail($to, $subject, $message, $headers);
1677
-        if( ! $sent ) {
1678
-            if ( is_array( $to ) ) {
1679
-                $to = implode( ',', $to );
1677
+        if (!$sent) {
1678
+            if (is_array($to)) {
1679
+                $to = implode(',', $to);
1680 1680
             }
1681 1681
             $log_message = sprintf(
1682
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1682
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1683 1683
                 $message_type,
1684
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1684
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1685 1685
                 $to,
1686 1686
                 $subject
1687 1687
             );
1688
-            geodir_error_log( $log_message );
1688
+            geodir_error_log($log_message);
1689 1689
         }
1690 1690
 
1691 1691
         ///////// ADMIN BCC EMIALS
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
         if ($message_type == 'registration') {
1694 1694
             $message_raw = explode(__("Password:", 'geodirectory'), $message);
1695 1695
             $message_raw2 = explode("</p>", $message_raw[1], 2);
1696
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1696
+            $message = $message_raw[0].__('Password:', 'geodirectory').' **********</p>'.$message_raw2[1];
1697 1697
         }
1698 1698
         $adminEmail = get_bloginfo('admin_email');
1699 1699
         $to = $adminEmail;
@@ -1711,20 +1711,20 @@  discard block
 block discarded – undo
1711 1711
             $admin_bcc = true;
1712 1712
         }
1713 1713
 
1714
-        if($admin_bcc === true){
1714
+        if ($admin_bcc === true) {
1715 1715
             $sent = wp_mail($to, $subject, $message, $headers);
1716
-            if( ! $sent ) {
1717
-                if ( is_array( $to ) ) {
1718
-                    $to = implode( ',', $to );
1716
+            if (!$sent) {
1717
+                if (is_array($to)) {
1718
+                    $to = implode(',', $to);
1719 1719
                 }
1720 1720
                 $log_message = sprintf(
1721
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1721
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1722 1722
                     $message_type,
1723
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1723
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
1724 1724
                     $to,
1725 1725
                     $subject
1726 1726
                 );
1727
-                geodir_error_log( $log_message );
1727
+                geodir_error_log($log_message);
1728 1728
             }
1729 1729
         }
1730 1730
 
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
 function geodir_custom_posts_body_class($classes) {
1773 1773
     global $wpdb, $wp;
1774 1774
     $post_types = geodir_get_posttypes('object');
1775
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1775
+    if (!empty($post_types) && count((array) $post_types) > 1) {
1776 1776
         $classes[] = 'geodir_custom_posts';
1777 1777
     }
1778 1778
 
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
     $geodir_option = get_option($geodir_option_name);
1833 1833
 
1834 1834
     if (!empty($geodir_option)) {
1835
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1835
+        add_option($geodir_option_name.'_'.$version_date, $geodir_option);
1836 1836
     }
1837 1837
 }
1838 1838
 
@@ -1938,36 +1938,36 @@  discard block
 block discarded – undo
1938 1938
 
1939 1939
     $query_args = $gd_query_args_widgets;
1940 1940
     if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1941
-        return $wpdb->posts . ".post_date DESC, ";
1941
+        return $wpdb->posts.".post_date DESC, ";
1942 1942
     }
1943 1943
 
1944 1944
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1945
-    $table = $plugin_prefix . $post_type . '_detail';
1945
+    $table = $plugin_prefix.$post_type.'_detail';
1946 1946
 
1947 1947
     $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1948 1948
 
1949 1949
     switch ($sort_by) {
1950 1950
         case 'latest':
1951 1951
         case 'newest':
1952
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1952
+            $orderby = $wpdb->posts.".post_date DESC, ";
1953 1953
             break;
1954 1954
         case 'featured':
1955
-            $orderby = $table . ".is_featured ASC, ";
1955
+            $orderby = $table.".is_featured ASC, ";
1956 1956
             break;
1957 1957
         case 'az':
1958
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1958
+            $orderby = $wpdb->posts.".post_title ASC, ";
1959 1959
             break;
1960 1960
         case 'high_review':
1961
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1961
+            $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, ";
1962 1962
             break;
1963 1963
         case 'high_rating':
1964
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1964
+            $orderby = "( ".$table.".overall_rating  ) DESC, ";
1965 1965
             break;
1966 1966
         case 'random':
1967 1967
             $orderby = "RAND(), ";
1968 1968
             break;
1969 1969
         default:
1970
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1970
+            $orderby = $wpdb->posts.".post_title ASC, ";
1971 1971
             break;
1972 1972
     }
1973 1973
 
@@ -1994,9 +1994,9 @@  discard block
 block discarded – undo
1994 1994
     $gd_query_args_widgets = $query_args;
1995 1995
 
1996 1996
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1997
-    $table = $plugin_prefix . $post_type . '_detail';
1997
+    $table = $plugin_prefix.$post_type.'_detail';
1998 1998
 
1999
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1999
+    $fields = $wpdb->posts.".*, ".$table.".*";
2000 2000
     /**
2001 2001
      * Filter widget listing fields string part that is being used for query.
2002 2002
      *
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
      */
2008 2008
     $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
2009 2009
 
2010
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
2010
+    $join = "INNER JOIN ".$table." ON (".$table.".post_id = ".$wpdb->posts.".ID)";
2011 2011
 
2012 2012
     ########### WPML ###########
2013 2013
 
@@ -2015,7 +2015,7 @@  discard block
 block discarded – undo
2015 2015
         global $sitepress;
2016 2016
         $lang_code = ICL_LANGUAGE_CODE;
2017 2017
         if ($lang_code) {
2018
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2018
+            $join .= " JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID";
2019 2019
         }
2020 2020
     }
2021 2021
 
@@ -2030,9 +2030,9 @@  discard block
 block discarded – undo
2030 2030
      */
2031 2031
     $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2032 2032
 
2033
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2033
+    $post_status = is_super_admin() ? " OR ".$wpdb->posts.".post_status = 'private'" : '';
2034 2034
 
2035
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2035
+    $where = " AND ( ".$wpdb->posts.".post_status = 'publish' ".$post_status." ) AND ".$wpdb->posts.".post_type = '".$post_type."'";
2036 2036
 
2037 2037
     ########### WPML ###########
2038 2038
     if (function_exists('icl_object_id')) {
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
      * @param string $post_type Post type.
2050 2050
      */
2051 2051
     $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2052
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2052
+    $where = $where != '' ? " WHERE 1=1 ".$where : '';
2053 2053
 
2054 2054
     $groupby = " GROUP BY $wpdb->posts.ID ";
2055 2055
     /**
@@ -2062,10 +2062,10 @@  discard block
 block discarded – undo
2062 2062
     $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2063 2063
 
2064 2064
     if ($count_only) {
2065
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2066
-			" . $join . "
2065
+        $sql = "SELECT COUNT(".$wpdb->posts.".ID) AS total FROM ".$wpdb->posts."
2066
+			" . $join."
2067 2067
 			" . $where;
2068
-        $rows = (int)$wpdb->get_var($sql);
2068
+        $rows = (int) $wpdb->get_var($sql);
2069 2069
     } else {
2070 2070
         $orderby = geodir_widget_listings_get_order($query_args);
2071 2071
         /**
@@ -2077,8 +2077,8 @@  discard block
 block discarded – undo
2077 2077
          * @param string $post_type Post type.
2078 2078
          */
2079 2079
         $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2080
-        $orderby .= $wpdb->posts . ".post_title ASC";
2081
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2080
+        $orderby .= $wpdb->posts.".post_title ASC";
2081
+        $orderby = $orderby != '' ? " ORDER BY ".$orderby : '';
2082 2082
 
2083 2083
         $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2084 2084
         /**
@@ -2091,16 +2091,16 @@  discard block
 block discarded – undo
2091 2091
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2092 2092
 
2093 2093
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2094
-        if ( !$page )
2094
+        if (!$page)
2095 2095
             $page = 1;
2096 2096
 
2097
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2097
+        $limit = (int) $limit > 0 ? " LIMIT ".absint(($page - 1) * (int) $limit).", ".(int) $limit : "";
2098 2098
 
2099
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2100
-			" . $join . "
2101
-			" . $where . "
2102
-			" . $groupby . "
2103
-			" . $orderby . "
2099
+        $sql = "SELECT SQL_CALC_FOUND_ROWS ".$fields." FROM ".$wpdb->posts."
2100
+			" . $join."
2101
+			" . $where."
2102
+			" . $groupby."
2103
+			" . $orderby."
2104 2104
 			" . $limit;
2105 2105
         $rows = $wpdb->get_results($sql);
2106 2106
     }
@@ -2153,10 +2153,10 @@  discard block
 block discarded – undo
2153 2153
     }
2154 2154
 
2155 2155
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2156
-    $table = $plugin_prefix . $post_type . '_detail';
2156
+    $table = $plugin_prefix.$post_type.'_detail';
2157 2157
 
2158 2158
     if (!empty($query_args['with_pics_only'])) {
2159
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2159
+        $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
2160 2160
     }
2161 2161
 
2162 2162
     if (!empty($query_args['tax_query'])) {
@@ -2188,7 +2188,7 @@  discard block
 block discarded – undo
2188 2188
         return $where;
2189 2189
     }
2190 2190
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2191
-    $table = $plugin_prefix . $post_type . '_detail';
2191
+    $table = $plugin_prefix.$post_type.'_detail';
2192 2192
 
2193 2193
     if (!empty($query_args)) {
2194 2194
         if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
@@ -2196,27 +2196,27 @@  discard block
 block discarded – undo
2196 2196
         }
2197 2197
 
2198 2198
         if (!empty($query_args['post_author'])) {
2199
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2199
+            $where .= " AND ".$wpdb->posts.".post_author = ".(int) $query_args['post_author'];
2200 2200
         }
2201 2201
         
2202 2202
         if (!empty($query_args['show_featured_only'])) {
2203
-            $where .= " AND " . $table . ".is_featured = '1'";
2203
+            $where .= " AND ".$table.".is_featured = '1'";
2204 2204
         }
2205 2205
 
2206 2206
         if (!empty($query_args['show_special_only'])) {
2207
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2207
+            $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
2208 2208
         }
2209 2209
 
2210 2210
         if (!empty($query_args['with_pics_only'])) {
2211
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2211
+            $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL ";
2212 2212
         }
2213 2213
 
2214 2214
         if (!empty($query_args['featured_image_only'])) {
2215
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2215
+            $where .= " AND ".$table.".featured_image IS NOT NULL AND ".$table.".featured_image!='' ";
2216 2216
         }
2217 2217
 
2218 2218
         if (!empty($query_args['with_videos_only'])) {
2219
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2219
+            $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
2220 2220
         }
2221 2221
 
2222 2222
         if (!empty($query_args['tax_query'])) {
@@ -2273,7 +2273,7 @@  discard block
 block discarded – undo
2273 2273
     }
2274 2274
 
2275 2275
     if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2276
-        $limit = (int)$query_args['posts_per_page'];
2276
+        $limit = (int) $query_args['posts_per_page'];
2277 2277
     }
2278 2278
 
2279 2279
     return $limit;
@@ -2416,9 +2416,9 @@  discard block
 block discarded – undo
2416 2416
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2417 2417
     }
2418 2418
     $home_url = str_replace("www.", "", $home_url);
2419
-    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')) ) {
2419
+    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'))) {
2420 2420
         return true;
2421
-    }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')){
2421
+    }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')) {
2422 2422
         return true;
2423 2423
     } else {
2424 2424
         return false;
@@ -2501,19 +2501,19 @@  discard block
 block discarded – undo
2501 2501
 
2502 2502
     $gd_post_type = geodir_get_current_posttype();
2503 2503
 
2504
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2505
-    if(!empty($gd_post_type)){
2504
+    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
2505
+    if (!empty($gd_post_type)) {
2506 2506
         $default_post_type = $gd_post_type;
2507
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2507
+    }elseif (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type'])) {
2508 2508
         $default_post_type = $instance['default_post_type'];
2509
-    }else{
2509
+    } else {
2510 2510
         $all_gd_post_type = geodir_get_posttypes();
2511 2511
         $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2512 2512
     }
2513 2513
 
2514 2514
     $taxonomy = array();
2515 2515
     if (!empty($gd_post_type)) {
2516
-        $taxonomy[] = $gd_post_type . "category";
2516
+        $taxonomy[] = $gd_post_type."category";
2517 2517
     } else {
2518 2518
         $taxonomy = geodir_get_taxonomies($gd_post_type);
2519 2519
     }
@@ -2533,7 +2533,7 @@  discard block
 block discarded – undo
2533 2533
             $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2534 2534
         }
2535 2535
 
2536
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2536
+        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type.'category']) ? $default_post_type.'category' : '';
2537 2537
 
2538 2538
         $tax_change_output = '';
2539 2539
         if (count($b_terms) > 1) {
@@ -2541,20 +2541,20 @@  discard block
 block discarded – undo
2541 2541
             foreach ($b_terms as $key => $val) {
2542 2542
                 $ptype = get_post_type_object(str_replace("category", "", $key));
2543 2543
                 $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2544
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2544
+                $tax_change_output .= "<option value='$key' ".selected($key, $default_taxonomy, false).">".sprintf(__('%s Categories', 'geodirectory'), $cpt_name)."</option>";
2545 2545
             }
2546 2546
             $tax_change_output .= "</select>";
2547 2547
         }
2548 2548
 
2549 2549
         if (!empty($b_terms)) {
2550
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2551
-            global $cat_count;//make global so we can change via function
2550
+            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array
2551
+            global $cat_count; //make global so we can change via function
2552 2552
             $cat_count = 0;
2553 2553
             ?>
2554 2554
             <div class="geodir-category-list-in clearfix">
2555 2555
                 <div class="geodir-cat-list clearfix">
2556 2556
                     <?php
2557
-                    echo $before_title . __($title) . $after_title;
2557
+                    echo $before_title.__($title).$after_title;
2558 2558
 
2559 2559
                     echo $tax_change_output;
2560 2560
 
@@ -2571,8 +2571,8 @@  discard block
 block discarded – undo
2571 2571
                     $hide = 'style="display:none;"';
2572 2572
                 }
2573 2573
                 echo "<div class='geodir-cat-list-more' $hide >";
2574
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2575
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2574
+                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">'.__('More Categories', 'geodirectory').'</a>';
2575
+                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">'.__('Less Categories', 'geodirectory').'</a>';
2576 2576
                 echo "</div>";
2577 2577
                 /* add scripts */
2578 2578
                 add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
         $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2613 2613
         $total_post = $cat->count;
2614 2614
 
2615
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2615
+        $term_link = get_term_link($cat, $cat->taxonomy);
2616 2616
         /**
2617 2617
          * Filer the category term link.
2618 2618
          *
@@ -2621,10 +2621,10 @@  discard block
 block discarded – undo
2621 2621
          * @param int    $cat->term_id The term id.
2622 2622
          * @param string $post_type Wordpress post type.
2623 2623
          */
2624
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2624
+        $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
2625 2625
 
2626
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2627
-        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> ';
2626
+        echo '<li class="'.$class_row.'"><a href="'.$term_link.'">';
2627
+        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> ';
2628 2628
         echo '</a></li>';
2629 2629
     }
2630 2630
 }
@@ -2755,29 +2755,29 @@  discard block
 block discarded – undo
2755 2755
                 itemWidth: 75,
2756 2756
                 itemMargin: 5,
2757 2757
                 asNavFor: '#geodir_widget_slider',
2758
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2758
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2759 2759
             });
2760 2760
 
2761 2761
             jQuery('#geodir_widget_slider').flexslider({
2762
-                animation: "<?php echo $animation;?>",
2762
+                animation: "<?php echo $animation; ?>",
2763 2763
                 selector: ".geodir-slides > li",
2764 2764
                 namespace: "geodir-",
2765 2765
                 controlNav: true,
2766
-                animationLoop: <?php echo $animationLoop;?>,
2767
-                slideshow: <?php echo $slideshow;?>,
2768
-                slideshowSpeed: <?php echo $slideshowSpeed;?>,
2769
-                animationSpeed: <?php echo $animationSpeed;?>,
2770
-                directionNav: <?php echo $directionNav;?>,
2771
-                maxItems: <?php echo $max_show;?>,
2766
+                animationLoop: <?php echo $animationLoop; ?>,
2767
+                slideshow: <?php echo $slideshow; ?>,
2768
+                slideshowSpeed: <?php echo $slideshowSpeed; ?>,
2769
+                animationSpeed: <?php echo $animationSpeed; ?>,
2770
+                directionNav: <?php echo $directionNav; ?>,
2771
+                maxItems: <?php echo $max_show; ?>,
2772 2772
                 move: 1,
2773
-                <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
2773
+                <?php if ($slide_width) { echo "itemWidth: ".$slide_width.","; }?>
2774 2774
                 sync: "#geodir_widget_carousel",
2775 2775
                 start: function (slider) {
2776 2776
                     jQuery('.geodir-listing-flex-loader').hide();
2777 2777
                     jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
2778 2778
                     jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
2779 2779
                 },
2780
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2780
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2781 2781
             });
2782 2782
         });
2783 2783
     </script>
@@ -2813,12 +2813,12 @@  discard block
 block discarded – undo
2813 2813
     $widget_listings = geodir_get_widget_listings($query_args);
2814 2814
     if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2815 2815
         if ($title) {
2816
-            echo $before_title . $title . $after_title;
2816
+            echo $before_title.$title.$after_title;
2817 2817
         }
2818 2818
 
2819 2819
         global $post;
2820 2820
 
2821
-        $current_post = $post;// keep current post info
2821
+        $current_post = $post; // keep current post info
2822 2822
 
2823 2823
         $widget_main_slides = '';
2824 2824
         $nav_slides = '';
@@ -2836,11 +2836,11 @@  discard block
 block discarded – undo
2836 2836
                     $widget_spacer_height = ((200 - $widget_image->height) / 2);
2837 2837
                 }
2838 2838
 
2839
-                $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" />';
2839
+                $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" />';
2840 2840
 
2841 2841
                 $title = '';
2842 2842
                 if ($show_title) {
2843
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2843
+                    $title_html = '<div class="geodir-slider-title"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></div>';
2844 2844
                     $post_id = $post->ID;
2845 2845
                     $post_permalink = get_permalink($post->ID);
2846 2846
                     $post_title = get_the_title($post->ID);
@@ -2853,11 +2853,11 @@  discard block
 block discarded – undo
2853 2853
                      * @param string $post_permalink The post permalink url.
2854 2854
                      * @param string $post_title The post title text.
2855 2855
                      */
2856
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2856
+                    $title = apply_filters('geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title);
2857 2857
                 }
2858 2858
 
2859
-                $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>';
2860
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2859
+                $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>';
2860
+                $nav_slides .= '<li><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:48px;margin:0 auto;" /></li>';
2861 2861
                 $widget_slides++;
2862 2862
             }
2863 2863
         }
@@ -2901,7 +2901,7 @@  discard block
 block discarded – undo
2901 2901
     $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2902 2902
 
2903 2903
     echo $before_widget;
2904
-    echo $before_title . $title . $after_title;
2904
+    echo $before_title.$title.$after_title;
2905 2905
 
2906 2906
     if (is_user_logged_in()) {
2907 2907
         global $current_user;
@@ -2943,7 +2943,7 @@  discard block
 block discarded – undo
2943 2943
                          */
2944 2944
                         $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2945 2945
 
2946
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2946
+                        $addlisting_links .= '<option '.$selected.' value="'.$add_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
2947 2947
 
2948 2948
                     }
2949 2949
                 }
@@ -2989,7 +2989,7 @@  discard block
 block discarded – undo
2989 2989
                      */
2990 2990
                     $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2991 2991
 
2992
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2992
+                    $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
2993 2993
                 }
2994 2994
             }
2995 2995
 
@@ -3034,7 +3034,7 @@  discard block
 block discarded – undo
3034 3034
                      */
3035 3035
                     $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3036 3036
 
3037
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3037
+                    $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
3038 3038
                 }
3039 3039
             }
3040 3040
 
@@ -3217,7 +3217,7 @@  discard block
 block discarded – undo
3217 3217
     }
3218 3218
 
3219 3219
     if (empty($title) || $title == 'All') {
3220
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3220
+        $title .= ' '.__(get_post_type_plural_label($post_type), 'geodirectory');
3221 3221
     }
3222 3222
 
3223 3223
     $location_url = array();
@@ -3271,7 +3271,7 @@  discard block
 block discarded – undo
3271 3271
             $geodir_add_location_url = '1';
3272 3272
         }
3273 3273
 
3274
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3274
+        $viewall_url = get_term_link((int) $category[0], $post_type.'category');
3275 3275
 
3276 3276
         $geodir_add_location_url = NULL;
3277 3277
     }
@@ -3279,7 +3279,7 @@  discard block
 block discarded – undo
3279 3279
         $gd_session->set('gd_multi_location', 1);
3280 3280
     }
3281 3281
 
3282
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3282
+    if (is_wp_error($viewall_url)) {$viewall_url = ''; }
3283 3283
 
3284 3284
     $query_args = array(
3285 3285
         'posts_per_page' => $post_number,
@@ -3345,7 +3345,7 @@  discard block
 block discarded – undo
3345 3345
              */
3346 3346
             do_action('geodir_before_view_all_link_in_widget'); ?>
3347 3347
             <div class="geodir_list_heading clearfix">
3348
-                <?php echo $before_title . $title . $after_title; ?>
3348
+                <?php echo $before_title.$title.$after_title; ?>
3349 3349
                 <a href="<?php echo $viewall_url; ?>"
3350 3350
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3351 3351
             </div>
@@ -3431,9 +3431,9 @@  discard block
 block discarded – undo
3431 3431
 {
3432 3432
     global $wpdb, $plugin_prefix;
3433 3433
 
3434
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3434
+    $detail_table = $plugin_prefix.$post_type.'_detail';
3435 3435
 
3436
-    $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 . ")";
3436
+    $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.")";
3437 3437
 
3438 3438
     /**
3439 3439
      * Filter count review sql query.
@@ -3472,7 +3472,7 @@  discard block
 block discarded – undo
3472 3472
      * @param bool $force_update Force update option value?. Default.false.
3473 3473
      * @param int $post_ID The post id to update if any.
3474 3474
      */
3475
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3475
+    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update, $post_ID);
3476 3476
     if (!empty($option_data)) {
3477 3477
         return $option_data;
3478 3478
     }
@@ -3480,11 +3480,11 @@  discard block
 block discarded – undo
3480 3480
     $option_data = get_option('geodir_global_review_count');
3481 3481
 
3482 3482
     if (!$option_data || $force_update) {
3483
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3483
+        if ((int) $post_ID > 0) { // Update reviews count for specific post categories only.
3484 3484
             global $gd_session;
3485
-            $term_array = (array)$option_data;
3485
+            $term_array = (array) $option_data;
3486 3486
             $post_type = get_post_type($post_ID);
3487
-            $taxonomy = $post_type . 'category';
3487
+            $taxonomy = $post_type.'category';
3488 3488
             $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3489 3489
 
3490 3490
             if (!empty($terms) && !is_wp_error($terms)) {
@@ -3499,9 +3499,9 @@  discard block
 block discarded – undo
3499 3499
             
3500 3500
             $terms = array();
3501 3501
             if (isset($_POST['post_category'][$taxonomy])) {
3502
-                $terms = (array)$_POST['post_category'][$taxonomy];
3502
+                $terms = (array) $_POST['post_category'][$taxonomy];
3503 3503
             } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3504
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3504
+                $terms = (array) $session_listing['post_category'][$taxonomy];
3505 3505
             }
3506 3506
             
3507 3507
             if (!empty($terms)) {
@@ -3589,7 +3589,7 @@  discard block
 block discarded – undo
3589 3589
     return true;
3590 3590
 }
3591 3591
 
3592
-function geodir_term_review_count_force_update_single_post($post_id){
3592
+function geodir_term_review_count_force_update_single_post($post_id) {
3593 3593
     geodir_count_reviews_by_terms(true, $post_id); 
3594 3594
 }
3595 3595
 
@@ -3726,17 +3726,17 @@  discard block
 block discarded – undo
3726 3726
      */
3727 3727
     $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3728 3728
 
3729
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3730
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3729
+    load_textdomain('geodirectory', WP_LANG_DIR.'/'.'geodirectory'.'/'.'geodirectory'.'-'.$locale.'.mo');
3730
+    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))).'/geodirectory-languages');
3731 3731
 
3732 3732
     /**
3733 3733
      * Define language constants.
3734 3734
      *
3735 3735
      * @since 1.0.0
3736 3736
      */
3737
-    require_once(geodir_plugin_path() . '/language.php');
3737
+    require_once(geodir_plugin_path().'/language.php');
3738 3738
 
3739
-    $language_file = geodir_plugin_path() . '/db-language.php';
3739
+    $language_file = geodir_plugin_path().'/db-language.php';
3740 3740
 
3741 3741
     // Load language string file if not created yet
3742 3742
     if (!file_exists($language_file)) {
@@ -3751,8 +3751,8 @@  discard block
 block discarded – undo
3751 3751
          */
3752 3752
         try {
3753 3753
             require_once($language_file);
3754
-        } catch(Exception $e) {
3755
-            error_log('Language Error: ' . $e->getMessage());
3754
+        } catch (Exception $e) {
3755
+            error_log('Language Error: '.$e->getMessage());
3756 3756
         }
3757 3757
     }
3758 3758
 }
@@ -3769,18 +3769,18 @@  discard block
 block discarded – undo
3769 3769
  */
3770 3770
 function geodirectory_load_db_language() {
3771 3771
     global $wp_filesystem;
3772
-    if( empty( $wp_filesystem ) ) {
3773
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3772
+    if (empty($wp_filesystem)) {
3773
+        require_once(ABSPATH.'/wp-admin/includes/file.php');
3774 3774
         WP_Filesystem();
3775 3775
         global $wp_filesystem;
3776 3776
     }
3777 3777
 
3778
-    $language_file = geodir_plugin_path() . '/db-language.php';
3778
+    $language_file = geodir_plugin_path().'/db-language.php';
3779 3779
 
3780
-    if(is_file($language_file) && !is_writable($language_file))
3780
+    if (is_file($language_file) && !is_writable($language_file))
3781 3781
         return false; // Not possible to create.
3782 3782
 
3783
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3783
+    if (!is_file($language_file) && !is_writable(dirname($language_file)))
3784 3784
         return false; // Not possible to create.
3785 3785
 
3786 3786
     $contents_strings = array();
@@ -3814,17 +3814,17 @@  discard block
 block discarded – undo
3814 3814
     $contents = implode(PHP_EOL, $contents_head);
3815 3815
 
3816 3816
     if (!empty($contents_strings)) {
3817
-        foreach ( $contents_strings as $string ) {
3817
+        foreach ($contents_strings as $string) {
3818 3818
             if (is_scalar($string) && $string != '') {
3819 3819
                 $string = str_replace("'", "\'", $string);
3820
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3820
+                $contents .= PHP_EOL."__('".$string."', 'geodirectory');";
3821 3821
             }
3822 3822
         }
3823 3823
     }
3824 3824
 
3825 3825
     $contents .= implode(PHP_EOL, $contents_foot);
3826 3826
 
3827
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3827
+    if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE))
3828 3828
         return false; // Failure; could not write file.
3829 3829
 
3830 3830
     return true;
@@ -3846,11 +3846,11 @@  discard block
 block discarded – undo
3846 3846
     global $wpdb;
3847 3847
 
3848 3848
     // Custom fields table
3849
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3849
+    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM ".GEODIR_CUSTOM_FIELDS_TABLE;
3850 3850
     $rows = $wpdb->get_results($sql);
3851 3851
 
3852 3852
     if (!empty($rows)) {
3853
-        foreach($rows as $row) {
3853
+        foreach ($rows as $row) {
3854 3854
             if (!empty($row->admin_title))
3855 3855
                 $translation_texts[] = stripslashes_deep($row->admin_title);
3856 3856
 			
@@ -3884,11 +3884,11 @@  discard block
 block discarded – undo
3884 3884
     }
3885 3885
 	
3886 3886
     // Custom sorting fields table
3887
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3887
+    $sql = "SELECT site_title, asc_title, desc_title FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3888 3888
     $rows = $wpdb->get_results($sql);
3889 3889
 
3890 3890
     if (!empty($rows)) {
3891
-        foreach($rows as $row) {
3891
+        foreach ($rows as $row) {
3892 3892
             if (!empty($row->site_title))
3893 3893
                 $translation_texts[] = stripslashes_deep($row->site_title);
3894 3894
 
@@ -3902,11 +3902,11 @@  discard block
 block discarded – undo
3902 3902
 	
3903 3903
 	// Advance search filter fields table
3904 3904
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
3905
-		$sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE;
3905
+		$sql = "SELECT field_site_name, front_search_title, field_desc FROM ".GEODIR_ADVANCE_SEARCH_TABLE;
3906 3906
 		$rows = $wpdb->get_results($sql);
3907 3907
 
3908 3908
 		if (!empty($rows)) {
3909
-			foreach($rows as $row) {
3909
+			foreach ($rows as $row) {
3910 3910
 				if (!empty($row->field_site_name))
3911 3911
 					$translation_texts[] = stripslashes_deep($row->field_site_name);
3912 3912
 
@@ -3941,7 +3941,7 @@  discard block
 block discarded – undo
3941 3941
      *
3942 3942
      * @param array $geodir_allowed_mime_types and file extensions.
3943 3943
      */
3944
-    return apply_filters( 'geodir_allowed_mime_types', array(
3944
+    return apply_filters('geodir_allowed_mime_types', array(
3945 3945
             'Image' => array( // Image formats.
3946 3946
                 'jpg' => 'image/jpeg',
3947 3947
                 'jpe' => 'image/jpeg',
@@ -4030,13 +4030,13 @@  discard block
 block discarded – undo
4030 4030
 
4031 4031
 
4032 4032
 
4033
-add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
4033
+add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
4034 4034
 /*
4035 4035
  * Add location variables to wpseo replacements.
4036 4036
  *
4037 4037
  * @since 1.5.4
4038 4038
  */
4039
-function geodir_wpseo_replacements($vars){
4039
+function geodir_wpseo_replacements($vars) {
4040 4040
 
4041 4041
     global $wp;
4042 4042
     $title = '';
@@ -4051,12 +4051,12 @@  discard block
 block discarded – undo
4051 4051
      * @param array $location_array The array of location variables.
4052 4052
      * @param array $vars The page title variables.
4053 4053
      */
4054
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4054
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
4055 4055
     $location_titles = array();
4056
-    if(get_query_var( 'gd_country_full' )){
4057
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4058
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4059
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4056
+    if (get_query_var('gd_country_full')) {
4057
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4058
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4059
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4060 4060
     }
4061 4061
     $location_single = '';
4062 4062
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4128,23 +4128,23 @@  discard block
 block discarded – undo
4128 4128
     }
4129 4129
 
4130 4130
 
4131
-    if(!empty($location_titles)) {
4131
+    if (!empty($location_titles)) {
4132 4132
         $vars['%%location%%'] = implode(", ", $location_titles);
4133 4133
     }
4134 4134
 
4135 4135
 
4136
-    if(!empty($location_titles)) {
4137
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4136
+    if (!empty($location_titles)) {
4137
+        $vars['%%in_location%%'] = __('in ', 'geodirectory').implode(", ", $location_titles);
4138 4138
     }
4139 4139
 
4140 4140
 
4141 4141
 
4142
-    if($location_single) {
4143
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4142
+    if ($location_single) {
4143
+        $vars['%%in_location_single%%'] = __('in', 'geodirectory').' '.$location_single;
4144 4144
     }
4145 4145
 
4146 4146
 
4147
-    if($location_single) {
4147
+    if ($location_single) {
4148 4148
         $vars['%%location_single%%'] = $location_single;
4149 4149
     }
4150 4150
 
@@ -4156,13 +4156,13 @@  discard block
 block discarded – undo
4156 4156
      * @param string $vars The title with variables.
4157 4157
      * @param array $location_array The array of location variables.
4158 4158
      */
4159
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4159
+    return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
4160 4160
 }
4161 4161
 
4162 4162
 
4163
-add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
4164
-add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
4165
-add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
4163
+add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
4164
+add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
4165
+add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
4166 4166
 
4167 4167
 /**
4168 4168
  * Filter the title variables.
@@ -4221,19 +4221,19 @@  discard block
 block discarded – undo
4221 4221
         $sep = apply_filters('geodir_page_title_separator', '|');
4222 4222
     }
4223 4223
 
4224
-    if (strpos($title,'%%title%%') !== false) {
4224
+    if (strpos($title, '%%title%%') !== false) {
4225 4225
         $title = str_replace("%%title%%", $post->post_title, $title);
4226 4226
     }
4227 4227
 
4228
-    if (strpos($title,'%%sitename%%') !== false) {
4228
+    if (strpos($title, '%%sitename%%') !== false) {
4229 4229
         $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4230 4230
     }
4231 4231
 
4232
-    if (strpos($title,'%%sitedesc%%') !== false) {
4232
+    if (strpos($title, '%%sitedesc%%') !== false) {
4233 4233
         $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4234 4234
     }
4235 4235
 
4236
-    if (strpos($title,'%%excerpt%%') !== false) {
4236
+    if (strpos($title, '%%excerpt%%') !== false) {
4237 4237
         $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4238 4238
     }
4239 4239
     
@@ -4241,8 +4241,8 @@  discard block
 block discarded – undo
4241 4241
         $post_type = sanitize_text_field($_REQUEST['stype']);
4242 4242
     } else if ($gd_page == 'add-listing') {
4243 4243
         $post_type = sanitize_text_field($_REQUEST['listing_type']);
4244
-        $post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int)$_REQUEST['pid']) : $post_type;
4245
-    } else if (isset($post->post_type) && $post->post_type && in_array($post->post_type , geodir_get_posttypes())) {
4244
+        $post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int) $_REQUEST['pid']) : $post_type;
4245
+    } else if (isset($post->post_type) && $post->post_type && in_array($post->post_type, geodir_get_posttypes())) {
4246 4246
         $post_type = $post->post_type;
4247 4247
     } else {
4248 4248
         $post_type = get_query_var('post_type');
@@ -4269,9 +4269,9 @@  discard block
 block discarded – undo
4269 4269
     if (strpos($title, '%%category%%') !== false) {
4270 4270
         $cat_name = '';
4271 4271
 
4272
-        if ($gd_page=='detail') {
4272
+        if ($gd_page == 'detail') {
4273 4273
             if ($post->default_category) {
4274
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4274
+                $cat = get_term($post->default_category, $post->post_type.'category');
4275 4275
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4276 4276
             }
4277 4277
         } else if ($gd_page == 'listing') {
@@ -4286,12 +4286,12 @@  discard block
 block discarded – undo
4286 4286
     if (strpos($title, '%%tag%%') !== false) {
4287 4287
         $cat_name = '';
4288 4288
 
4289
-        if ($gd_page=='detail') {
4289
+        if ($gd_page == 'detail') {
4290 4290
             if ($post->default_category) {
4291
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4291
+                $cat = get_term($post->default_category, $post->post_type.'category');
4292 4292
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4293 4293
             }
4294
-        } else if($gd_page == 'listing') {
4294
+        } else if ($gd_page == 'listing') {
4295 4295
             $queried_object = get_queried_object();
4296 4296
             if (isset($queried_object->name)) {
4297 4297
                 $cat_name = $queried_object->name;
@@ -4305,7 +4305,7 @@  discard block
 block discarded – undo
4305 4305
         $title = str_replace("%%id%%", $ID, $title);
4306 4306
     }
4307 4307
 
4308
-    if (strpos($title,'%%sep%%') !== false) {
4308
+    if (strpos($title, '%%sep%%') !== false) {
4309 4309
         $title = str_replace("%%sep%%", $sep, $title);
4310 4310
     }
4311 4311
 
@@ -4322,12 +4322,12 @@  discard block
 block discarded – undo
4322 4322
      * @param string $gd_page The page being filtered.
4323 4323
      * @param string $sep The separator, default: `|`.
4324 4324
      */
4325
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4325
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
4326 4326
     $location_titles = array();
4327
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4328
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4329
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4330
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4327
+    if ($gd_page == 'location' && get_query_var('gd_country_full')) {
4328
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4329
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4330
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4331 4331
     }
4332 4332
     $location_single = '';
4333 4333
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4399,51 +4399,51 @@  discard block
 block discarded – undo
4399 4399
     }
4400 4400
 
4401 4401
 
4402
-    if(strpos($title,'%%location%%') !== false){
4402
+    if (strpos($title, '%%location%%') !== false) {
4403 4403
         $location = '';
4404
-        if($location_titles) {
4404
+        if ($location_titles) {
4405 4405
             $location = implode(", ", $location_titles);
4406 4406
         }
4407
-        $title = str_replace("%%location%%",$location,$title);
4407
+        $title = str_replace("%%location%%", $location, $title);
4408 4408
     }
4409 4409
 
4410
-    if(strpos($title,'%%in_location%%') !== false){
4410
+    if (strpos($title, '%%in_location%%') !== false) {
4411 4411
         $location = '';
4412
-        if($location_titles) {
4413
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4412
+        if ($location_titles) {
4413
+            $location = __('in ', 'geodirectory').implode(", ", $location_titles);
4414 4414
         }
4415
-        $title = str_replace("%%in_location%%",$location,$title);
4415
+        $title = str_replace("%%in_location%%", $location, $title);
4416 4416
     }
4417 4417
 
4418
-    if(strpos($title,'%%in_location_single%%') !== false){
4419
-        if($location_single) {
4420
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4418
+    if (strpos($title, '%%in_location_single%%') !== false) {
4419
+        if ($location_single) {
4420
+            $location_single = __('in', 'geodirectory').' '.$location_single;
4421 4421
         }
4422
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4422
+        $title = str_replace("%%in_location_single%%", $location_single, $title);
4423 4423
     }
4424 4424
 
4425
-    if(strpos($title,'%%location_single%%') !== false){
4426
-        $title = str_replace("%%location_single%%",$location_single,$title);
4425
+    if (strpos($title, '%%location_single%%') !== false) {
4426
+        $title = str_replace("%%location_single%%", $location_single, $title);
4427 4427
     }
4428 4428
 
4429 4429
 
4430
-    if(strpos($title,'%%search_term%%') !== false){
4430
+    if (strpos($title, '%%search_term%%') !== false) {
4431 4431
         $search_term = '';
4432
-        if(isset($_REQUEST['s'])){
4432
+        if (isset($_REQUEST['s'])) {
4433 4433
             $search_term = esc_attr($_REQUEST['s']);
4434 4434
         }
4435
-        $title = str_replace("%%search_term%%",$search_term,$title);
4435
+        $title = str_replace("%%search_term%%", $search_term, $title);
4436 4436
     }
4437 4437
 
4438
-    if(strpos($title,'%%search_near%%') !== false){
4438
+    if (strpos($title, '%%search_near%%') !== false) {
4439 4439
         $search_term = '';
4440
-        if(isset($_REQUEST['snear'])){
4440
+        if (isset($_REQUEST['snear'])) {
4441 4441
             $search_term = esc_attr($_REQUEST['snear']);
4442 4442
         }
4443
-        $title = str_replace("%%search_near%%",$search_term,$title);
4443
+        $title = str_replace("%%search_near%%", $search_term, $title);
4444 4444
     }
4445 4445
 
4446
-    if(strpos($title,'%%name%%') !== false){
4446
+    if (strpos($title, '%%name%%') !== false) {
4447 4447
         $author_name = get_the_author();
4448 4448
         if (!$author_name || $author_name === '') {
4449 4449
             $queried_object = get_queried_object();
@@ -4468,9 +4468,9 @@  discard block
 block discarded – undo
4468 4468
         $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4469 4469
     }
4470 4470
 
4471
-    $title = wptexturize( $title );
4472
-    $title = convert_chars( $title );
4473
-    $title = esc_html( $title );
4471
+    $title = wptexturize($title);
4472
+    $title = convert_chars($title);
4473
+    $title = esc_html($title);
4474 4474
 
4475 4475
     /**
4476 4476
      * Filter the title variables after standard ones have been filtered.
@@ -4483,7 +4483,7 @@  discard block
 block discarded – undo
4483 4483
      * @param string $sep The separator, default: `|`.
4484 4484
      */
4485 4485
 
4486
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4486
+    return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
4487 4487
 }
4488 4488
 
4489 4489
 /**
@@ -4606,7 +4606,7 @@  discard block
 block discarded – undo
4606 4606
     }
4607 4607
     
4608 4608
     $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4609
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4609
+    $is_admin = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
4610 4610
     $inline_save = $action == 'inline-save' ? true : false;
4611 4611
 
4612 4612
     if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
@@ -4617,7 +4617,7 @@  discard block
 block discarded – undo
4617 4617
         return;
4618 4618
     }
4619 4619
 
4620
-    $user_id = (int)get_current_user_id();
4620
+    $user_id = (int) get_current_user_id();
4621 4621
         
4622 4622
     if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4623 4623
         $author_id = !empty($post->post_author) ? $post->post_author : 0;
@@ -4661,7 +4661,7 @@  discard block
 block discarded – undo
4661 4661
     $nr  = geodir_title_meta_pagenumbering('nr');
4662 4662
 
4663 4663
     if ($max > 1 && $nr > 1) {
4664
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4664
+        $replacement = sprintf($sep.' '.__('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4665 4665
     }
4666 4666
 
4667 4667
     return $replacement;
@@ -4680,7 +4680,7 @@  discard block
 block discarded – undo
4680 4680
 
4681 4681
     $nr = geodir_title_meta_pagenumbering('nr');
4682 4682
     if (isset($nr) && $nr > 0) {
4683
-        $replacement = (string)$nr;
4683
+        $replacement = (string) $nr;
4684 4684
     }
4685 4685
 
4686 4686
     return $replacement;
@@ -4699,7 +4699,7 @@  discard block
 block discarded – undo
4699 4699
 
4700 4700
     $max = geodir_title_meta_pagenumbering('max');
4701 4701
     if (isset($max) && $max > 0) {
4702
-        $replacement = (string)$max;
4702
+        $replacement = (string) $max;
4703 4703
     }
4704 4704
 
4705 4705
     return $replacement;
@@ -4741,7 +4741,7 @@  discard block
 block discarded – undo
4741 4741
         }
4742 4742
 
4743 4743
         if (isset($post->post_content)) {
4744
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4744
+            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->') + 1);
4745 4745
         }
4746 4746
     }
4747 4747
 
@@ -4790,10 +4790,10 @@  discard block
 block discarded – undo
4790 4790
  *
4791 4791
  * @return array
4792 4792
  */
4793
-function geodir_remove_hentry( $class ) {
4794
-    if(geodir_is_page('detail')){
4795
-        $class = array_diff( $class, array( 'hentry' ) );
4793
+function geodir_remove_hentry($class) {
4794
+    if (geodir_is_page('detail')) {
4795
+        $class = array_diff($class, array('hentry'));
4796 4796
     }
4797 4797
     return $class;
4798 4798
 }
4799
-add_filter( 'post_class', 'geodir_remove_hentry' );
4800 4799
\ No newline at end of file
4800
+add_filter('post_class', 'geodir_remove_hentry');
4801 4801
\ 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.
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.
Spacing   +61 added lines, -61 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() ) {
51
-				$this->prefix = '_' . get_current_blog_id();
49
+		if ($this->use_php_sessions) {
50
+			if (is_multisite()) {
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' ) ) {
63
-				require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/class-recursive-arrayaccess.php';
62
+			if (!class_exists('Recursive_ArrayAccess')) {
63
+				require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/class-recursive-arrayaccess.php';
64 64
 			}
65 65
 
66
-			if ( !class_exists( 'WP_Session' ) ) {
67
-				require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/class-wp-session.php';
68
-				require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/wp-session.php';
66
+			if (!class_exists('WP_Session')) {
67
+				require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/class-wp-session.php';
68
+				require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/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.
geodirectory-functions/location_functions.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *
37 37
  * @since 1.0.0
38 38
  * @package GeoDirectory
39
- * @return object
39
+ * @return string
40 40
  */
41 41
 function geodir_get_default_location()
42 42
 {
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
  * @package GeoDirectory
324 324
  * @param int $min The minimum number. Default: 0.
325 325
  * @param int $max The maximum number. Default: 1.
326
- * @return float
326
+ * @return integer
327 327
  */
328 328
 function geodir_random_float($min = 0, $max = 1)
329 329
 {
Please login to merge, or discard this patch.
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -61,11 +61,12 @@  discard block
 block discarded – undo
61 61
 function geodir_is_default_location_set()
62 62
 {
63 63
     $default_location = geodir_get_default_location();
64
-    if (!empty($default_location))
65
-        return true;
66
-    else
67
-        return false;
68
-}
64
+    if (!empty($default_location)) {
65
+            return true;
66
+    } else {
67
+            return false;
68
+    }
69
+    }
69 70
 
70 71
 /**
71 72
  * Returns location slug using location string.
@@ -258,8 +259,9 @@  discard block
 block discarded – undo
258 259
 
259 260
         }
260 261
 
261
-        if ($geodir_location->is_default)
262
-            update_option('geodir_default_location', $geodir_location);
262
+        if ($geodir_location->is_default) {
263
+                    update_option('geodir_default_location', $geodir_location);
264
+        }
263 265
 
264 266
         return $geodir_location->location_id;
265 267
 
@@ -307,9 +309,10 @@  discard block
 block discarded – undo
307 309
     $status = $data->status;
308 310
     if ($status == "OK") {
309 311
         return $data->results[0]->address_components;
310
-    } else
311
-        return false;
312
-}
312
+    } else {
313
+            return false;
314
+    }
315
+    }
313 316
 
314 317
 /**
315 318
  * Returns current location terms.
@@ -333,16 +336,19 @@  discard block
 block discarded – undo
333 336
         }
334 337
 
335 338
         $country = $gd_session->get('gd_country');
336
-        if ($country != '' && $country)
337
-            $location_array['gd_country'] = urldecode($country);
339
+        if ($country != '' && $country) {
340
+                    $location_array['gd_country'] = urldecode($country);
341
+        }
338 342
 
339 343
         $region = $gd_session->get('gd_region');
340
-        if ($region != '' && $region)
341
-            $location_array['gd_region'] = urldecode($region);
344
+        if ($region != '' && $region) {
345
+                    $location_array['gd_region'] = urldecode($region);
346
+        }
342 347
 
343 348
         $city = $gd_session->get('gd_city');
344
-        if ($city != '' && $city)
345
-            $location_array['gd_city'] = urldecode($city);
349
+        if ($city != '' && $city) {
350
+                    $location_array['gd_city'] = urldecode($city);
351
+        }
346 352
     } else {
347 353
         if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
348 354
             return $location_array;
@@ -354,14 +360,17 @@  discard block
 block discarded – undo
354 360
 
355 361
         $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
356 362
 
357
-        if ($country != '')
358
-            $location_array['gd_country'] = urldecode($country);
363
+        if ($country != '') {
364
+                    $location_array['gd_country'] = urldecode($country);
365
+        }
359 366
 
360
-        if ($region != '')
361
-            $location_array['gd_region'] = urldecode($region);
367
+        if ($region != '') {
368
+                    $location_array['gd_region'] = urldecode($region);
369
+        }
362 370
 
363
-        if ($city != '')
364
-            $location_array['gd_city'] = urldecode($city);
371
+        if ($city != '') {
372
+                    $location_array['gd_city'] = urldecode($city);
373
+        }
365 374
 			
366 375
 		// Fix category link in ajax popular category widget on change post type
367 376
 		if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 {
125 125
     global $wpdb;
126 126
 
127
-    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
127
+    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM ".GEODIR_COUNTRIES_TABLE." ORDER BY Country ASC");
128 128
     
129 129
     $ISO2 = array();
130 130
     $countries = array();
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
     
137 137
     asort($countries);
138 138
     
139
-    $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
139
+    $out_put = '<option '.selected('', $post_country, false).' value="">'.__('Select Country', 'geodirectory').'</option>';
140 140
     foreach ($countries as $country => $name) {
141 141
         $ccode = $ISO2[$country];
142 142
 
143
-        $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
143
+        $out_put .= '<option '.selected($post_country, $country, false).' value="'.esc_attr($country).'" data-country_code="'.$ccode.'">'.$name.'</option>';
144 144
     }
145 145
 
146 146
     echo $out_put;
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
         if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
183 183
 
184 184
             foreach ($posttype as $posttypeobj) {
185
-                $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
185
+                $post_locations = '['.$default_location->city_slug.'],['.$default_location->region_slug.'],['.$default_location->country_slug.']'; // set all overall post location
186 186
 
187 187
                 $sql = $wpdb->prepare(
188
-                    "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
188
+                    "UPDATE ".$plugin_prefix.$posttypeobj."_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189 189
                     array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190 190
                 );
191 191
                 $wpdb->query($sql);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
          *
234 234
          * @since 1.0.0
235 235
          */
236
-        $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
236
+        $geodir_location = (object) apply_filters('geodir_add_new_location', array('location_id' => 0,
237 237
             'country' => $location_country,
238 238
             'region' => $location_region,
239 239
             'city' => $location_city,
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 
249 249
         if ($geodir_location->country) {
250 250
 
251
-            $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
251
+            $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country=%s", array($geodir_location->country)));
252 252
 
253 253
             if (empty($get_country)) {
254 254
 
255
-                $wpdb->query($wpdb->prepare("INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (Country, Title) VALUES (%s,%s)", array($geodir_location->country, $geodir_location->country)));
255
+                $wpdb->query($wpdb->prepare("INSERT INTO ".GEODIR_COUNTRIES_TABLE." (Country, Title) VALUES (%s,%s)", array($geodir_location->country, $geodir_location->country)));
256 256
 
257 257
             }
258 258
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function geodir_get_address_by_lat_lan($lat, $lng)
295 295
 {
296
-    $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ;
296
+    $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng);
297 297
 
298 298
     $ch = curl_init();
299 299
     curl_setopt($ch, CURLOPT_URL, $url);
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 * @param string $location_array_from Source type of location terms. Default session.
387 387
 	 * @param string $gd_post_type WP post type.
388 388
 	 */
389
-	$location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type );
389
+	$location_array = apply_filters('geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type);
390 390
 
391 391
     return $location_array;
392 392
 
Please login to merge, or discard this patch.
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function geodir_get_current_city_lat()
11 11
 {
12
-    $location = geodir_get_default_location();
13
-    $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484';
12
+	$location = geodir_get_default_location();
13
+	$lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484';
14 14
 
15
-    return $lat;
15
+	return $lat;
16 16
 }
17 17
 
18 18
 /**
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function geodir_get_current_city_lng()
27 27
 {
28
-    $location = geodir_get_default_location();
29
-    $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786';
30
-    return $lng;
28
+	$location = geodir_get_default_location();
29
+	$lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786';
30
+	return $lng;
31 31
 }
32 32
 
33 33
 
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function geodir_get_default_location()
42 42
 {
43
-    /**
44
-     * Filter the default location.
45
-     *
46
-     * @since 1.0.0
47
-     * @package GeoDirectory
48
-     *
49
-     * @param string $location_result The default location object.
50
-     */
51
-    return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location'));
43
+	/**
44
+	 * Filter the default location.
45
+	 *
46
+	 * @since 1.0.0
47
+	 * @package GeoDirectory
48
+	 *
49
+	 * @param string $location_result The default location object.
50
+	 */
51
+	return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location'));
52 52
 }
53 53
 
54 54
 /**
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function geodir_is_default_location_set()
62 62
 {
63
-    $default_location = geodir_get_default_location();
64
-    if (!empty($default_location))
65
-        return true;
66
-    else
67
-        return false;
63
+	$default_location = geodir_get_default_location();
64
+	if (!empty($default_location))
65
+		return true;
66
+	else
67
+		return false;
68 68
 }
69 69
 
70 70
 /**
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 function create_location_slug($location_string)
79 79
 {
80 80
 
81
-    /**
82
-     * Filter the location slug.
83
-     *
84
-     * @since 1.0.0
85
-     * @package GeoDirectory
86
-     *
87
-     * @param string $location_string Sanitized location string.
88
-     */
89
-    return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string)));
81
+	/**
82
+	 * Filter the location slug.
83
+	 *
84
+	 * @since 1.0.0
85
+	 * @package GeoDirectory
86
+	 *
87
+	 * @param string $location_string Sanitized location string.
88
+	 */
89
+	return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string)));
90 90
 
91 91
 }
92 92
 
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_get_location($id = '')
102 102
 {
103
-    /**
104
-     * Filter the location information.
105
-     *
106
-     * @since 1.0.0
107
-     * @package GeoDirectory
108
-     *
109
-     * @param string $id The location ID.
110
-     */
111
-    return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id);
103
+	/**
104
+	 * Filter the location information.
105
+	 *
106
+	 * @since 1.0.0
107
+	 * @package GeoDirectory
108
+	 *
109
+	 * @param string $id The location ID.
110
+	 */
111
+	return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id);
112 112
 }
113 113
 
114 114
 /**
@@ -122,28 +122,28 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function geodir_get_country_dl($post_country = '', $prefix = '')
124 124
 {
125
-    global $wpdb;
125
+	global $wpdb;
126 126
 
127
-    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
127
+	$rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
128 128
     
129
-    $ISO2 = array();
130
-    $countries = array();
129
+	$ISO2 = array();
130
+	$countries = array();
131 131
     
132
-    foreach ($rows as $row) {
133
-        $ISO2[$row->Country] = $row->ISO2;
134
-        $countries[$row->Country] = __($row->Country, 'geodirectory');
135
-    }
132
+	foreach ($rows as $row) {
133
+		$ISO2[$row->Country] = $row->ISO2;
134
+		$countries[$row->Country] = __($row->Country, 'geodirectory');
135
+	}
136 136
     
137
-    asort($countries);
137
+	asort($countries);
138 138
     
139
-    $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
140
-    foreach ($countries as $country => $name) {
141
-        $ccode = $ISO2[$country];
139
+	$out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
140
+	foreach ($countries as $country => $name) {
141
+		$ccode = $ISO2[$country];
142 142
 
143
-        $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
144
-    }
143
+		$out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
144
+	}
145 145
 
146
-    echo $out_put;
146
+	echo $out_put;
147 147
 }
148 148
 
149 149
 
@@ -158,40 +158,40 @@  discard block
 block discarded – undo
158 158
 function geodir_location_form_submit()
159 159
 {
160 160
 
161
-    global $wpdb, $plugin_prefix;
162
-    if (isset($_REQUEST['add_location'])) {
161
+	global $wpdb, $plugin_prefix;
162
+	if (isset($_REQUEST['add_location'])) {
163 163
 
164
-        $location_info = array(
165
-            'city' => $_REQUEST['city'],
166
-            'region' => $_REQUEST['region'],
167
-            'country' => $_REQUEST['country'],
168
-            'geo_lat' => $_REQUEST['latitude'],
169
-            'geo_lng' => $_REQUEST['longitude'],
170
-            'is_default' => $_REQUEST['is_default'],
171
-            'update_city' => $_REQUEST['update_city']
172
-        );
164
+		$location_info = array(
165
+			'city' => $_REQUEST['city'],
166
+			'region' => $_REQUEST['region'],
167
+			'country' => $_REQUEST['country'],
168
+			'geo_lat' => $_REQUEST['latitude'],
169
+			'geo_lng' => $_REQUEST['longitude'],
170
+			'is_default' => $_REQUEST['is_default'],
171
+			'update_city' => $_REQUEST['update_city']
172
+		);
173 173
 
174
-        $old_location = geodir_get_default_location();
174
+		$old_location = geodir_get_default_location();
175 175
 
176
-        $locationid = geodir_add_new_location($location_info);
176
+		$locationid = geodir_add_new_location($location_info);
177 177
 
178
-        $default_location = geodir_get_location($locationid);
178
+		$default_location = geodir_get_location($locationid);
179 179
 
180
-        //UPDATE AND DELETE LISTING
181
-        $posttype = geodir_get_posttypes();
182
-        if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
180
+		//UPDATE AND DELETE LISTING
181
+		$posttype = geodir_get_posttypes();
182
+		if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
183 183
 
184
-            foreach ($posttype as $posttypeobj) {
185
-                $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
184
+			foreach ($posttype as $posttypeobj) {
185
+				$post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
186 186
 
187
-                $sql = $wpdb->prepare(
188
-                    "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189
-                    array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190
-                );
191
-                $wpdb->query($sql);
192
-            }
193
-        }
194
-    }
187
+				$sql = $wpdb->prepare(
188
+					"UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189
+					array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190
+				);
191
+				$wpdb->query($sql);
192
+			}
193
+		}
194
+	}
195 195
 }
196 196
 
197 197
 /**
@@ -214,58 +214,58 @@  discard block
 block discarded – undo
214 214
  */
215 215
 function geodir_add_new_location($location_info = array())
216 216
 {
217
-    global $wpdb;
217
+	global $wpdb;
218 218
 
219
-    if (!empty($location_info)) {
219
+	if (!empty($location_info)) {
220 220
 
221
-        $location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all';
222
-        $location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all';
223
-        $location_country = ($location_info['country'] != '') ? $location_info['country'] : 'all';
224
-        $location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : '';
225
-        $location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : '';
226
-        $is_default = isset($location_info['is_default']) ? $location_info['is_default'] : '';
227
-        $country_slug = create_location_slug(__($location_country, 'geodirectory'));
228
-        $region_slug = create_location_slug($location_region);
229
-        $city_slug = create_location_slug($location_city);
221
+		$location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all';
222
+		$location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all';
223
+		$location_country = ($location_info['country'] != '') ? $location_info['country'] : 'all';
224
+		$location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : '';
225
+		$location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : '';
226
+		$is_default = isset($location_info['is_default']) ? $location_info['is_default'] : '';
227
+		$country_slug = create_location_slug(__($location_country, 'geodirectory'));
228
+		$region_slug = create_location_slug($location_region);
229
+		$city_slug = create_location_slug($location_city);
230 230
 
231
-        /**
232
-         * Filter add new location data.
233
-         *
234
-         * @since 1.0.0
235
-         */
236
-        $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
237
-            'country' => $location_country,
238
-            'region' => $location_region,
239
-            'city' => $location_city,
240
-            'country_slug' => $country_slug,
241
-            'region_slug' => $region_slug,
242
-            'city_slug' => $city_slug,
243
-            'city_latitude' => $location_lat,
244
-            'city_longitude' => $location_lng,
245
-            'is_default' => $is_default
246
-        ));
231
+		/**
232
+		 * Filter add new location data.
233
+		 *
234
+		 * @since 1.0.0
235
+		 */
236
+		$geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
237
+			'country' => $location_country,
238
+			'region' => $location_region,
239
+			'city' => $location_city,
240
+			'country_slug' => $country_slug,
241
+			'region_slug' => $region_slug,
242
+			'city_slug' => $city_slug,
243
+			'city_latitude' => $location_lat,
244
+			'city_longitude' => $location_lng,
245
+			'is_default' => $is_default
246
+		));
247 247
 
248 248
 
249
-        if ($geodir_location->country) {
249
+		if ($geodir_location->country) {
250 250
 
251
-            $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
251
+			$get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
252 252
 
253
-            if (empty($get_country)) {
253
+			if (empty($get_country)) {
254 254
 
255
-                $wpdb->query($wpdb->prepare("INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (Country, Title) VALUES (%s,%s)", array($geodir_location->country, $geodir_location->country)));
255
+				$wpdb->query($wpdb->prepare("INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (Country, Title) VALUES (%s,%s)", array($geodir_location->country, $geodir_location->country)));
256 256
 
257
-            }
257
+			}
258 258
 
259
-        }
259
+		}
260 260
 
261
-        if ($geodir_location->is_default)
262
-            update_option('geodir_default_location', $geodir_location);
261
+		if ($geodir_location->is_default)
262
+			update_option('geodir_default_location', $geodir_location);
263 263
 
264
-        return $geodir_location->location_id;
264
+		return $geodir_location->location_id;
265 265
 
266
-    } else {
267
-        return false;
268
-    }
266
+	} else {
267
+		return false;
268
+	}
269 269
 }
270 270
 
271 271
 /**
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
  */
280 280
 function geodir_random_float($min = 0, $max = 1)
281 281
 {
282
-    return $min + mt_rand() / mt_getrandmax() * ($max - $min);
282
+	return $min + mt_rand() / mt_getrandmax() * ($max - $min);
283 283
 }
284 284
 
285 285
 /**
@@ -293,22 +293,22 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function geodir_get_address_by_lat_lan($lat, $lng)
295 295
 {
296
-    $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ;
297
-
298
-    $ch = curl_init();
299
-    curl_setopt($ch, CURLOPT_URL, $url);
300
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
301
-    curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
302
-    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
303
-    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
304
-    $response = curl_exec($ch);
305
-    curl_close($ch);
306
-    $data = json_decode($response);
307
-    $status = $data->status;
308
-    if ($status == "OK") {
309
-        return $data->results[0]->address_components;
310
-    } else
311
-        return false;
296
+	$url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ;
297
+
298
+	$ch = curl_init();
299
+	curl_setopt($ch, CURLOPT_URL, $url);
300
+	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
301
+	curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
302
+	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
303
+	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
304
+	$response = curl_exec($ch);
305
+	curl_close($ch);
306
+	$data = json_decode($response);
307
+	$status = $data->status;
308
+	if ($status == "OK") {
309
+		return $data->results[0]->address_components;
310
+	} else
311
+		return false;
312 312
 }
313 313
 
314 314
 /**
@@ -325,70 +325,70 @@  discard block
 block discarded – undo
325 325
  */
326 326
 function geodir_get_current_location_terms($location_array_from = 'session', $gd_post_type = '')
327 327
 {
328
-    global $wp, $gd_session;
329
-    $location_array = array();
330
-    if ($location_array_from == 'session') {
331
-        if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
332
-            return $location_array;
333
-        }
328
+	global $wp, $gd_session;
329
+	$location_array = array();
330
+	if ($location_array_from == 'session') {
331
+		if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
332
+			return $location_array;
333
+		}
334 334
 
335
-        $country = $gd_session->get('gd_country');
336
-        if ($country != '' && $country)
337
-            $location_array['gd_country'] = urldecode($country);
335
+		$country = $gd_session->get('gd_country');
336
+		if ($country != '' && $country)
337
+			$location_array['gd_country'] = urldecode($country);
338 338
 
339
-        $region = $gd_session->get('gd_region');
340
-        if ($region != '' && $region)
341
-            $location_array['gd_region'] = urldecode($region);
339
+		$region = $gd_session->get('gd_region');
340
+		if ($region != '' && $region)
341
+			$location_array['gd_region'] = urldecode($region);
342 342
 
343
-        $city = $gd_session->get('gd_city');
344
-        if ($city != '' && $city)
345
-            $location_array['gd_city'] = urldecode($city);
346
-    } else {
347
-        if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
348
-            return $location_array;
349
-        }
343
+		$city = $gd_session->get('gd_city');
344
+		if ($city != '' && $city)
345
+			$location_array['gd_city'] = urldecode($city);
346
+	} else {
347
+		if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
348
+			return $location_array;
349
+		}
350 350
 
351
-        $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
351
+		$country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
352 352
 
353
-        $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
353
+		$region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
354 354
 
355
-        $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
355
+		$city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
356 356
 
357
-        if ($country != '')
358
-            $location_array['gd_country'] = urldecode($country);
357
+		if ($country != '')
358
+			$location_array['gd_country'] = urldecode($country);
359 359
 
360
-        if ($region != '')
361
-            $location_array['gd_region'] = urldecode($region);
360
+		if ($region != '')
361
+			$location_array['gd_region'] = urldecode($region);
362 362
 
363
-        if ($city != '')
364
-            $location_array['gd_city'] = urldecode($city);
363
+		if ($city != '')
364
+			$location_array['gd_city'] = urldecode($city);
365 365
 			
366 366
 		// Fix category link in ajax popular category widget on change post type
367 367
 		if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
368 368
 			$location_array = geodir_get_current_location_terms('session');
369 369
 		}
370
-    }
370
+	}
371 371
 
372 372
 	/**
373 373
 	 * Filter the location terms.
374 374
 	 *
375 375
 	 * @since 1.4.6
376
-     * @package GeoDirectory
376
+	 * @package GeoDirectory
377
+	 *
378
+	 * @param array $location_array {
379
+	 *    Attributes of the location_array.
377 380
 	 *
378
-     * @param array $location_array {
379
-     *    Attributes of the location_array.
380
-     *
381
-     *    @type string $gd_country The country slug.
382
-     *    @type string $gd_region The region slug.
383
-     *    @type string $gd_city The city slug.
384
-     *
385
-     * }
381
+	 *    @type string $gd_country The country slug.
382
+	 *    @type string $gd_region The region slug.
383
+	 *    @type string $gd_city The city slug.
384
+	 *
385
+	 * }
386 386
 	 * @param string $location_array_from Source type of location terms. Default session.
387 387
 	 * @param string $gd_post_type WP post type.
388 388
 	 */
389 389
 	$location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type );
390 390
 
391
-    return $location_array;
391
+	return $location_array;
392 392
 
393 393
 }
394 394
 
@@ -401,22 +401,22 @@  discard block
 block discarded – undo
401 401
  * @return bool|string
402 402
  */
403 403
 function geodir_get_location_link($which_location = 'current') {
404
-    $location_link = get_permalink(geodir_location_page_id());
405
-
406
-    if ($which_location == 'base') {
407
-        return $location_link;
408
-    } else {
409
-        $location_terms = geodir_get_current_location_terms();
410
-
411
-        if (!empty($location_terms)) {
412
-            if (get_option('permalink_structure') != '') {
413
-                $location_terms = implode("/", $location_terms);
414
-                $location_terms = rtrim($location_terms, '/');
415
-                $location_link .= $location_terms;
416
-            } else {
417
-                $location_link = geodir_getlink($location_link, $location_terms);
418
-            }
419
-        }
420
-    }
421
-    return $location_link;
404
+	$location_link = get_permalink(geodir_location_page_id());
405
+
406
+	if ($which_location == 'base') {
407
+		return $location_link;
408
+	} else {
409
+		$location_terms = geodir_get_current_location_terms();
410
+
411
+		if (!empty($location_terms)) {
412
+			if (get_option('permalink_structure') != '') {
413
+				$location_terms = implode("/", $location_terms);
414
+				$location_terms = rtrim($location_terms, '/');
415
+				$location_link .= $location_terms;
416
+			} else {
417
+				$location_link = geodir_getlink($location_link, $location_terms);
418
+			}
419
+		}
420
+	}
421
+	return $location_link;
422 422
 }
Please login to merge, or discard this patch.